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.

eCAP correct capture

I am using the eCAP module on the TMS320F2837xS.

Testing it against my PWM TBPRD value I am getting 1 time-stamp counter less in my CAP1-4 registers than expected.

The PWM is using up-down-count mode. eCap events set to rising edges - (If I do rising and falling I get 2 less than expected)  I have tried various prescalers and they all result in 1 time-stamp counter lower than expected.

Is this behavior normal - is there any documentation I can link to?

  • Hi David,

    What are the PWM setting (Set/Clr events etc.)? Are you measuring the actual pulse width on scope and does it match with expected from PWM?
    There can be some variation in the eCAP captured values due to the asynchronous nature of the inputs, but this doesn't seem to be the case here.

    -Bharathi.
  • The width measured on a scope varies slightly.  But the values in eCAP registers are 1 less than I expecte

    Rising and falling edge = PWM_PERIOD -1

    Rising edge = (PWM_PERIOD * 2) - 1

    ePWM1->TBPRD = PWM_PERIOD;
    ePWM1->TBCTR = 0x0000u;
    ePWM1->TBCTL.bit.CTRMODE = TB_COUNT_UPDOWN;
    ePWM1->CMPA.bit.CMPA = 0u;
    ePWM1->AQCTLA.bit.CAU = 2;
    ePWM1->AQCTLA.bit.CAD = 1;
    ePWM1->TBCTL.bit.CLKDIV = 0;
    ePWM1->TBCTL.bit.HSPCLKDIV = 0;
    ePWM1->DBCTL.bit.IN_MODE = 0u;
    ePWM1->DBCTL.bit.POLSEL = 2;

    ePWM1->DBRED = DEADBAND;

    ePWM1->DBFED = DEADBAND;

    ePWM1->DBCTL.bit.OUT_MODE = DB_FULL_ENABLE;

  • Hi David,

    With the configuration you mentioned above, I expect PWM to stay high, since the compare value is Zero.
    ePWM1->CMPA.bit.CMPA = 0u;
    ePWM1->AQCTLA.bit.CAU = 2;
    ePWM1->AQCTLA.bit.CAD = 1;
    Are you changing the compare value later on?

    Also, are you measuring ECAP values captured over multiple PWM periods?
    Do you read the same values all the time?

    -Bharathi.
  • I do change the CMPA value - this does not affect values in rising edge only captures.

    I am measuring over multiple PWM periods and the capture in CAP1-4 is always:

    Rising edge = (PWM_PERIOD * 2) - 1

  • I am still looking for confirmation on the documentation here. Refer to the Time Difference (Delta) Operation Rising Edge Trigger example of the Technical reference manual.  Would this apply the way I am thinking and the results I am seeing?

    "In Delta-time mode, TSCTR is Reset back to Zero on every valid event. Here Capture events are qualified as Rising edge only. On an event, TSCTR contents (Time-Stamp) is captured first, and then TSCTR is reset to Zero."

    The TSCTR contents (Time-Stamp) is captured first and then reset to zero. (I.E. the TSCTR contents (Time-Stamp) is captured before incrementing.)

    This would make sense and apply to both my rising edge and rising/falling eCAP modes I was using.