Keil Logo


The bdata memory type can be used only to declare variables You can not declare bdata functions. This memory is accessed using 16-bit addresses and is the on-chip bit-addressable memory (0xFD00 - 0xFDFF) of the C16x/ST10/XC16x. This memory (which is limited to 256 bytes) can be accessed as bytes, words, or as bits.

Variables declared bdata are located in the SDATA group.

Declare bdata variables as follows:

unsigned int bdata ba_var;

Declare bits within a bdata variable as follows:

sbit ba_bit_0 = ba_var ^ 0;    /* Bit 0 of ba_var */
sbit ba_bit_8 = ba_var ^ 8;    /* Bit 8 of ba_var */

The C16x/XC16x/ST10 microcontrollers provide very efficient bit instructions. A bit-field structure that has single bit members is located in the BDATA address space by using the memory type bdata. In this case, bit-fields are accessed with the efficient bit instructions. For example:

struct test {
  int bit0: 1;
  int bit1: 1;
  int bit2: 1;
  int bit3: 1;
  int bit4: 1;
  int bit5: 1;

struct test bdata t;

void main (void)  {
  t.bit0 = 1;
  if (t.bit1) {
    t.bit2 = t.bit0;

You can use the HOLD directive to locate structures with single-bit bit-fields to the BDATA memory area. Then, the compiler generates bit instructions to access the bit-fields. For example:

C166 MYPROG.C HOLD (bdata 2, near 6)

locates all structures (smaller than 2 bytes) with bit-fields to the BDATA memory.


  • sbit variables can be defined only at file level. It is impossible to define automatic sbit variables or to use sbit in local function variables. You can use bit-field structures instead.

Related Knowledgebase Articles

  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.