on & off led
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2011-02-10 1:36 PM
on & off led
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2011-05-17 5: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++); }- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2011-05-17 5: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.Up vote any posts that you find helpful, it shows what's working..
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2011-05-17 5:24 AM
Either will do. It's not called the Bit Set Reset Register for nothing! The BSRR allows both operations.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2011-05-17 5: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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2011-05-17 5: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.