void ConfigureUserLED()
{
// GPIOA clock enable
RCC->IOPENR = 1;
GPIOA->MODER &= ~(3 << 10);
GPIOA->MODER |= (1 << 10);
}
int main()
{
// Configure PA5 as output
ConfigureUserLED();
// TIM3 clock enable
RCC->APBENR1 |= (1 << 1);
// Set Prescaler and Auto Reload Register to slow the
// processor down so we can see the LED blink.
// Freq = SYSCLK / ((PSC - 1) * (ARR - 1))
// Freq = 12MHz / ((12000 - 1) * (100 - 1))
// Freq = ~10Hz
TIM3->PSC = 12000;
TIM3->ARR = 100;
// Start the timer
TIM3->CR1 |= 1;
while(1)
{
// Wait for the overflow event to be fired
while(!(TIM3->SR & TIM_SR_UIF)){}
// Reset the Update Interrupt Flag
TIM3->SR &= ~TIM_SR_UIF;
// Toggle the LED
GPIOA->ODR ^= (1 << 5);
}
}