Has anyone had troubles with codewarrior 5.1 giving error 2801 when using a freescale define in a macro?
Including header file "mc9s12A64.h".
Using its #define for "PORTA_BIT3" which defines "_PORTAB.Overlap_STR.PORTASTR.Bits.BIT3"
I created macros to turn the bit ON or OFF as follows
#define LED_ON (_PORTA_BIT3 = 1)
#define LED_OFF (_PORTA_BIT3 = 0)
Using this creates the error C2801.
If I change the macros to
#define LED_ON (PORTA = PORTA | PORTA_BIT3_MASK)
#define LED_OFF (PORTA = PORTA & ~PORTA_BIT3_MASK)
where the header file defines PORTA to be "_PORTAB.Overlap_STR.PORTASTR.Byte", it compiles correctly.
The same problem occurs if you want to test a port pin
#define READ_BIT1 (PORTA_BIT1 == 1) // error
but
#define READ_BIT1 ((PORTA & PORTA_BIT1_MASK) == 1) // ok
The only difference between the 2 methods is the last few chars in the defines. Either ".Bits.BIT3" or ".Byte".
I assume that either method would produce the same code but the first method is nicer and easier to do.
Anyone got any ideas or solutions???
Hello Phillip,
any breakthrough with your project? Please keep us posted :smileywink:
Best,
Monica,
Thanks everyone.
Sorry it's taken me a while to come back to you, but had to get some other work out.
Unfortunately I have gotten no further other than to say the problem must be in my project somewhere.
I created a new project to show the issue but as Zhang-Jennie found it didn't show.
I tried setting up all my compiler options to match and it made no difference.
So I'll have to let it rest for now until I find the problem. When I do I'll let you know what it was.
Thanks again
Phil
Ensure that you haven't set the compiler to compile as strict C standard. The CW register headers use various non-standard and poorly-defined bit field features that a standard compiler will get problems compiling.
Thanks.
No not set to strict C
I just tested your code on my side with CW5.1 i didn't see any error come out. can you please upload your demo project here so that we can check it directly? thanks!