Other Parts Discussed in Thread: TMS320F28377D, TEST2
Hi everyone,
AQCTLA [ZRO] event is not executed when "0" is loaded to TBCTR.
Is this behavior correct?
// Included Files
//
#include "F28x_Project.h"
//
// Defines
//
#define EPWM1_MAX_DB 0x03FF
#define EPWM2_MAX_DB 0x03FF
#define EPWM3_MAX_DB 0x03FF
#define EPWM1_MIN_DB 0
#define EPWM2_MIN_DB 0
#define EPWM3_MIN_DB 0
#define DB_UP 1
#define DB_DOWN 0
//
// Globals
//
Uint32 EPwm2TimerIntCount;
Uint16 EPwm2_DB_Direction;
//
// Function Prototypes
//
void InitEPwm2Example(void);
__interrupt void epwm2_isr(void);
//
// Main
//
void main(void)
{
InitSysCtrl();
CpuSysRegs.PCLKCR2.bit.EPWM2=1;
InitEPwm2Gpio();
DINT;
InitPieCtrl();
IER = 0x0000;
IFR = 0x0000;
InitPieVectTable();
EALLOW; // This is needed to write to EALLOW protected registers
PieVectTable.EPWM2_INT = &epwm2_isr;
EDIS; // This is needed to disable write to EALLOW protected registers
EALLOW;
CpuSysRegs.PCLKCR0.bit.TBCLKSYNC =0;
EDIS;
InitEPwm2Example();
EALLOW;
CpuSysRegs.PCLKCR0.bit.TBCLKSYNC =1;
EDIS;
EPwm2TimerIntCount = 0;
IER |= M_INT3;
PieCtrlRegs.PIEIER3.bit.INTx2 = 1;
EINT; // Enable Global interrupt INTM
ERTM; // Enable Global realtime interrupt DBGM
for(;;)
{
asm (" NOP");
}
}
//
// epwm2_isr - EPWM2 ISR
//
__interrupt void epwm2_isr(void)
{
EPwm2TimerIntCount++;
EPwm2Regs.TBCTR = 0;
//
// Clear INT flag for this timer
//
EPwm2Regs.ETCLR.bit.INT = 1;
//
// Acknowledge this interrupt to receive more interrupts from group 3
//
PieCtrlRegs.PIEACK.all = PIEACK_GROUP3;
}
//
// InitEPwm2Example - Initialize EPWM2 configuration
//
void InitEPwm2Example()
{
EPwm2Regs.TBPRD = 6000; // Set timer period
EPwm2Regs.TBPHS.bit.TBPHS = 0x0000; // Phase is 0
EPwm2Regs.TBCTR = 0x0000; // Clear counter
//
// Setup TBCLK
//
EPwm2Regs.TBCTL.bit.CTRMODE = TB_COUNT_UP; // Count up
EPwm2Regs.TBCTL.bit.PHSEN = TB_DISABLE; // Disable phase loading
EPwm2Regs.TBCTL.bit.HSPCLKDIV = TB_DIV4; // Clock ratio to SYSCLKOUT
EPwm2Regs.TBCTL.bit.CLKDIV = TB_DIV4; // Slow just to observe on
// the scope
//
// Setup compare
//
EPwm2Regs.CMPA.bit.CMPA = 3000;
// EPwm2Regs.CMPB.all = 4500;
//
// Set actions
//
EPwm2Regs.AQCTLA.bit.ZRO = AQ_CLEAR; // Set PWM2A on Zero
EPwm2Regs.AQCTLA.bit.CAU = AQ_SET;
//
// Interrupt where we will modify the deadband
//
EPwm2Regs.ETSEL.bit.INTSEL = ET_CTRU_CMPA; // Select INT on Zero event
EPwm2Regs.ETSEL.bit.INTEN = 1; // Enable INT
EPwm2Regs.ETPS.bit.INTPRD = ET_3RD; // Generate INT on 3rd event
}
//
// End of file
//
I checked with the above source code.
AQCTLA [ZRO] event was not executed when TBCTR = 0 in the interrupt function.
Please let me know if there is a method to execute AQCTLA [ZRO] event when TBCTR = 0.
Best regards,
Sasaki

