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.

C2000WARE: Inconsistent ECAP Readout

Part Number: C2000WARE


I am using the ECAP module to read the frequency output of a sensor, but the capture count value is inconsistent with the frequency input after calculating the frequency to discard any out of input range values, which worked with a function generator but not on the actual sensor.

I am currently using only one capture event on the rising edge, although before I was using 2/4 rising and 1/3 falling, and taking the difference between 4 and 2 to find the count. Using multiple events did not help, as all of the counts were inconsistent. I have scoped the input frequency and it is a pretty clean square wave, so I am wondering if I am missing something in my configuration. I am reading the count on a 20kHz EPWM isr instead of a ECAP isr to not intefere with my spi interrupt timing.

Here is my config function:

void configureECAP() {
// Disable ,clear all capture flags and interrupts
//
ECAP_disableInterrupt(ECAP1_BASE,
(ECAP_ISR_SOURCE_CAPTURE_EVENT_1 |
ECAP_ISR_SOURCE_COUNTER_OVERFLOW |
ECAP_ISR_SOURCE_COUNTER_PERIOD |
ECAP_ISR_SOURCE_COUNTER_COMPARE));
ECAP_clearInterrupt(ECAP1_BASE,
(ECAP_ISR_SOURCE_CAPTURE_EVENT_1 |
ECAP_ISR_SOURCE_COUNTER_OVERFLOW |
ECAP_ISR_SOURCE_COUNTER_PERIOD |
ECAP_ISR_SOURCE_COUNTER_COMPARE));
//REMOVED EXTRA EVENTS


//
ECAP_disableTimeStampCapture(ECAP1_BASE);
//
ECAP_stopCounter(ECAP1_BASE);
ECAP_enableCaptureMode(ECAP1_BASE);

ECAP_setCaptureMode(ECAP1_BASE, ECAP_CONTINUOUS_CAPTURE_MODE, ECAP_EVENT_1);

ECAP_setEventPolarity(ECAP1_BASE, ECAP_EVENT_1, ECAP_EVNT_RISING_EDGE);

ECAP_enableCounterResetOnEvent(ECAP1_BASE, ECAP_EVENT_1);

XBAR_setInputPin(XBAR_INPUT7, 29);

ECAP_enableLoadCounter(ECAP1_BASE);
ECAP_setSyncOutMode(ECAP1_BASE, ECAP_SYNC_OUT_DISABLED);
ECAP_startCounter(ECAP1_BASE);
//ECAP_reArm(ECAP1_BASE); //ADDED
ECAP_enableTimeStampCapture(ECAP1_BASE);
}

  • Hi Martin,

    Which device you are using?  What is the version of the C2000Ware SDK?

    There is an example in C2000Ware SDK. Please try the example and check if it measures correctly?

    C:/ti/c2000/C2000Ware_4_01_00_00/driverlib/<DEVICE>/examples/ecap/CCS/ecap_ex2_capture_pwm.projectspec

    Thanks & Regards,

    Santosh