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.

F2837xD Delfino Capture Module

Other Parts Discussed in Thread: CONTROLSUITE

I am trying to use the ecap2 pin to capture positive edge transitions generated on a PWM signal. For some reason, the capture interrupt is triggering on both positive and negative edges and I am unable to figure out why. The interrupt should occur on all positive edge transitions using CEVT 1 through 4 events. Here is the code for the ecap2 registers configuration and ISR:

void InitECapture2()

{

ECap2Regs.ECEINT.all = 0x0000; // Disable all capture __interrupts

ECap2Regs.ECCLR.all = 0xFFFF; // Clear all CAP __interrupt flags

ECap2Regs.ECCTL1.bit.CAPLDEN = 0; // Disable CAP1-CAP4 register loads

ECap2Regs.ECCTL2.bit.TSCTRSTOP = 0; // Make sure the counter is stopped

// Configure peripheral registers

// ECAP module 2 config

ECap2Regs.ECCTL1.bit.CAP1POL = 0; // Rising edge

ECap2Regs.ECCTL1.bit.CAP2POL = 0; // Rising edge

ECap2Regs.ECCTL1.bit.CAP3POL = 0; // Rising edge

ECap2Regs.ECCTL1.bit.CAP4POL = 0; // Rising edge

ECap2Regs.ECCTL1.bit.CTRRST1 = 0; // Absolute operation

ECap2Regs.ECCTL1.bit.CTRRST2 = 0; // Absolute operation

ECap2Regs.ECCTL1.bit.CTRRST3 = 0; // Absolute operation

ECap2Regs.ECCTL1.bit.CTRRST4 = 0; // Absolute operation

ECap2Regs.ECCTL1.bit.PRESCALE = 0; // No prescale

ECap2Regs.ECCTL2.bit.CAP_APWM = 0; // Operate in capture mode

ECap2Regs.ECCTL2.bit.CONT_ONESHT = 0; // Operate in continuous mode

ECap2Regs.ECCTL2.bit.SYNCO_SEL = 0; // Disable syncout signal

ECap2Regs.ECCTL2.bit.SYNCI_EN = 0; // Disable sync-in option

ECap2Regs.ECCTL1.bit.CAPLDEN = 0; // Disable CAP1-CAP4 register loads

ECap2Regs.ECEINT.bit.CEVT1 = 1; // __interrupt on every event

ECap2Regs.ECEINT.bit.CEVT2 = 1; // __interrupt on every event

ECap2Regs.ECEINT.bit.CEVT3 = 1; // __interrupt on every event

ECap2Regs.ECEINT.bit.CEVT4 = 1; // __interrupt on every event

ECap2Regs.ECCTL2.bit.TSCTRSTOP = 1; // TSCTR free-running

}

 

__interrupt void ecap2_isr(void) //Scanner Mirror Facet Position Indication ISR

{

// Cap input is syc'ed to SYSCLKOUT so there may be

// a +/- 1 cycle variation

//Note: In Difference operation, Time-stamp directly represents the Period value.

GpioDataRegs.GPBTOGGLE.bit.GPIO60 = 1; //Set hi pin output

ECap2IntCount++;

ECap2Regs.ECCLR.bit.CEVT1 = 1;

ECap2Regs.ECCLR.bit.CEVT2 = 1;

ECap2Regs.ECCLR.bit.CEVT3 = 1;

ECap2Regs.ECCLR.bit.CEVT4 = 1;

ECap2Regs.ECCLR.bit.INT = 1;

// Acknowledge this __interrupt to receive more __interrupts from group 4

PieCtrlRegs.PIEACK.all = PIEACK_GROUP4;

}

  • Hi Moeed,

    First, are you able to get the "ecap_capture_pwm" example to work correctly?
    \controlSUITE\device_support\F2837xD\v180\F2837xD_examples_Cpu1\ecap_capture_pwm\

    This would be a very good step to do - if you have not done this already.

    ===

    For your code:
    1) If you enable eCAP register loads (CAPLDEN) which eCAP register edit over time (CAP1?, CAP1-4?, other?).
    2) I might recommend looking at the eCAP registers in the watch window to double-check that your code is setting things like you expect (perhaps there is some other code, perhaps boilerplate, that are setting some additional register bits.


    Thank you,
    Brett