cancel
Showing results for 
Search instead for 
Did you mean: 

“GPIOx_BSRR�, “GPIOx_BRR� registers access?

armmcu
Associate II
Posted on May 11, 2009 at 07:21

“GPIOx_BSRR�, “GPIOx_BRR� registers access?

2 REPLIES 2
armmcu
Associate II
Posted on May 17, 2011 at 13:11

Hi moderator, all

As it is stated in ST reference manual

The “Atomic bit set or reset� is performed through “GPIOx_BSRR�, “GPIOx_BRR� registers.

My question is:

Is it possible to perform an I/O bit toggling when programming only one register at one time?

I mean for example to toggle bit six, do like this

while(1){

GPIOx->BSRR = 0x400040;

}

I did the test but it didn’t work !!!

Is it due to the fact that GPIOx register have to be accessed as 32-bit words ?

Thanks in advance for your help amigos!

rael
Associate II
Posted on May 17, 2011 at 13:11

I think if you set a 1 in the upper 16 bits, in your BSRR Port position, and a 0 in the lower 16 bits or the BSRR, same port position, and then xor with a 32 bit value that has ones in both positions. That way, you can effectively swap the one from the upper to the lower 16 bits, or the lower to the upper, with each xor operation.

I'm teaching myself C, so don't assume my code is correct... something like this ?

GPIOx->BSRR = 0x000040

while(1){

GPIOx->BSRR = GPIOx->BSRR ^ 0x400040;

}

Hope you have a good scope !