cancel
Showing results for 
Search instead for 
Did you mean: 

Timer/Usart priority problem

techdesk
Associate III

While testing the Blackpill Timers and Usarts I came across this problem. If I set for example 6 timer channels using two timers. (In my case Tim2 and Tim3 and Usart1. 
If I set all six channels to PWM generation, I find it difficult to dynamically reset or change the timer variables.
Although the Usart1 is set to interrupt enabled, sending a string (then being converted to an integer)
Eg: __HAL_TIM_SET_COMPARE(&htim3, TIM_CHANNEL_1, M1)  (in this case M1 is the converted variable that I send via serial. The behavior is erratic. Sometimes the timer accepts the the variable and sometimes nothing happens.
Someone suggested DMA etc. But nothing works. Even though the Usart1 is set priority over the timers, the behavior is still erratic. Especially using Serial radio modules like the Loras etc which has baudrates of 9600.
It is crucial to be able to dynamically change the timer variables, especially in UAV applications.
Any answers or assistance here?

2 REPLIES 2
liaifat85
Senior III

USART1 interrupt should have a  higher priority than TIM2 and TIM3 interrupts.In STM32, lower numerical values indicate higher priority. Configure this using HAL_NVIC_SetPriority.

That is what I did precisely. Like I said I am still experiencing the problem when I run ALL 6 channels of the two timers