cancel
Showing results for 
Search instead for 
Did you mean: 

STM32F303R8T6 Bit-Banding Calculation Out of Range

BG1
Senior

Hi , I encountered an interesting problem while I was trying to calculate the Bit-Banding Address of GPIO registers .

The peripherals working on AHB2 and AHB3 busses are overflowing when trying to calculate their bit-banding map .. For Example ;

I wanted to ease the syntax of reading some IO pins and here is the result for GPIOA , IDR register..

--------------------------------------------------------------------------------------

PERIPH_BASE =0x40000000

Address offset of IDR is = 0x10

AHB2PERIPH_BASE=(PERIPH_BASE + 0x08000000)

GPIOA_BASE =(AHB2PERIPH_BASE + 0x00000000)

GPIOA_BASE=0x48000000

---------------------------------------------------------------------------------------

For GPIOA_IDR_Bit0;

GPIOA_IDR_Bit0=0x42000000 + ((GPIOA_BASE +0x10-0x40000000)*0x20);

GPIOA_IDR_Bit0=0x142000200 .... Which is out of 0x42000000 -- 0x43FFFFFF Range !

Is there something I misinterpret ? or This is the reality of bit-banding exception such that doesn't work on some peripherals ... ?? Please tell me the truth .. I can live with that :)

1 ACCEPTED SOLUTION

Accepted Solutions

AHB2 and AHB3 is not within the bit-banded peripheral area, which is 0x40000000-0x400FFFFF. See Bit-banding chapter in PM0214.

JW

View solution in original post

6 REPLIES 6

AHB2 and AHB3 is not within the bit-banded peripheral area, which is 0x40000000-0x400FFFFF. See Bit-banding chapter in PM0214.

JW

BG1
Senior

So I have to go with RMW instructions for bit operations ? No other chance ?

No, but for example GPIO has it's own atomic write register, BSRR.

JW

BG1
Senior

Can you give me an example ?

GPIOA->BSRR = 0x00000001; // Set bit 0 (PA0)

GPIOA->BSRR = 0x00010000; // Clear bit 0

or *((uint32_t *)&GPIOA->BSRR) on platforms where BSRR/BRR are split in the structure definition

*((uint32_t *)&GPIOA->BSRR) = 0x00000001; // Set bit 0 (PA0)

*((uint32_t *)&GPIOA->BSRR) = 0x00010000; // Clear bit 0

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

Thank you so much Clive !