Blinking LED
Hi all,
Just started with bare metal programming of stm32f411re.
Uploaded the following code to blink the onboard led of the nucleo board.
Code:
#include "stm32f4xx.h" // Device header
void delayMs(int delay);
int main (void)
{
RCC->AHB1ENR |= 1;
GPIOA->MODER |= 0x400;
while(1)
{
GPIOA->ODR = 0x20;
delayMs(100);
GPIOA->ODR &= ~0x20;
delayMs(100);
}
}
void delayMs(int delay)
{ int i ;
for(; delay>0; delay--)
{
for(i=0; i<4000; i++);
}
}
The above code had my led lit but it was very dim. While running the debugger, I found out that my code skips the delay function call.
So, I tried including a for loop as a delay directly in the while loop instead of having a separate function, but still it bypasses the statement and executes the next.
What change should be done here to get the code working?
Thanks in advance.