Skip to main content
Associate III
March 3, 2025
Solved

Timer based using thread X

  • March 3, 2025
  • 1 reply
  • 1078 views

Hi!!

I am using ThreadX to develop a project.

As far as I know, when using FreeRTOS, it is highly recommended to switch from SysTick to another timer.

Is it the same for ThreadX?

Therefore, I am using TIM7, which is a simple timer. I was wondering where I can find the TIM7 base function that is called every tick. I want to include a function there, but I cannot find it.

 

Thanks!

Best answer by Saket_Om

Hello @massimoperdigo 

Yes, it is recommended to switch from SysTick to another timer when using ThreadX, similar to FreeRTOS. This is because the SysTick is exclusively reserved for ThreadX, and you need to use another time base for the HAL, such as TIM6 or TIM7.


Therefore, I am using TIM7, which is a simple timer. I was wondering where I can find the TIM7 base function that is called every tick. I want to include a function there, but I cannot find it.


The function should be like the snippet code below: 

void TIM7_IRQHandler(void)
{
 // Call the HAL TIM IRQ handler
 HAL_TIM_IRQHandler(&htim7);
}

void HAL_TIM_PeriodElapsedCallback(TIM_HandleTypeDef *htim)
{
 /* USER CODE BEGIN Callback 0 */

 /* USER CODE END Callback 0 */
 if (htim->Instance == TIM7) {
 HAL_IncTick();
 }
 /* USER CODE BEGIN Callback 1 */

 /* USER CODE END Callback 1 */
}

Please refer to the example Projects/NUCLEO-H723ZG/Applications/ThreadX/Tx_Thread_Creation for more details: 

 

 

1 reply

Saket_OmBest answer
Technical Moderator
March 4, 2025

Hello @massimoperdigo 

Yes, it is recommended to switch from SysTick to another timer when using ThreadX, similar to FreeRTOS. This is because the SysTick is exclusively reserved for ThreadX, and you need to use another time base for the HAL, such as TIM6 or TIM7.


Therefore, I am using TIM7, which is a simple timer. I was wondering where I can find the TIM7 base function that is called every tick. I want to include a function there, but I cannot find it.


The function should be like the snippet code below: 

void TIM7_IRQHandler(void)
{
 // Call the HAL TIM IRQ handler
 HAL_TIM_IRQHandler(&htim7);
}

void HAL_TIM_PeriodElapsedCallback(TIM_HandleTypeDef *htim)
{
 /* USER CODE BEGIN Callback 0 */

 /* USER CODE END Callback 0 */
 if (htim->Instance == TIM7) {
 HAL_IncTick();
 }
 /* USER CODE BEGIN Callback 1 */

 /* USER CODE END Callback 1 */
}

Please refer to the example Projects/NUCLEO-H723ZG/Applications/ThreadX/Tx_Thread_Creation for more details: 

 

 

"In order to give better visibility on the answered topics, please click on 'Best answer' on the reply which solved your issue or answered your question.Saket_Om"
Associate III
March 5, 2025

ah, yes, perfect!!!

 

Thank you so much!