2011-02-10 01:36 PM
on & off led
2011-05-17 05:24 AM
Hi ajilforoushan.naeem,
I'm a bit confussed how this is supposed to toggle the LED. Assuming LED is on PA0 then shouldn't it be while(1) { GPIOA->BSRR = 1; // LED on for (i=0;i<20000;i++); GPIOA->BRR = 1; // LED off for (i=0;i<20000;i++); }2011-05-17 05:24 AM
Probably want to enable the GPIOA clocks, and configure the GPIO pins first.
Try looking at some of ST's example code in the firmware library.2011-05-17 05:24 AM
Either will do. It's not called the Bit Set Reset Register for nothing! The BSRR allows both operations.
2011-05-17 05:24 AM
I see, thanks. I wonder why the BRR resister is needed if both set and reset can be done using the BSRR register.
2011-05-17 05:24 AM
Hi Trevor,
The BRR and BSRR can be used together to set / reset a bit without having to change the value written to the register. This can save time compared to having to shift the bit up and down 16 places (for the BSRR). Might not mean much if writing in 'C' but can make fast assembler ''bit-bashing'' routines easier to write keeping values in registers.