AnsweredAssumed Answered

Bit-banding on STM32L series

Question asked by lake.michael.001 on Jun 3, 2011
Latest reply on Jun 3, 2011 by Clive One
Hi,

I'm trying to get bit-banding to work on STM32L series. It seems that some header  definitions have changed between STM32F and STM32L so it's not clear how bit-banding should be implemented.

I've tried the following:

#define BITBAND_PERI_REF   0x40000000
#define BITBAND_PERI_BASE  0x42000000
#define BITBAND_PERI(a,b) ((BITBAND_PERI_BASE + (a-BITBAND_PERI_REF)*32 + (b*4)))  // Convert PERI address

//Offset of ODR in GPIO_TypeDef = 0x14?
//GPIOA ODR = 0x40000000 + 0x00020000 + 0x000 + 0x14
//GPIOB ODR = 0x40000000 + 0x00020000 + 0x400 + 0x14
//GPIOC ODR = 0x40000000 + 0x00020000 + 0x800 + 0x14
//GPIOD ODR = 0x40000000 + 0x00020000 + 0xC00 + 0x14
#define GPIOA_BB(b) *((volatile uint32_t *)(BITBAND_PERI(0x40020014,b)))
#define GPIOB_BB(b) *((volatile uint32_t *)(BITBAND_PERI(0x40020414,b)))
#define GPIOC_BB(b) *((volatile uint32_t *)(BITBAND_PERI(0x40020814,b)))
#define GPIOD_BB(b) *((volatile uint32_t *)(BITBAND_PERI(0x40020C14,b)))

But it doesn't seem to work. Any ideas on how we can solve this?

Thanks.

Outcomes