2009-05-10 10:21 PM
“GPIOx_BSRR�, “GPIOx_BRR� registers access?
2011-05-17 04:11 AM
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!2011-05-17 04:11 AM
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 !