Other Parts Discussed in Thread: C2000WARE,
I use the eCap Function of 28379D to capture the rising edge of an GPIO's pulse, as you can see in the figure below, CH4 is the pulse of the GPIO to trigger the eCap, and CH3 is the signal sent out by eCap interrupt_isr when the DSP capture the rising edge. so why it has such a larger time delay? the system clock is set to 200MHz.
void Ecap_Init(void)
{
EALLOW;
InputXbarRegs.INPUT7SELECT = 21; // Set eCAP1 source to GPIO-pin
EDIS;
GPIO_SetupPinOptions(21, GPIO_INPUT, GPIO_ASYNC);
ECap1Regs.ECEINT.all = 0x0000; // Disable all capture __interrupts
ECap1Regs.ECCLR.all = 0xFFFF; // Clear all CAP __interrupt flags
ECap1Regs.ECCTL1.bit.CAPLDEN = 0; // Disable CAP1-CAP4 register loads
ECap1Regs.ECCTL2.bit.TSCTRSTOP = 0; // Make sure the counter is stopped
// Configure peripheral registers
ECap1Regs.ECCTL2.bit.CONT_ONESHT = 1; // One-shot
ECap1Regs.ECCTL2.bit.STOP_WRAP = 0;//3; // Stop at 4 events
ECap1Regs.ECCTL1.bit.CAP1POL = 0; // Falling edge
ECap1Regs.ECCTL1.bit.CAP2POL = 0; // Rising edge
ECap1Regs.ECCTL1.bit.CAP3POL = 0; // Falling edge
ECap1Regs.ECCTL1.bit.CAP4POL = 0; // Rising edge
ECap1Regs.ECCTL1.bit.CTRRST1 = 1; // Difference operation
ECap1Regs.ECCTL1.bit.CTRRST2 = 1; // Difference operation
ECap1Regs.ECCTL1.bit.CTRRST3 = 1; // Difference operation
ECap1Regs.ECCTL1.bit.CTRRST4 = 1; // Difference operation
ECap1Regs.ECCTL2.bit.SYNCI_EN = 0; // Enable sync in
ECap1Regs.ECCTL2.bit.SYNCO_SEL = 0; // Pass through
ECap1Regs.ECCTL1.bit.CAPLDEN = 1; // Enable capture units
ECap1Regs.ECCTL2.bit.TSCTRSTOP = 1; // Start Counter
ECap1Regs.ECCTL2.bit.REARM = 1; // arm one-shot
ECap1Regs.ECCTL1.bit.CAPLDEN = 1; // Enable CAP1-CAP4 register loads
ECap1Regs.ECEINT.bit.CEVT1 = 1; // 1 events = __interrupt
// ECap1Regs.ECEINT.bit.CEVT4 = 1; // 4 events = __interrupt
}/* Ecap_Init() */
interrupt void ecap1_isr(void)
{
EALLOW;
GpioDataRegs.GPASET.bit.GPIO12 = 1;
EDIS;
ECap1Regs.ECCLR.bit.CEVT1 = 1;
ECap1Regs.ECCLR.bit.INT = 1;
ECap1Regs.ECCTL2.bit.REARM = 1;
// Acknowledge this __interrupt to receive more __interrupts from group 4
PieCtrlRegs.PIEACK.all = PIEACK_GROUP4;
GpioDataRegs.GPACLEAR.bit.GPIO12 = 1;
}