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.

TMS320F28027: ECAP Capture Example Cannot Capture Correct Period

Part Number: TMS320F28027
Other Parts Discussed in Thread: C2000WARE

Hi team,

I did a little experiment based on Example_2802xECap_Capture_Pwm in C2000Ware.

I connected GPIO4&5 with a extern wire. And I did not change other configurations.

In the ECAP isr, I added a breakpoint to  read the cap result: 

time1 = ECap1Regs.CAP1;
time2 = ECap1Regs.CAP2;
time3 = ECap1Regs.CAP3;
time4 = ECap1Regs.CAP4;
ECap1PassCount++;

According to my knowledge, I should be able to get 4 same values in time 1-4 as shown in the following figure:


However, there is high possibility that I see the result that time1=3*time2.


 

Could you please help to explain why? Is this caused by the breakpoint?

  • Variation in CAP1 isn't unexpected--that's why the ISR doesn't check it for correctness like the other CAP registers.

    There are a couple factors that cause this. One thing is that the CAP4 event resets the ECAP counter and triggers an ISR. The ECAP counter will continue to run without being reset until the CAP1 edge has been detected. However, since we're running in one-shot mode, the ECAP won't be looking for the CAP1 edge until after the REARM happens at the end of the ISR, so all the counts that happened between CAP4 and the REARM count toward CAP1.

    You can also imagine a scenario where that REARM just misses the falling edge, meaning there will be nearly 1 period's worth of counts captured as part of CAP1 in addition to the aforementioned counts.

    Whitney