Use eCAP to measure differenz from event on 2 GPIO

Hello,

I want to measure the exact time between two rising edges that I expect on GPIO24 and GPIO25. I’m considering using eCAP for this.

  1. A rising edge on GPIO24 should start the eCAP, and a rising edge on GPIO25 should stop it. How can I link the start of eCAP to the rising edge on GPIO24?

  2. eCAP1 is connected to GPIO24 and eCAP2 to GPIO25. The difference between the CV1 values of each eCAP gives the time. How can I ensure that eCAP1 and eCAP2 start at the same time — synchronization, but how?

How can I implement one of these solutions? Or is there a third option to solve this problem?

Unfortunately, this is not something that can be implemented with our regular TSP blocks.

However, if you tell me how you would hand-code such a configuration, I might be able to provide you with a workaround in conjunction with our TSP.

Kind regards, Beat Arnet

Hallo Beat,

For Variant 1, the idea is as follows:
A rising edge on GPIO24 triggers an interrupt, which starts eCap1.

  • eCap1 is connected to GPIO25 and is configured in one-shot mode.
  • After a rising edge occurs on GPIO25, an interrupt is triggered for CV1.
  • The result is stored, and the interrupts for GPIO24 and eCap1.CV1 are released.

For Variant 2, the idea is as follows:
eCap1 and eCap2 are started via SWSYNC at the beginning of the base task.

  • eCap1 is connected to GPIO24 and captures CV1 on a rising edge.
  • eCap2 is connected to GPIO25 and also captures CV1 on a rising edge.
  • Both eCaps are configured in one-shot mode.

At the start of the base task, it is checked whether both eCaps have registered a CV event. The results are stored, and the eCaps are restarted.

Summary:
Variant 1 relies on interrupts.
In Variant 2, the goal is to avoid using interrupts.

King regards, Rainer Gartemann