Skip to main content
JTari.1
Associate II
April 29, 2022
Question

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

  • April 29, 2022
  • 3 replies
  • 2077 views

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.

This topic has been closed for replies.

3 replies

Javier1
Principal
April 29, 2022

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

hit me up in https://www.linkedin.com/in/javiermuñoz/
JTari.1
JTari.1Author
Associate II
April 29, 2022

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

waclawek.jan
Super User
April 29, 2022

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