| |||
| Home > Compiler Command-line Options > --bitband | |||
This option bit-bands all non const global structure objects. It enables a word of memory to be mapped to a single bit in the bit-band region. This enables efficient atomic access to single-bit values in SRAM and Peripheral regions of the memory architecture.
For peripherals that are width sensitive, byte, halfword, and word stores or loads to the alias space are generated for char, short, and int types of bitfields of bit-banded structs respectively.
The following restrictions apply:
This option only affects struct types. Any union type or other aggregate type with a union as a member cannot be bit-banded.
Members of structs cannot be bit-banded individually.
Bit-banded accesses are generated only for single-bit bitfields.
Bit-banded accesses are not generated for const objects, pointers, and local objects.
Bit-banding is only available on some processors. For example, the Cortex-M4 and Cortex-M3 processors.
In Example 1 the
writes to bitfields i and k are
bit-banded when compiled using the --bitband command-line
option.
Example 1. Bit-banding example
typedef struct {
int i : 1;
int j : 2;
int k : 1;
} BB;
BB value;
void update_value(void)
{
value.i = 1;
value.k = 1;
}
Compiler and processor support for bit-banding in Using the Compiler
the Technical Reference Manual for your processor.