cancel
Showing results for 
Search instead for 
Did you mean: 

[BUG] Wrong timer interrupt handling in HAL for STM32L496

SStor
Senior

Hello,

the following code is generated by CubeMX 6.11.1 in module stm32l4xx_it.c:

/**
  * @brief This function handles TIM1 trigger and commutation interrupts and TIM17 global interrupt.
  */
void TIM1_TRG_COM_TIM17_IRQHandler(void)
{
  /* USER CODE BEGIN TIM1_TRG_COM_TIM17_IRQn 0 */

  /* USER CODE END TIM1_TRG_COM_TIM17_IRQn 0 */
  HAL_TIM_IRQHandler(&htim1);
  HAL_TIM_IRQHandler(&htim17);
  /* USER CODE BEGIN TIM1_TRG_COM_TIM17_IRQn 1 */

  /* USER CODE END TIM1_TRG_COM_TIM17_IRQn 1 */
}

/**
  * @brief This function handles TIM1 capture compare interrupt.
  */
void TIM1_CC_IRQHandler(void)
{
  /* USER CODE BEGIN TIM1_CC_IRQn 0 */

  /* USER CODE END TIM1_CC_IRQn 0 */
  HAL_TIM_IRQHandler(&htim1);
  /* USER CODE BEGIN TIM1_CC_IRQn 1 */

  /* USER CODE END TIM1_CC_IRQn 1 */
}

Interrupts for TIM1 (capture) and TIM17 (global) are both activated, but with different priorities.

The problem is that TIM1_TRG_COM_TIM17_IRQHandler() handles also the capture interrupts from TIM1 with same function HAL_TIM_IRQHandler(&htim1) (called from 2 different interrupt sources).

Therefore the TIM1 capture functions can be called with wrong priority or twice (race condition causes additional interrupt without reason).

 

I think the common HAL timer interrupt handler has to be split in different parts (one for capture processing, one for trigger processing, etc.) and each part should called only once from the right interrupt source (the int handler would also be shorter and faster).

Same problem could also occure on other interrupt handlers with multiple sources or other processor families...

 

1 ACCEPTED SOLUTION

Accepted Solutions
Sarra.S
ST Employee

Hello @SStor,

I appreciate your input, I confirmed this issue, and I created an internal ticket for the responsible team (Ticket 180631), I will keep you updated!  

 

To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.

View solution in original post

1 REPLY 1
Sarra.S
ST Employee

Hello @SStor,

I appreciate your input, I confirmed this issue, and I created an internal ticket for the responsible team (Ticket 180631), I will keep you updated!  

 

To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.