Hi everybody!
I´m trying to use the eCAP2 and eCAP3 to measure the phase shift of two squared signals. I read on the SPRUFG4a page 21 that the eCAPs can be syncronized with software by writing a 1 on ECap2.Regs.ECCTL2.bit.SWSYNC. I´ve trying to see any synchocronization on ECap3.Regs.CTRPHS but no value is copied on the register.
below you can find the Configuration of my eCAPs:
ECap2Regs.ECEINT.all = 0; // Disable all eCAP interrupts
ECap2Regs.ECCTL1.bit.CAPLDEN = 0; // Disabled loading of capture results
ECap2Regs.ECCTL2.bit.TSCTRSTOP = 0; // Stop the counter
ECap2Regs.TSCTR = 0; // Clear the counter
ECap2Regs.CTRPHS = 0; // Clear the counter phase register
ECap2Regs.ECCTL2.all = 0x0096; // ECAP control register 2
ECap2Regs.ECCTL1.all = 0x01C4; // ECAP control register 1
ECap2Regs.ECEINT.all = 0x0004; // Enable desired eCAP interrupts
ECap2Regs.ECCTL2.bit.SYNCO_SEL = 0;
ECap2Regs.ECCTL2.bit.SYNCI_EN = 1;
ECap3Regs.ECEINT.all = 0; // Disable all eCAP interrupts
ECap3Regs.ECCTL1.bit.CAPLDEN = 0; // Disabled loading of capture results
ECap3Regs.ECCTL2.bit.TSCTRSTOP = 0; // Stop the counter
ECap3Regs.TSCTR = 0; // Clear the counter
ECap3Regs.CTRPHS = 0; // Clear the counter phase register
ECap3Regs.ECCTL2.all = 0x0096; // ECAP control register 2
ECap3Regs.ECCTL1.all = 0x01C4; // ECAP control register 1
ECap3Regs.ECEINT.all = 0x0004; // Enable desired eCAP interrupts
ECap3Regs.ECCTL2.bit.SYNCO_SEL = 0;
ECap3Regs.ECCTL2.bit.SYNCI_EN = 1;
And here you can find my interrupt service routines:
interrupt void eCAP2_isr(void)
{
ECap2Regs.ECCTL2.bit.SWSYNC = 1;
ECap2Regs.ECCLR.bit.INT = 1; // Clear the ECAP1 interrupt flag
ECap2Regs.ECCLR.bit.CEVT2 = 1; // Clear the CEVT1 flag
PieCtrlRegs.PIEACK.all = PIEACK_GROUP4; // Must acknowledge the PIE group 4
}
interrupt void eCAP3_isr(void)
{
PhaseUI = ECap3Regs.CTRPHS;
ECap3Regs.ECCLR.bit.INT = 1; // Clear the ECAP1 interrupt flag
ECap3Regs.ECCLR.bit.CEVT2 = 1; // Clear the CEVT1 flag
PieCtrlRegs.PIEACK.all = PIEACK_GROUP4; // Must acknowledge the PIE group 4
}