-
Notifications
You must be signed in to change notification settings - Fork 16
Open
Labels
bugSomething isn't workingSomething isn't workingdocumentationImprovements or additions to documentationImprovements or additions to documentationenhancementNew feature or requestNew feature or request
Milestone
Description
Describe the bug
If control frequency = PWM frequency, current syncAPI does not work, no synch pulse emitted.
In current implementation, the periodic real time task enable the propagation of the PWM repetition event. For that it waits in alternate mode for few microseconds, propagate a repetition event, and then return to GPIO mode to stop other events to be propagated.
As such, the slave only receive one tick per control period.
This approach has multiple flaws.
- Does not work if PWM frequency is close to control frequency
- Rely on busy wait
- Introduce a delay between master task and slave task.
Fix proposal
I propose a new approach to the problem.
- The master would spawn an hardware timer in its
_hrtim_callback() - The timer would count until
control_task_period - 1µsecond - On expire, it would spawn a really short real time interrupt that would set
GPIO alternate mode. - On repetition event, the
_hrtim_callbackwill be triggered, and the pulse will be correctly propagated. - At that moment, we disable further propagation by setting
GPIO normal modeagain. - We re-arm the timer counter.
This fix proposal should IMO address all 3 shortcomings identified in current implementation, at the cost of managing one more hardware timer to deal with synch..
Reactions are currently unavailable
Metadata
Metadata
Labels
bugSomething isn't workingSomething isn't workingdocumentationImprovements or additions to documentationImprovements or additions to documentationenhancementNew feature or requestNew feature or request