2017-02-20 11:08 AM
hey everyone,
i was using stm32f103 and i was doing a bit-band on gpioa. Now i'm trying on cortex-m4 stm32L432 with no luck. Something changed in L4? Has onyone used bigbanding on gpioa @ stm32l4?
thanks in advance
#bit-band #bit-banding #stm32l4Solved! Go to Solution.
2017-02-20 03:05 PM
Pretty sure the 0x48000000 address space of the GPIOA peripheral is not mappable into the bit banded memory
Which would be the 0x40000000..0x400FFFFF into 0x42000000
2017-02-20 11:26 AM
The programming manual is for F4 and L4 and I've used bitbanding for GPIO on the STM32F437.
Maybe the register location is different?
Recently I refrained to use bitband as it seems deprecated on STM32F7. (portability)
Overall, with the BSSR register on STM32, bit band is less important.
2017-02-20 12:30 PM
Thanks for reply!
Maybe i'm doing something wrong..... wierd. What address you used for gpioa, pin 7?
2017-02-20 12:43 PM
It was few years back... found this piece of code from std library for F4: (my original code is somewhere in my archive...)
♯ include 'stm32f4xx.h'
/** @addtogroup STM32F4xx_StdPeriph_Examples
* @{ *//** @addtogroup CortexM_BitBand
* @{ */♯ define Var_ResetBit_BB(VarAddr, BitNumber) \
(*(__IO uint32_t *) (SRAM_BB_BASE | ((VarAddr - SRAM_BASE) << 5) | ((BitNumber) << 2)) = 0) ♯ define Var_SetBit_BB(VarAddr, BitNumber) \ (*(__IO uint32_t *) (SRAM_BB_BASE | ((VarAddr - SRAM_BASE) << 5) | ((BitNumber) << 2)) = 1)♯ define Var_GetBit_BB(VarAddr, BitNumber) \
(*(__IO uint32_t *) (SRAM_BB_BASE | ((VarAddr - SRAM_BASE) << 5) | ((BitNumber) << 2))) __IO uint32_t Var, VarAddr = 0, VarBitValue = 0;int main(void)
{ /*!< At this stage the microcontroller clock setting is already configured, this is done through SystemInit() function which is called from startup files (startup_stm32f40_41xxx.s/startup_stm32f427_437xx.s/startup_stm32f429_439xx.s) before to branch to application main. To reconfigure the default setting of SystemInit() function, refer to system_stm32f4xx.c file */ Var = 0x00005AA5;/* A mapping formula shows how to reference each word in the alias region to a
corresponding bit in the bit-band region. The mapping formula is: bit_word_addr = bit_band_base + (byte_offset x 32) + (bit_number + 4)where:
- bit_word_addr: is the address of the word in the alias memory region that maps to the targeted bit. - bit_band_base is the starting address of the alias region - byte_offset is the number of the byte in the bit-band region that contains the targeted bit - bit_number is the bit position (0-7) of the targeted bit *//* Get the variable address --------------------------------------------------*/
VarAddr = (uint32_t)&Var;/* Modify variable bit using bit-band access ---------------------------------*/
/* Modify Var variable bit 0 -----------------------------------------------*/ Var_ResetBit_BB(VarAddr, 0); /* Var = 0x00005AA4 */ Var_SetBit_BB(VarAddr, 0); /* Var = 0x00005AA5 */ /* Modify Var variable bit 11 ----------------------------------------------*/ Var_ResetBit_BB(VarAddr, 11); /* Var = 0x000052A5 */ /* Get Var variable bit 11 value */ VarBitValue = Var_GetBit_BB(VarAddr, 11); /* VarBitValue = 0x00000000 */ Var_SetBit_BB(VarAddr, 11); /* Var = 0x00005AA5 */ /* Get Var variable bit 11 value */ VarBitValue = Var_GetBit_BB(VarAddr, 11); /* VarBitValue = 0x00000001 */ /* Modify Var variable bit 31 ----------------------------------------------*/ Var_SetBit_BB(VarAddr, 31); /* Var = 0x80005AA5 */ /* Get Var variable bit 31 value */ VarBitValue = Var_GetBit_BB(VarAddr, 31); /* VarBitValue = 0x00000001 */ Var_ResetBit_BB(VarAddr, 31); /* Var = 0x00005AA5 */ /* Get Var variable bit 31 value */ VarBitValue = Var_GetBit_BB(VarAddr, 31); /* VarBitValue = 0x00000000 */ while (1) { }}2017-02-20 03:05 PM
Pretty sure the 0x48000000 address space of the GPIOA peripheral is not mappable into the bit banded memory
Which would be the 0x40000000..0x400FFFFF into 0x42000000
2017-02-20 03:40 PM
that's sad but probably true..
2017-06-06 08:41 AM
See Programming manual
'STM32F3, STM32F4 and STM32L4 Series Cortex®-M4 programming manual' Table 14. Peripheral memory bit-banding regions.Peripheral bit-band region is restricted to 0x4000 0000-0x400F FFFF whereas GPIOA register boundary addresses are 0x4800 0000 - 0x4800 03FF on STM32L43xxx (see
)2017-06-06 10:29 AM
Please mark my answer as correct....