Blinking LED with TIM1(STM32F3DISCOVERY) through registers
I'm working on a project with an STM32F3 MCU and I've been running some test-code on register level, but I have had trouble with the timer and making pin PE8 blink. The result from this code is that it will turn the LED on but it won't toggle the pin so the LED isn't blinking. The following is the code that I'm running on keil uvision:
#include "stm32f303xc.h"
#include "system_stm32f3xx.h"
void CLOCK_config(void);
void GPIO_config(void);
void TIM1_init(void);
void CLOCK_config(void){
//ENABLE HSI CLOCK
RCC->CR |= RCC_CR_HSION;
while(!(RCC->CR & RCC_CR_HSIRDY));
//ENABLE TIM1
RCC->APB2ENR |= RCC_APB2ENR_TIM1EN;
//CONFIGURE CLOCK FOR PORTE
RCC->AHBENR |= RCC_AHBENR_GPIOEEN;
}
void GPIO_config(void){
//SET GPIOE8 AS OUTPUT MODE
GPIOE->MODER |= (1<<0x10U);
//SET GPIOE8 AS MEDIUM SPEED
GPIOE->OSPEEDR |= (1<<0x10U);
}
void TIM1_init(void){
//SET PRESCALER
TIM1->PSC |= 65000;
//SET RELOAD COUNTER VALUE
TIM1->ARR |= 100;
//ENABLE TIMER
TIM1->CR1 |= TIM_CR1_CEN;
}
int main(){
CLOCK_config();
GPIO_config();
TIM1_init();
while(1){
if(TIM1->SR & TIM_SR_UIF){
TIM1->SR &= ~TIM_SR_UIF;
GPIOE->BSRR ^= (1<<0x8U);
}
}
}Is there something that I'm missing, because I thought that I had configured the peripherals correctly, although I'm a bit unsure about how the system clock should be configured? I wanted to keep it simple so I'm hoping for a solution that doesn't involve interrupts or changing the timer to the generic or basic timers.