STM32F051R8 TIM14 does not work
Hi,
I'm practicing with the timers of my STM32F0-Disco.
Quite simply, I'm trying to use TIM6 or TIM14 as a simple time base. In order to verify its correct functioning I have put a GPIO call to toggle a LED whenever the interrupt handling function is called.
I used STMCubeMX to generate the code (very simple, since it uses only TIM14 plus two GPIOs, the on-board green and blue LEDs).
The thing that has been driving me crazy for two days is that the TIM14_IRQHandler () interrupt handling function is never called and consequently the LED does not flash.
I have checked and re-checked the generated code several times, also adding the timer activation call, LL_TIM_EnableCounter (TIM14).
The code follows:
static void MX_TIM14_Init(void)
{
/* USER CODE BEGIN TIM14_Init 0 */
/* USER CODE END TIM14_Init 0 */
LL_TIM_InitTypeDef TIM_InitStruct = {0};
/* Peripheral clock enable */
LL_APB1_GRP1_EnableClock(LL_APB1_GRP1_PERIPH_TIM14);
/* TIM14 interrupt Init */
NVIC_SetPriority(TIM14_IRQn, 0);
NVIC_EnableIRQ(TIM14_IRQn);
/* USER CODE BEGIN TIM14_Init 1 */
/* USER CODE END TIM14_Init 1 */
TIM_InitStruct.Prescaler = 47999;
TIM_InitStruct.CounterMode = LL_TIM_COUNTERMODE_UP;
TIM_InitStruct.Autoreload = 499;
TIM_InitStruct.ClockDivision = LL_TIM_CLOCKDIVISION_DIV1;
LL_TIM_Init(TIM14, &TIM_InitStruct);
LL_TIM_EnableARRPreload(TIM14);
/* USER CODE BEGIN TIM14_Init 2 */
/* USER CODE END TIM14_Init 2 */
/* Enable counter */
LL_TIM_EnableCounter(TIM14);
}The previous function is called in my main() bode, before the usual while(1) loop.
In my stm32f0xx_it.c I've written the interrupt handler as follows:
void TIM14_IRQHandler(void)
{
LL_TIM_ClearFlag_UPDATE(TIM14);
LL_GPIO_TogglePin(LD4_GPIO_Port,LD4_Pin);
}With the programmed values for prescaler and autoreload register I would expect an update event every 0.5 seconds, having a system core clock of 48 MHz.
Bute the IRQ handler never gets called (the LED don't flash).
Did I forget something trivial?
Max
