Dear e2e community
I am quite new with 28377D, and I have a question.
I would like to configure EPWM6 to generate an interrupt every time that TBCTR = ZERO, and increment a counter named "epwm6_int_count " for every time that the interrupt routine is run.
In order to do so, I have configured EPWM6 as follow:
EPwm6Regs.TBCTL.bit.CTRMODE = TB_COUNT_UPDOWN;
EPwm6Regs.TBCTL.bit.PHSEN = TB_DISABLE;
EPwm6Regs.TBCTL.bit.HSPCLKDIV = TB_DIV1;
EPwm6Regs.TBCTL.bit.CLKDIV = TB_DIV1;
EPwm6Regs.ETSEL.bit.INTEN = 1; // 1 enable EPWMx_INT interrupt
EPwm6Regs.ETSEL.bit.INTSEL = 1; // 001 generate interrupt when TBCTR = 0
EPwm6Regs.ETPS.bit.INTPRD = 1; // generate an interrupt in the first event
In the main.c program though I also have other interrupts, the configuration is as follow:
...
...
void main() {
InitSysCtrl();
DINT;
InitPieCtrl();
IER = 0x0000;
IFR = 0x0000;
InitPieVectTable();
InitGpio();
InitCpuTimers(); //*******
//Map ISR functions
EALLOW;
PieVectTable.ADCA1_INT = &adca1_isr; //function for ADCA interrupt 1
PieVectTable.ADCB1_INT = &adcb1_isr; //function for ADCB interrupt 1
PieVectTable.ADCC1_INT = &adcc1_isr; //function for ADCC interrupt 1
PieVectTable.ADCD1_INT = &adcd1_isr; //function for ADCD interrupt 1
PieVectTable.TIMER0_INT = &cpu_timer0_isr; //******* CPU timer #0 generated interrupt
PieVectTable.EPWM6_INT = &epwm6_isr; // function for interrupt based on ePWM6
EDIS;
//Enable global Interrupts and higher priority real-time debug events:
IER |= M_INT1; //Enable group 1 interrupts
EINT;
// Enable Global interrupt INTM
ERTM;
// Enable Global realtime interrupt DBGM
// Enable PIE interrupt (ref Table 2-2. PIE Channel Mapping, pag. 90)
PieCtrlRegs.PIEIER1.bit.INTx1 = 1; // enable adc_int_A_1
PieCtrlRegs.PIEIER1.bit.INTx2 = 1; // enable adc_int_B_1
PieCtrlRegs.PIEIER1.bit.INTx3 = 1; // enable adc_int_C_1
PieCtrlRegs.PIEIER1.bit.INTx6 = 1; // enable adc_int_D_1
PieCtrlRegs.PIEIER1.bit.INTx7 = 1; // Enable TINT0 in the PIE: Group 1 interrupt 7 *******
PieCtrlRegs.PIEIER3.bit.INTx6 = 3; // enable EPWM6 interrupts (row 3:PIEIER3, column 6:INTx6)
...
...
interrupt void epwm6_isr(void){
epwm6_int_count =epwm6_int_count + 1;
PieCtrlRegs.PIEACK.all = PIEACK_GROUP1;
}
To see if the epwm6_isr works I would like the counter "epwm6_int_count" to increment its value every time that the ISR is entered, but as it is this counter is always zero, meaning that epwm6_isr() routine is never entered I guess.
I am not sure of where the mistake is, and also I am not sure of the values I set such: IER = 0x0000; IFR = 0x0000;
Other interrupts are exactly like:
interrupt void adca1_isr(void) {
...
...
AdcaRegs.ADCINTFLGCLR.bit.ADCINT1 = 1; //clear INT1 flag
PieCtrlRegs.PIEACK.all = PIEACK_GROUP1;
}
and they work fine.
Appreciate your help.
Leo