Skip to main content
Visitor II
November 14, 2024
Question

Timer/Usart priority problem

  • November 14, 2024
  • 2 replies
  • 939 views

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?

    This topic has been closed for replies.

    2 replies

    Visitor II
    November 14, 2024

    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.

    techdeskAuthor
    Visitor II
    November 14, 2024

    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

    techdeskAuthor
    Visitor II
    November 22, 2024

    I set the priorities. That is simple. Running one or two timer channels simultaneously is not a problem.
    But running 6 channels simultaneously, plus two Usarts communication and a I2C port DOES run erratic .Sometimes it works and sometimes it does not well. 
    Anyone have guaranteed system? 

    Graduate II
    November 25, 2024

    @techdesk wrote:

    I set the priorities. That is simple. Running one or two timer channels simultaneously is not a problem.
    But running 6 channels simultaneously, plus two Usarts communication and a I2C port DOES run erratic .Sometimes it works and sometimes it does not well. 
    Anyone have guaranteed system? 


    You haven't shown any code, so no telling how you're buffering the UART communication and parsing?

    What does your string look like?