2021-04-26 06:36 AM
I have multiple devices with stm32L5 mcu playing led animations and connected via RS-485. However, when I send a command via RS-485 to start led animations, they become asynchronous. I want to use an mcu clock as reference and send it to all others mcu via RS-485 then calibrate it based on the first one's clock, but don't know how to measure clock ticks and configure it. I don't know where to start.
Any suggestions or thoughts are welcomed.
2021-04-26 06:52 AM
Nothing is perfect. No matter how accurately you calibrate your clocks, they will drift apart. If at all possible, have one device send out periodic "frame" messages, and have the others resynchronise to those messages. You will need to think how to synchronise the ones that receive the frame messages; you don't want them to freeze waiting for a message, and also have to cope with them running more slowly than the reference.
As to how often those messages have to be, it depends how rapidly the clocks drift apart, and how far drifting is acceptable.
Internal oscillators e.g. HSI drift much worse than crystal-controlled oscillators e.g. HSE or LSE
Hope this helps,
Danish
2021-04-26 07:00 AM
Thanks for your answer Danish.
I'm using RTOS with mutilple Tasks, One task that is blocked most of time unless it's time to update led frames and other task that should be used to receive or send clock ticks. I just want the delay to become unnoticed. Is there any Hal function that give clocks ticks and some other hal function to callibrate or configure the mcu clock ?
Zed