Electronic – Bit banding in Arm cortex M4

armcortex-m4microcontroller

I am confused about the concept of using a pin offset in bit banding. EG, given that PORTA has a base address of 0x40004000 and the 5th bit has an offset of 0x0080, the address of the pin should be 0x40004080
and I use this address to read/write to this bit.

My questions are :
1 – Is this address in the 1 MB bit band region or it's in the alias ?
2 – How can the sum of two different bins offsets + the base port address allows us to write to the two pins simultaneously? is it some sort of a mask ?


sorry if my questions are not clear, I am really confused.

Best Answer

The bit specific address is an alias for an operation conducted on a specific bit of an address in the bit band target region.

If you wish to make a simultaneous change to multiple bits, you should not use the bit-band alias, but some other mechanism. This might be a traditional read-modify-write operation.

Many MCU's also have their own vendor-unique hardware mechanism for GPIO modification distinct from the inherited ARM bit band idea, for example ST has the BSRR register where you can set or clear a group of bits on a GPIO port.