timer-stm32: correct some init code

clear status register first
and enable the counter
This commit is contained in:
Nico Tonnhofer 2019-04-16 23:43:49 +02:00
parent 6ca071804b
commit 426ffb9420
1 changed files with 2 additions and 3 deletions

View File

@ -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.