ARM Technical Support Knowledge Articles

ERRORS USING SBITS AND SFRS

Applies to: C51 C Compiler

Answer


Information in this article applies to:


QUESTION

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?

ANSWER

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;
  }
}

MORE INFORMATION

Article last edited on: 2007-03-27 17:32:26

Rate this article

[Bad]
|
|
[Good]
Disagree? Move your mouse over the bar and click

Did you find this article helpful? Yes No

How can we improve this article?

Link to this article
Copyright © 2011 ARM Limited. All rights reserved. External (Open), Non-Confidential