This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

Can an eCAP be used to simultaneously capture absolute and relative timestamps?

Other Parts Discussed in Thread: TMS320F28377S

I am using a TMS320F28377S Launchpad to run some code that is looking at a 75% (or so) duty cycle pulse train. I am using an eCAP to look at this because it really gets rid of a lot of overhead.

That being said, I want to run an algorithm that needs the following:

1) The absolute timestamp of the "most recent" rising edge of the pulse train

2) The relative period between the "two most recent" rising edges of the pulse train

Right now, I have been doing this by enabling the ECap1Regs.CAP1 and ECap1Regs.CAP2 registers and reading the Overflow bit (ECap1Regs.ECFLG.bit.CTROVF). In the nominal case where there is no overflow, I just compare CAP1 and CAP2 and find the "greatest" counter value (which would be the most recent) and store that, then I calculate the difference between CAP1 and CAP2 and store that. If there is an overflow, I basically just do the same thing (accounting for overflow). I think this line of logic is about 100 clock cycles (with inefficient code), which isn't bad considering how much power is in the 28377S, but I would like to know whether I can make things more efficient.

I know that the eCAP can be configured to be in "delta" mode where it gives you the period between the last two capture events, and I know that it can be configured to have absolute timestamp.

Is there a way that I can configure an eCAP so that I can read registers and get the absolute timestamp of the "most recent" rising edge of a pulse train, and also get the period between the last two? I am effectively doing this right now, but it would be nice to do this without have to do any "if-then" logic in software.

Thanks for the help.

  • Hi Daniel,

    I believe the best way to do this would be to configure eCAP to operate in Delta mode. In Delta mode the eCAP counter gets reset at every capture event. You can get the relative period between two capture events by simply reading the capture register # 2 (assuming there are two events to be captured). You can get the absolute time-stamp by continuously summing up the captured values. There is no risk of counter overflow unless two closest events can come in at a period greater than the 32-bit counter capabilities of eCAP (including all the clock prescaling).

    I hope this helps.

    Hrishi