ARM Technical Support Knowledge Articles

DECLARING BDATA AND SBIT VARIABLES

Applies to: C166 C Compiler

Answer


Information in this article applies to:


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

SEE ALSO

Article last edited on: 2006-03-12 09:20:13

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