Bit-banding: When should it be used?

Go To Last Post
3 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

The SAMG55 (and other Cortex M3/4) processors have a bit-band region in the lower 1MB of the SRAM and peripheral regions.  For this chip, that means that the entire SRAM and peripheral addresses are within the bit-band region. 

 

Is there a reason NOT to write any single bit access to use the bit-band alias?  I don't see it used at all in Atmel driver code.  For instance, looking at a random"set bit" instruction, instead of doing:
 

static inline void hri_pio_set_ABCDSR_P0_bit(const void *const hw, uint8_t index)
{
	PIO_CRITICAL_SECTION_ENTER();
	((Pio *)hw)->PIO_ABCDSR
|= PIO_ABCDSR_P0; PIO_CRITICAL_SECTION_LEAVE(); }

The same thing could be accomplished by simply writing a 1 to the bit-band alias of the PIO_ABCDSR_P0 bit in the PIO_ABCDSR register, and wouldn't require the CRITICAL_SECTION wrapper to be atomic.

 

Is there a good reason not to make full use of bit-banding? 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Is there a good reason not to make full use of bit-banding? 

It seems to have fallen into disfavor, and isn't implemented at all in newer chips (CM7, many of the CM4 chips. (SAMx5x))

Someone said it interacts poorly with caches.

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Thanks, that makes sense for why I don't see more mention/use of it.  FWIW, it is in the SAMG55.