I am running the 28335 processor for a motor control application. The clock is set to 150 MHz. I have 3 hall sensors feeding into the ECAPs. I have measured the speed with a tach and the counts from rising edge to rising edge on Hall1 is not matching up to the expected value. The state is being checked in a 100Khz polling loop (PRD function using DSP BIOS). My assumption is that each count equates to 1 clock tick of the 150 MHz clock. Has anyone seen this or is there something wrong with my assumption or implementation? Below is the initialization code.
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
ECap1Regs.ECCTL1.bit.CAPLDEN = 1; // Enable CAP1-CAP4 register loads
ECap1Regs.ECCTL1.bit.CAP1POL = 0;
ECap1Regs.ECCTL1.bit.CTRRST1 = 1;
ECap1Regs.ECCTL2.bit.TSCTRSTOP = 1; // Start Counter
This is my logic in the polling loop:
if (ECap1Regs.ECFLG.bit.CEVT1 != 0)
{
timeStamp = ECap1Regs.CAP1;
ECap1Regs.ECCLR.bit.CEVT1 = 1;
}