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++); }
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.