Skip to content

[SYNC] Sync communication does not work when PWM freq is not way higher than control frequency #134

@jalinei

Description

@jalinei

Describe the bug
If control frequency = PWM frequency, current syncAPI does not work, no synch pulse emitted.

Current synchronization mechanism

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

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_callback will 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..

Metadata

Metadata

Labels

bugSomething isn't workingdocumentationImprovements or additions to documentationenhancementNew feature or request

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions