Gpio1pin macro expansion problem

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
OlPe_282281
Level 2
Level 2
Welcome! 10 replies posted 5 replies posted

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

0 Likes
1 Solution
MotooTanaka
Level 9
Level 9
Distributor - Marubun (Japan)
First comment on blog Beta tester First comment on KBA

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

View solution in original post

0 Likes
7 Replies
ShipingW_81
Moderator
Moderator
Moderator
500 replies posted 250 solutions authored 250 replies posted

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)

0 Likes
lock attach
Attachments are accessible only for community members.

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.

0 Likes

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.

0 Likes
MotooTanaka
Level 9
Level 9
Distributor - Marubun (Japan)
First comment on blog Beta tester First comment on KBA

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

0 Likes

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?

0 Likes

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.

0 Likes
MotooTanaka
Level 9
Level 9
Distributor - Marubun (Japan)
First comment on blog Beta tester First comment on KBA

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

0 Likes