2023-08-07 08:52 AM
I am working on a project where I need to synchronize a PWM signal generated by an STM32 microcontroller with an external signal. To achieve accurate synchronization, I believe I need to implement a drifting correction algorithm. I am seeking guidance on how to achieve this with the STM32 microcontroller. Can anyone suggest an algorithm or approach to achieve this synchronization and drifting correction effectively?
Anyone have any code examples or code snippets that demonstrate synchronization with an external signal and drifting correction using the STM32 microcontroller? Are there any open-source libraries or resources available that can help me achieve this synchronization?
Thank you for your help and guidance in advance! I appreciate any insights or experiences you can share to assist me in accomplishing this synchronization and drifting correction task with the STM32 microcontroller.
2023-08-07 09:07 AM
Which STM32, they make a handful at this point.
If yours has a 32-bit TIM you could perhaps time-stamp the events from a free running TIM. Say latching the edges of external events, and those of internally wireable connections or associativity, or externally looped. Check the Reference Manual for you part for an understanding of functionality / connectivity options and sources.
2023-08-07 09:25 AM
You could tie the timer reset channel to the external signal and use that to reset the timer. That will keep you aligned.
You could use a free running timer in IC mode to capture the duration between edges and update your timer appropriately.
The best/optimal method will depend on the frequency of the outgoing PWM signal and the incoming sync signal.