cancel
Showing results for 
Search instead for 
Did you mean: 

Timer 6 ISR utilizing 56-60% CPU (Threadx +STM32H7)

JTari.1
Associate II

I am using stm32h7 with threadx where TIM6 is time timebase for HAL and systick is used by threadX. The project is generated using the standard cubeMX configuration. I am using tracelyzer to visualize my CPU utilization, and i found out that TIM6 ISR is taking almost 60 % of the CPU, which to me makes no sense as it takes few us to execute and has a period of 1ms.

The remaining system (ISRs and Tasks) consume only 11% of the CPU. Am i doing somthing wrong because i cannot do proper RMA of my system.

3 REPLIES 3
Javier1
Principal

Show us the ISR code, maybe threadx is doing something inside that ISR?

Available for consulting/freelancing , hit me up in https://github.com/javiBajoCero
JTari.1
Associate II

thanks Javier for reply.Here is my ISR code:

void TIM6_DAC_IRQHandler(void)

{

/* USER CODE BEGIN TIM6_DAC_IRQn 0 */

vTraceStoreISRBegin(TimerHandle6);

/* USER CODE END TIM6_DAC_IRQn 0 */

HAL_TIM_IRQHandler(&htim6);

/* USER CODE BEGIN TIM6_DAC_IRQn 1 */

vTraceStoreISREnd(TimerHandle6);

/* USER CODE END TIM6_DAC_IRQn 1 */

}

Where vTraceStoreISRBegin and vTraceStoreISREnd are tracning functions. and the callback is:

void HAL_TIM_PeriodElapsedCallback(TIM_HandleTypeDef *htim) {

  if (htim->Instance == TIM6) {

    HAL_IncTick();

  }

}

Nothing sophisticated

If you know that the ISR period is 1ms and duration a few us (and both of these you can easily verify by toggling an output pin at beginning and end of ISR and observing on oscilloscope/LA), then the mechanism through which you are told the CPU utilization is faulty.

JW