Skip to main content
Associate III
Mar 3, 2025 4:32 PM UTC
Solved

Timer based using thread X

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!

This topic has been closed for replies.
Saket_OmBest answer
ST Technical Moderator
Mar 4, 2025 1:59 PM UTC

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

2 replies

Saket_OmBest answer
ST Technical Moderator
Mar 4, 2025 1:59 PM UTC

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
Mar 5, 2025 3:26 PM UTC

ah, yes, perfect!!!

 

Thank you so much!