cancel
Showing results for 
Search instead for 
Did you mean: 

Timer instance not working in FreeRTOS context

Refused_HC
Associate II

Hello all, I explain you my problem the best I can.

 

I have a project with the MCU STM32U575RGT6 The project has TouchGFX and FreeRTOS. After the initializations of the peripherals, I have the next calls, so the while(1) in main.c is not executed. As you can see in the next image.

Refused_HC_0-1770275394376.png

So for the moment the only main loop I have detected in the application is the timer interruption.

Refused_HC_1-1770275568170.png

In CubeMX I have 3 timers defined: TIM17, which is been assigned to the system as the timebase source:

Refused_HC_2-1770275664648.png

And timers 2 and 4 with the same exact parameters in CubeMX: (timer3 is related to an encoder....)

Refused_HC_3-1770275746935.png

 

Refused_HC_4-1770275763311.png

Refused_HC_5-1770275872540.png

I initialize the corresponding interruptions.

Refused_HC_6-1770275954325.png

The problem is that in the interruption HAL_TIM_PeriodElapsedCallback I never get the call of the timer 4 instance.

Refused_HC_7-1770276131730.png

Any help will be welcome.

3 REPLIES 3
Gyessine
ST Employee

Hello @Refused_HC 
Can you check please Timer4 registers (TIM4_CR1,TIM4_ARR,TIM4_PSC,TIM4_CNT),are they getting initialized and working like they should be?
Additionally, monitor the related pin to determine whether the timer generates a signal if possible.
BR
Gyessine

To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.

ferro
Lead

Hi @Refused_HC 

In you main(), before anything else, try to call __set_BASEPRI(0)

int main(void)
{

  /* USER CODE BEGIN 1 */
  
  __set_BASEPRI(0);

  /* USER CODE END 1 */

 

see this discussion

https://community.st.com/t5/stm32-mcus-embedded-software/stm32f4-tim6-initialization/m-p/888102

 

ferro
Lead

Hi @Refused_HC 

please ignore my previous reply, I got confused. 

>>"After the initializations of the peripherals, I have the next calls, so the while(1) in main.c is not executed"

This is correct behaviour as RTOS is running its scheduler/idle task thread. Not sure now. okKernelStart() does not return.

 

How can you have HAL_IncTick() called from TIM4 IRQ when you assigned TIM17 as the HAL tick base timer ?

And your TIM4 is RTOS aware. Does not make sense.