cancel
Showing results for 
Search instead for 
Did you mean: 

another bit band question

John Doe1
Associate III
Posted on February 20, 2017 at 20:08

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 #stm32l4
1 ACCEPTED SOLUTION

Accepted Solutions
Posted on February 20, 2017 at 23:05

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

Tips, buy me a coffee, or three.. PayPal Venmo Up vote any posts that you find helpful, it shows what's working..

View solution in original post

7 REPLIES 7
S.Ma
Principal
Posted on February 20, 2017 at 20:26

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.

Posted on February 20, 2017 at 20:30

Thanks for reply!

Maybe i'm doing something wrong..... wierd. What address you used for gpioa, pin 7?

Posted on February 20, 2017 at 20:43

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)

{

}

}
Posted on February 20, 2017 at 23:05

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

Tips, buy me a coffee, or three.. PayPal Venmo Up vote any posts that you find helpful, it shows what's working..
Posted on February 20, 2017 at 23:40

that's sad but probably true..

Posted on June 06, 2017 at 15:41

See Programming manual

http://www.st.com/content/ccc/resource/technical/document/programming_manual/6c/3a/cb/e7/e4/ea/44/9b/DM00046982.pdf/files/DM00046982.pdf/jcr:content/translations/en.DM00046982.pdf

'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

http://www.st.com/content/ccc/resource/technical/document/reference_manual/group0/b0/ac/3e/8f/6d/21/47/af/DM00151940/files/DM00151940.pdf/jcr:content/translations/en.DM00151940.pdf

)
In order to give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.
Posted on June 06, 2017 at 17:29

Please mark my answer as correct....

Tips, buy me a coffee, or three.. PayPal Venmo Up vote any posts that you find helpful, it shows what's working..