I wonder to know is there anyone who define a variable in bit-banded region in c programming language for cortex-M3 particularly LPC17XX.

I have followed the compiler attribute for Keil (__attribute__((bitband))) based on the link but when I check the address range in debugger, it has been defined out of the scope of bit-banded region and it seems the attribute doesn't effect the code, even when I set the more specific region address with this attribute __attribute__((at())) ?

As far as I know, by having a byte represent a bit directly in the memory controller, the processor does not need to perform a read + modify + write sequence command to set/clear or toggle a bit as in the ARM information centre says:

This allows every individual bit in the bit-banding region to be directly accessible from a word-aligned address using a single LDR instruction. It also allows individual bits to be toggled from C without performing a read-modify-write sequence of instructions.

My another question is for set a bit what we should write in the byte that represented a bit. Any value except zero or just 1 is accepted?

How about toggling the bit (without the three step sequence)?

  • \$\begingroup\$ just a wild guess: perhaps the variable is declared in the bitband alias memory region (where depending upon it's address, lsb of each individual word (32 bits) acts as an alias for the corresponding bit in bitband memory) \$\endgroup\$ – Bhavneet Singh Bajwa Apr 15 '17 at 6:48

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.