2011-06-03 02:50 AM
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: &sharpdefine BITBAND_PERI_REF 0x40000000 &sharpdefine BITBAND_PERI_BASE 0x42000000 &sharpdefine 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 &sharpdefine GPIOA_BB(b) *((volatile uint32_t *)(BITBAND_PERI(0x40020014,b))) &sharpdefine GPIOB_BB(b) *((volatile uint32_t *)(BITBAND_PERI(0x40020414,b))) &sharpdefine GPIOC_BB(b) *((volatile uint32_t *)(BITBAND_PERI(0x40020814,b))) &sharpdefine 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. #bit-banding-stm32l2011-06-03 06:15 AM
The following seems to be viable on the STM32L platform, with a Keil compiler.
Not sure what you're using, but you could verify the actual addresses of the pointers you are using to confirm they match the correct values. { // STM32L152-EVAL Test volatile unsigned long *odr_a = (volatile unsigned long *)0x40020014; volatile unsigned long *odr_a_bb = (volatile unsigned long *)0x42400280; sprintf(text,''%08X %08X'',*odr_a,GPIOA->ODR); GLCD_DisplayString(0, 0, (unsigned char *)text); odr_a_bb[0] = 1; odr_a_bb[4] = 1; sprintf(text,''%08X %08X'',*odr_a,GPIOA->ODR); GLCD_DisplayString(1, 0, (unsigned char *)text); odr_a_bb[0] = 0; odr_a_bb[8] = 1; sprintf(text,''%08X %08X'',*odr_a,GPIOA->ODR); GLCD_DisplayString(2, 0, (unsigned char *)text); } The output is 00000000 00000000 00000011 00000011 00000110 00000110