Hi,
I'm using ePWM1 (TMSF28027) as an compare unit. It will give me interrupt on CMPA and I will then load a new value. The problem is that even if the resolution of the ePWM unit should be 533ns (60Mhz / (32*1) = 1.875MHz = 533ns) but it seems to be 90us. Can somebody explain me what I'm doing wrong? I toggle one pin in the interrupt and it seems to have this 180us jitter. It doesn't jitter all the time but once in a while +/- 90us. I also use interrupt prioritization but this one has the highest priority.
Initialization:
EPwm1Regs.TBCTL.all = 0;
EPwm1Regs.TBCTL.bit.CTRMODE = TB_FREEZE; // Disable the timer
EPwm1Regs.TBCTL.bit.FREE_SOFT = 1;
EPwm1Regs.TBCTL.bit.CLKDIV = TB_DIV32; // 0x05
EPwm1Regs.TBCTL.bit.HSPCLKDIV = TB_DIV1; // 0x00
EPwm1Regs.TBCTR = 0; // Clear timer counter
EPwm1Regs.TBCTL.bit.PRDLD = TB_IMMEDIATE; //
EPwm1Regs.TBCTL.bit.SYNCOSEL = TB_CTR_ZERO;
EPwm1Regs.TBPRD = 0xFFFF ;
EPwm1Regs.CMPA.half.CMPA = NextCompareEvent; //
EPwm1Regs.CMPCTL.bit.SHDWAMODE = CC_IMMEDIATE; // Load immediately
EPwm1Regs.AQCTLA.all = 0;
EPwm1Regs.DBCTL.bit.OUT_MODE = DB_DISABLE; // Disable Dead-band module
EPwm1Regs.ETSEL.all = 0;
EPwm1Regs.ETSEL.bit.INTEN = 1; // Enable EPWMx_INT generation
EPwm1Regs.ETSEL.bit.INTSEL = 4; // Enable event time-base counter equal to CMPA when the timer is incrementing.
EPwm1Regs.ETPS.bit.INTCNT = 1; // ePWM Interrupt Event: 1 event has occurred.
EPwm1Regs.ETPS.bit.INTPRD = 1; // ePWM Interrupt: Generate an interrupt on the first event INTCNT = 01 (first event)
EALLOW;
EPwm1Regs.TZSEL.all = 0; // Trip-Zone Submodule disabled
// Enable ePWM1 in PIE
PieCtrlRegs.PIEIER3.bit.INTx1 = 1; // Enable INT 3.1 in the PIE
IER |= M_INT3; // Enable CPU Interrupt 3
EDIS;
Update to register in interrupt:
NextCompareEvent += FixedTime; // FixedTime = 18750 = 10ms
/* Load next compare time to compare register */
EPwm1Regs.CMPA.half.CMPA = NextCompareEvent;