7 Replies Latest reply on Jul 25, 2019 1:27 AM by MoTa_728816

    Gpio1pin macro expansion problem

    OlPe_282281

      Hello,

       

      not really FM4 specific, but I run into a problem with the macro code arround the Gpio1pin  macros:

       

      my_project.h

      #define GPIO_PIN_TIMING_CHECKPOINT   GPIO1PIN_PB3

       

      main.c

      Gpio1pin_InitOut(GPIO_PIN_TIMING_CHECKPOINT, Gpio1pin_InitVal(1u));

       

      get expanded as

      do{ stc_gpio1pin_init_t __v__;\

                                               __v__.bPullup=0u;__v__.bInitVal=0u;\

                                               ((__v__.bInitVal=(1u)));\

                                               GPIO_PIN_TIMING_CHECKPOINT_INITOUT(__v__); }while(0)

       

      hence resulting into linker errors. How can I use "aliases" for the pins?

       

      Thanks

        • 1. Re: Gpio1pin macro expansion problem
          ShipingW_81

          Can you help provide below details of this issue?

          - part number of target devie

          - sepcific IDE you developed on

          - your code is custom or based on PDL?

          - your project (if possible)

          • 2. Re: Gpio1pin macro expansion problem
            OlPe_282281

            Hello,

             

            attached the project; I'm using IAR Workbench/ARM 8.32 with the FM4 S6E2CC Pioneer Kit where the project is located at ...\PLD\2.1.0\examples\sk_s6e2gm\adc\fm4runtime; and it's PLD based.

             

            I have to rework from others work which had less experience than me, so don't wonder. The relevant code part is at CyFM4/ConfigGPIO. There is also a define to compile both versions (with project aliases/defines and without - CyFM4Project near bottom).

             

            So I get the linker error:

             

            ---<8---

            Building configuration: fm4runtime - Debug

            Updating build tree...

            Linking

            Error[Li005]: no definition for "GPIO_PIN_TIMING_CHECKPOINT_INITOUT" ..

            Error[Li005]: no definition for "GPIO_PIN_LED_RED_INITOUT" ..

            Error[Li005]: no definition for "GPIO_PIN_LED_GREEN_INITOUT" [..

            Error[Li005]: no definition for "GPIO_PIN_LED_BLUE_INITOUT" ..

            Error[Li005]: no definition for "GPIP_PIN_SCOPE_TRIGGER_INITOUT" ...

            Error while running Linker

             

            Total number of errors: 5

            Total number of warnings: 0

            --->8---

             

            Don't wonder if the answer is there twice, the 'replay' button clock doesn't seems to work at first try.

            • 3. Re: Gpio1pin macro expansion problem
              ShipingW_81

              Unfortunately, the project requires a newer version of IAR than the one installed on my side.

               

              Just from the compile error log, it looks pretty straightforward that the errors caused by lacking definitions of some cusotm GPIO macros. Maybe you need to add these definitions manually in your code.

              • 4. Re: Gpio1pin macro expansion problem
                MoTa_728816

                Hi,

                 

                Since you are using EWARM for FM4, I hope you can submit this question to IAR's support page or send technical request.

                As they are the experts of Compiler, I hope, they can help you better for this topic.

                 

                Having written that, I also tried to trace this problem, although I don't have access to EWARM.

                At first I was thinking that just the macro expansion which you wrote in the first post was not working.

                 

                Then with your second post, I noticed that the Linker error is saying...

                Error[Li005]: no definition for "GPIO_PIN_TIMING_CHECKPOINT_INITOUT" ..

                 

                But as GPIO_PIN_TIMING_CHECKPOINT was defined as GPIO1PIN_PB3in CyFM4Project.h,

                I would expect that the error should read "GPIO1PIN_PB3_INITOUT"...

                Then I noticed that there is a #if 0 statement in the CyFM4_GpioInit() in ConfigGPIO.c.

                 

                May be the one who wrote this also had similar problem.

                How about changing the first "#if 0" in CyFM4_GpioIit() to "#if 1"

                so that real pin names will be used for these?

                 

                As I wrote above, I could not test it by myself,

                so in case it does not work, I'm sorry for that.

                 

                moto

                 

                 

                 

                 

                 

                • 5. Re: Gpio1pin macro expansion problem
                  OlPe_282281

                  Thanks to all for checking my problem. I'm not yet in contact with IAR, but I would assume that the problem is more of general nature, hence independent of used IDE or compiler. At this time other problem are required to be solved, but I know this problem will rise again later on. Anyway, If in ConfigGPIO.c line 10 is '#if 1'... the comon PIN defines from PDL are used, no linker error:

                   

                  Building configuration: fm4runtime - Debug

                  Updating build tree...

                  ConfigGPIO.c

                  Linking

                   

                  Total number of errors: 0

                  Total number of warnings: 0

                   

                  otherwise ('#if 0') full log:

                   

                  Building configuration: fm4runtime - Debug

                  Updating build tree...

                  ConfigGPIO.c

                  Warning[Pe223]: function "GPIO_PIN_TIMING_CHECKPOINT_INITOUT" declared implicitly [...]\fm4runtime\CyFM4\ConfigGPIO.c 23

                  Warning[Pe223]: function "GPIO_PIN_LED_RED_INITOUT" declared implicitly [...]\fm4runtime\CyFM4\ConfigGPIO.c 26

                  Warning[Pe223]: function "GPIO_PIN_LED_GREEN_INITOUT" declared implicitly [...]\fm4runtime\CyFM4\ConfigGPIO.c 27

                  Warning[Pe223]: function "GPIO_PIN_LED_BLUE_INITOUT" declared implicitly [...]\fm4runtime\CyFM4\ConfigGPIO.c 28

                  Warning[Pe223]: function "GPIP_PIN_SCOPE_TRIGGER_INITOUT" declared implicitly [...]\fm4runtime\CyFM4\ConfigGPIO.c 31

                  Linking

                  Error[Li005]: no definition for "GPIO_PIN_TIMING_CHECKPOINT_INITOUT" [referenced from [...]\

                  fm4runtime\iar\output\debug\obj\ConfigGPIO.o]

                  Error[Li005]: no definition for "GPIO_PIN_LED_RED_INITOUT" [referenced from [...]\fm4runtime\iar\

                  output\debug\obj\ConfigGPIO.o]

                  Error[Li005]: no definition for "GPIO_PIN_LED_GREEN_INITOUT" [referenced from [...]\fm4runtime\

                  iar\output\debug\obj\ConfigGPIO.o]

                  Error[Li005]: no definition for "GPIO_PIN_LED_BLUE_INITOUT" [referenced from [...]\fm4runtime\

                  iar\output\debug\obj\ConfigGPIO.o]

                  Error[Li005]: no definition for "GPIP_PIN_SCOPE_TRIGGER_INITOUT" [referenced from [...]\

                  fm4runtime\iar\output\debug\obj\ConfigGPIO.o]

                  Error while running Linker

                   

                  Total number of errors: 5

                  Total number of warnings: 5

                   

                   

                  The strange thing is, even I moved the part of e.g. '#define MY_PIN GPIO1PIN_P1A' from CyFM4Project.h on top of the ConfigGPIO.c file it fails to build too! This is complementary to my experience with the preprocessor, but I'm not in deepth the it.

                   

                  BTW; I assume, most people use KEIL?

                  • 6. Re: Gpio1pin macro expansion problem
                    ShipingW_81

                    It looks this issue related to pure linking logic of your compiler, but nothing to do with FM4. The people here may help little for you.

                    • 7. Re: Gpio1pin macro expansion problem
                      MoTa_728816

                      Hi,

                       

                      I don't think this is a linking logic issue, but the C preprocessor is failing to convert the defined macro to the real pin name(s).

                      And it is taking place in the PDL, so it does have something to do with FM4.

                       

                      I'm suspecting either

                      (1) The #define nest is too deep or too tricky or wrong

                      (2) The preprocessor of the Compiler has a bug which prevents normal process of this definition

                       

                      As I wrote above, apparently the author(s) of the header file was experiencing similar issues

                      so they left the #if statement to disable the "#define"s and provide "real" pin name(s) to the compiler,

                      and  changing #if 0 to #if 1 actually allows the customer compile and link the program.

                       

                      I hope that with this "#if 1" the customer can survive for the time being.

                      Meantime, I hope that he/she contacts IAR for help.

                       

                      having written all above, the bottom line is,

                      YES, I agree with you, we won't be able to help the customer a lot here.

                       

                      moto