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.

ECAP6 Interrupt

Other Parts Discussed in Thread: CONTROLSUITE

Hello,

I am trying to use ECAP6 to capture the period and duty cycle of an externally generated PWM. I have assigned the pin (PH1 - GPIO49) to the C28, enabled the interrupts and polarities, and have enabled the clock. I have two problems:

1) interrupts do not generate, and

2) when I pause the debugger, CAP1, CAP2, CAP3, CAP4, and TSCTR all have the same value (which increases between each pause).

Code is copied below:

interrupt void ecap6_isr(void) {
	unsigned long val = ECap6Regs.CAP2;
	ECap6Regs.ECCLR.all = 0xFFFF;
	PieCtrlRegs.PIEACK.all = PIEACK_GROUP4;
	return;
}

void ecap_init() {

	SysCtrlRegs.PCLKCR1.bit.ECAP6ENCLK = 1;

    EALLOW;
    GpioCtrlRegs.GPBQSEL2.bit.GPIO49 = 0;   // Synch to SYSCLKOUT GPIO49 (CAP6)
    GpioCtrlRegs.GPBMUX2.bit.GPIO49 = 1;    // Configure GPIO49 as CAP6
    GpioTripRegs.GPTRIP12SEL.bit.GPTRIP12SEL = 49;   // Configure GPIO49 as CAP6
    EDIS;

    // Register interrupt
    EALLOW;
    PieVectTable.ECAP6_INT = &ecap6_isr;
    EDIS;

    // Initialize capture module
    ECap6Regs.ECEINT.all = 0x0000;            // Disable all capture interrupts
    ECap6Regs.ECCLR.all = 0xFFFF;             // Clear all CAP interrupt flags
    ECap6Regs.ECCTL1.bit.CAPLDEN = 0;         // Disable CAP1-CAP4 register
                                              // loads
    ECap6Regs.ECCTL2.bit.TSCTRSTOP = 0;       // Make sure the counter is
                                              // stopped

    ECap6Regs.ECCTL1.bit.CAP1POL = 0;
    ECap6Regs.ECCTL1.bit.CAP2POL = 1;
    ECap6Regs.ECCTL1.bit.CAP3POL = 0;
    ECap6Regs.ECCTL1.bit.CAP4POL = 1;

    ECap6Regs.ECCTL1.bit.CTRRST1 = 0;
    ECap6Regs.ECCTL1.bit.CTRRST2 = 1;
    ECap6Regs.ECCTL1.bit.CTRRST3 = 0;
    ECap6Regs.ECCTL1.bit.CTRRST4 = 1;

    ECap6Regs.ECCTL1.bit.CAPLDEN = 1;         // Enable capture units
    ECap6Regs.ECCTL1.bit.PRESCALE = 0;
    ECap6Regs.ECCTL2.bit.CAP_APWM = 0;			// Capture mode
    ECap6Regs.ECCTL2.bit.CONT_ONESHT = 0;
    ECap6Regs.ECCTL2.bit.SYNCO_SEL = 2;
    ECap6Regs.ECCTL2.bit.SYNCI_EN = 0;

    ECap6Regs.ECCTL2.bit.TSCTRSTOP = 1;       // Start Counter
    ECap6Regs.ECEINT.bit.CEVT4 = 1;

    // Enable CPU INT4
	IER |= M_INT4;

	// Enable eCAP INTn in the PIE
	PieCtrlRegs.PIEIER4.bit.INTx1 = 1;

	return;
}

I believe the problems may be related, but I have not been able to find the problem. Does anybody have any recommendations?

Thank you

Sam