STM32WB15CC TIM2 Interrupt Not Being Called.
- February 25, 2022
- 2 replies
- 1855 views
Hello everyone, I have been working with the stm32wb15cc for a few months and am having a weird issue. I believe I have set up TIM2 and it's interrupts properly and my TIM1 interrupts work but TIM2 interrupts are not being called. TIM2 clk speed is 4Mhz. Any insights would be appreciated!
I noticed nowhere in the the setup function is there a "HAL_NVIC_SetPriority(TIM2_IRQn, 0, 0);" or HAL_NVIC_EnableIRQ(TIM2_IRQn); but maybe HAL does it behind the scenes? It didn't work when I added it anyways lol.
I have set up the TIM2 Timer as follows:
- I have called "HAL_TIM_Base_Start(&htim2);"
- HAL_TIM_PeriodElapsedCallback function works for TIM1 but when I check for htim->Instance to be TIM2 it is never called. (callback image linked)
- I have made sure I enabled TIM2 interrupt in the NVIC. (interrupt image linked)
The setup Code is shown below and in TIM_Setup and TIM_Setup_Code images.
TIM_ClockConfigTypeDef sClockSourceConfig = {0};
TIM_MasterConfigTypeDef sMasterConfig = {0};
htim2.Instance = TIM2;
htim2.Init.Prescaler = 4000;
htim2.Init.CounterMode = TIM_COUNTERMODE_UP;
htim2.Init.Period = 10000;
htim2.Init.ClockDivision = TIM_CLOCKDIVISION_DIV1;
htim2.Init.AutoReloadPreload = TIM_AUTORELOAD_PRELOAD_DISABLE;
if (HAL_TIM_Base_Init(&htim2) != HAL_OK)
Error_Handler();
sClockSourceConfig.ClockSource = TIM_CLOCKSOURCE_INTERNAL;
if (HAL_TIM_ConfigClockSource(&htim2, &sClockSourceConfig) != HAL_OK)
Error_Handler();
sMasterConfig.MasterOutputTrigger = TIM_TRGO_RESET;
sMasterConfig.MasterSlaveMode = TIM_MASTERSLAVEMODE_DISABLE;
if (HAL_TIMEx_MasterConfigSynchronization(&htim2, &sMasterConfig) != HAL_OK)
Error_Handler();
