2024-11-14 12:38 AM
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?
2024-11-14 12:53 AM
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.
2024-11-14 01:00 AM
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
2024-11-22 02:08 AM
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?
2024-11-25 01:57 PM
@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?