Hi,
I met problem about the ePWM interrupt,
--1. if I comment "EPwm1Regs.CMPA.half.CMPA = sinewave(); ", the LED blinks when interrupt occurs;
--2. if I uncomment "EPwm1Regs.CMPA.half.CMPA = sinewave(); ", the LED doesn't blink anymore
--3. after 2, I comment it again, the LED still does not blink => Interrupt does not occure; but the PWM still output.
--4. to let the interrupt get right again, I must reset the MCU.
could anyone pls help me on this? how can I use the function sinewave(); successfully?
Note: CPU run at 60MHz; sinewave(); is provided together with a developer's kit; PWM 110kHz;
void InitEPwm1Example()
{
EPwm1Regs.TBPRD = 273; // PWM 110kHz
EPwm1Regs.TBPHS.half.TBPHS = 0x0000; // Phase is 0
EPwm1Regs.TBCTR = 0x0000; // Clear counter
// Setup TBCLK
EPwm1Regs.TBCTL.bit.CTRMODE = TB_COUNT_UPDOWN; // Count up
EPwm1Regs.TBCTL.bit.PHSEN = TB_DISABLE; // Disable phase loading
EPwm1Regs.TBCTL.bit.HSPCLKDIV = TB_DIV1; // Clock ratio to SYSCLKOUT
EPwm1Regs.TBCTL.bit.CLKDIV = TB_DIV1; // Slow so we can observe on the scope
// Setup compare
EPwm1Regs.CMPA.half.CMPA = 100;
// Set actions
EPwm1Regs.AQCTLA.bit.CAU = AQ_SET; // Set PWM1A on Zero
EPwm1Regs.AQCTLA.bit.CAD = AQ_CLEAR;
EPwm1Regs.AQCTLB.bit.CAU = AQ_CLEAR; // Set PWM1A on Zero
EPwm1Regs.AQCTLB.bit.CAD = AQ_SET;
// Active high complementary PWMs - Setup the deadband
EPwm1Regs.DBCTL.bit.OUT_MODE = DB_FULL_ENABLE;
EPwm1Regs.DBCTL.bit.POLSEL = DB_ACTV_HIC;
EPwm1Regs.DBCTL.bit.IN_MODE = DBA_ALL;
EPwm1Regs.DBRED = EPWM1_MIN_DB;
EPwm1Regs.DBFED = EPWM1_MIN_DB;
EPwm1_DB_Direction = DB_UP;
// Interrupt where we will change the deadband
EPwm1Regs.ETSEL.bit.INTSEL = ET_CTR_ZERO; // Select INT on Zero event
EPwm1Regs.ETSEL.bit.INTEN = 1; // Enable INT
EPwm1Regs.ETPS.bit.INTPRD = ET_3RD; // Generate INT on 3rd event
}
interrupt void epwm1_isr(void)
{
GpioDataRegs.GPBTOGGLE.bit.GPIO34 = 1; // To drive a LED
//EPwm1Regs.CMPA.half.CMPA = sinewave();
//----------------------------------------------
// Clear INT flag for this timer
EPwm1Regs.ETCLR.bit.INT = 1;
// Acknowledge this interrupt to receive more interrupts from group 3
PieCtrlRegs.PIEACK.all = PIEACK_GROUP3;
}