diff --git a/timer-stm32.c b/timer-stm32.c index 675c39c..0f1cc27 100644 --- a/timer-stm32.c +++ b/timer-stm32.c @@ -74,9 +74,8 @@ void timer_init() { */ RCC->APB1ENR |= RCC_APB1ENR_TIM5EN; // Turn on TIM5 power. - TIM5->CCR1 = 0xFFFFFFFF; // First timer should not occur at 0 - TIM5->CR1 &= ~(0x03FF); // clear register - TIM5->CR1 |= TIM_CR1_CEN; // Enable counter. + TIM5->SR = 0; // clear status register + TIM5->CR1 = TIM_CR1_CEN; // Enable counter. NVIC_SetPriority(TIM5_IRQn, NVIC_EncodePriority(NVIC_GetPriorityGrouping(), 0, 0)); // Also highest priority.