| ARM Technical Support Knowledge Articles | |
Applies to: C51 C Compiler
Information in this article applies to:
I've created the following program.
void main (void)
{
sfr P1 = 0x90;
while (1)
{
P1 ^= 0xFF;
}
}
When I compile it, I receive the following error messages:
*** ERROR C141 IN LINE 3 OF .MAIN.C: syntax error near 'sfr' *** ERROR C202 IN LINE 3 OF .MAIN.C: 'P1': undefined identifier
What's wrong?
SBIT and SFR objects may not be declared inside a function definition. They must be declared outside of a function. The following code compiles with no errors or warnings.
sfr P1 = 0x90;
void main (void)
{
while (1)
{
P1 ^= 0xFF;
}
}
Article last edited on: 2007-03-27 17:32:26
Did you find this article helpful? Yes No
How can we improve this article?