Keil Logo

C166: DECLARING BDATA AND SBIT VARIABLES


Information in this article applies to:

  • C166 Version 5 and Later

QUESTION

I'm trying to use the SBIT keyword to create a bit in a BDATA variable, but I can't seem to get the example program to work:

void main (void)
  {
  bdata int ibase;
  sbit mybit0 = ibase ^ 0;
  .
  .
  .
  mybit0 = 1;
}

I get the following compiler messages:

*** WARNING C189: 'ibase': storage class changed to 'static'
*** ERROR C25: syntax error near 'sbit'

How do I declare local bits?

ANSWER

As stated in the C166 User's Guide, the sbit notation can be only used in combintion with global variables. This means that you need to define the variable at file level.

However, you may use bit-field structures instead, since the usage of bit-field structures is not restricted.

Example:

struct b {
  unsigned int  _0: 1;
  unsigned int  _1: 1;
  unsigned int  _2: 1;
  unsigned int  _3: 1;
  unsigned int  _4: 1;
  unsigned int  _5: 1;
  unsigned int  _6: 1;
  unsigned int  _7: 1;
  unsigned int  _8: 1;
  unsigned int  _9: 1;
  unsigned int _10: 1;
  unsigned int _11: 1;
  unsigned int _12: 1;
  unsigned int _13: 1;
  unsigned int _14: 1;
  unsigned int _15: 1;
};

void main (void) {
  static struct b bdata ibase;

  ibase_1 = 1;
}

MORE INFORMATION

  • Refer to bdata in the C166 User's Guide.

SEE ALSO

Last Reviewed: Sunday, March 12, 2006


Did this article provide the answer you needed?
 
Yes
No
Not Sure
 
  Arm logo
Important information

This site uses cookies to store information on your computer. By continuing to use our site, you consent to our cookies.

Change Settings

Privacy Policy Update

Arm’s Privacy Policy has been updated. By continuing to use our site, you consent to Arm’s Privacy Policy. Please review our Privacy Policy to learn more about our collection, use and transfers
of your data.