Hi
There has been a bit written on this, but I am having a hard job understanding why I am seeing a 350nsec delay from when the PWM output goes low to before I can execute something in the isr generated by the epwm1 module. I have read that there are 14 cycles needed for an internal interrupt i.e., 175nsec at a 80MHz clock.
Here is my code which makes use of Biricha Digital Power API's. All it is doing is producing PWM and toggling GPIO18 high in the isr. It is running on a 28069 control stick. The bold text of the isr disassembly is the GPIO toggle that produces a 25nsec wide high pulse that I use for calculating the latency, but what is all the rest and is it avoidable to reduce the interrupt latency? All timing was made using a scope and I was using the CCS4 debugger to load the code to RAM ( I am not absolutely sure - could Flash wait states really double the delay?).
Thanks to those who might be able to shed some light.
#include "csl.h"
uint32_t freq;
uint16_t ticks;
interrupt void isr_pwm1( void )
{
GpioDataRegs.GPADAT.all = 0x00040000;
GpioDataRegs.GPADAT.all = 0x00000000;
PWM_ackInt(PWM_MOD_1); // clears the ePWM and PIE group flags
}
void main( void )
{
/* Initialize the MCU */
SYS_init();
freq = 116000;
ticks = PWM_freqToTicks(freq);
/* Setup PWM */
PWM_config( PWM_MOD_1, ticks, PWM_COUNT_DOWN );
PWM_setDeadBandHalfBridge( PWM_MOD_1, 10, HALF_BRIDGE_PN );
PWM_setDutyA(PWM_MOD_1, ticks/2);
PWM_setDutyB(PWM_MOD_1, ticks/2);
PWM_setCallback( PWM_MOD_1, isr_pwm1,PWM_INT_ZERO, PWM_INT_PRD_1 );
INT_enableGlobal(true);
GPIO_config( GPIO_18, GPIO_DIR_OUT, false);
while(1)
{
}
}
if I disassemble the isr it gives:
isr_pwm1:
0x3D8546: 761B ASP
0x3D8547: FFF0 PUSH RB
0x3D8548: A8BD MOVL *SP++, XAR4
0x3D8549: E20000BD MOV32 *SP++, STF
0x3D854B: E6300600 SETFLG RNDF32=1,RNDF64=1
0x3D854D: 2942 CLRC OVM|PAGE0
0x3D854E: 5616 CLRC AMODE
0x3D854F: 761F01BF MOVW DP, #0x1bf
0x3D8551: 8F040000 MOVL XAR4, #0x040000
0x3D8553: A800 MOVL @0x0, XAR4
0x3D8554: 0200 MOVB ACC, #0
0x3D8555: 1E00 MOVL @0x0, ACC
0x3D8556: 761F01A0 MOVW DP, #0x1a0
0x3D8558: 56BF011C MOVB @0x1c, #0x01, UNC
0x3D855A: 761F0033 MOVW DP, #0x33
0x3D855C: 56BF0421 MOVB @0x21, #0x04, UNC
0x3D855E: E28000BE MOV32 STF, *--SP
0x3D8560: 8ABE MOVL XAR4, *--SP
0x3D8561: FFF1 POP RB
0x3D8562: 7617 NASP
0x3D8563: 7602 IRET