cancel
Showing results for 
Search instead for 
Did you mean: 

Timer based using thread X

massimoperdigo
Associate III

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!

1 ACCEPTED SOLUTION

Accepted Solutions
Saket_Om
ST Employee

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: 

 

 

If your question is answered, please close this topic by clicking "Accept as Solution".

Thanks
Omar

View solution in original post

2 REPLIES 2
Saket_Om
ST Employee

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: 

 

 

If your question is answered, please close this topic by clicking "Accept as Solution".

Thanks
Omar

ah, yes, perfect!!!

 

Thank you so much!