15 #include "stm32l4xx_hal.h"
16 #include "stm32l4xx_hal_tim.h"
35 HAL_StatusTypeDef result;
36 RCC_ClkInitTypeDef rccClockConfig = {0U};
37 uint32_t clockFrequency = 0U;
38 uint32_t clockPrescaler = 0U;
39 uint32_t flashLatency;
42 uwTickPrio = TickPriority;
45 HAL_NVIC_SetPriority(TIM1_TRG_COM_TIM17_IRQn, TickPriority, 0U);
48 HAL_NVIC_EnableIRQ(TIM1_TRG_COM_TIM17_IRQn);
51 __HAL_RCC_TIM17_CLK_ENABLE();
54 HAL_RCC_GetClockConfig(&rccClockConfig, &flashLatency);
55 clockFrequency = HAL_RCC_GetPCLK2Freq();
56 clockPrescaler = (uint32_t)((clockFrequency / 1000000U) - 1U);
60 htim17.Init.CounterMode = TIM_COUNTERMODE_UP;
61 htim17.Init.ClockDivision = 0U;
62 htim17.Init.Period = (1000000U / 1000U) - 1U;
63 htim17.Init.Prescaler = clockPrescaler;
65 result = HAL_TIM_Base_Init(&
htim17);
69 result = HAL_TIM_Base_Start_IT(&
htim17);
83 __HAL_TIM_DISABLE_IT(&
htim17, TIM_IT_UPDATE);
94 __HAL_TIM_ENABLE_IT(&
htim17, TIM_IT_UPDATE);