Hello,
I based this part of the code from the Example_2833xEPwmTimerInt sample project. I am using EPwm1 to generate a 10MHz clock signal and also I used the code from the sample project to generate an interrupt.
I have added an instruction to toggle a pin which I am monitoring on an oscilloscope.
interrupt void epwm_timer_isr(void)
{
EPwmTimerIntCount++;
// 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;
GpioDataRegs.GPBTOGGLE.bit.GPIO32 = 1;
}
I see that the pin is toggling every ~2uS. Given that the cycle time for this chip is 6.67nS, I was expecting the interrupt to trigger at a much faster frequency. I was wondering if there was something in my configuration that is causing it go trigger at this speed? I am reading through the various documentation but have not found the culprit.
void InitEPwm(void)
{
//---------------------------------------------------------------------
//--- Must disable the clock to the ePWM modules if you
//--- want all ePWM modules synchronized.
//---------------------------------------------------------------------
EALLOW; // Enable EALLOW protected register access
SysCtrlRegs.PCLKCR0.bit.TBCLKSYNC = 0;
EDIS; // Disable EALLOW protected register access
//---------------------------------------------------------------------
//--- Configure ePWM1 for 10MHz symmetric PWM on EPWM1A pin
//---------------------------------------------------------------------
EPwm1Regs.TBCTL.bit.SYNCOSEL = TB_SYNC_IN; // Pass through
EPwm1Regs.TBCTL.bit.PHSEN = TB_ENABLE;
EPwm1Regs.TBCTL.bit.CTRMODE = 0x3; // Disable the timer
EPwm1Regs.TBCTL.all = 0xC033; // Configure timer control register
EPwm1Regs.TBCTR = 0x0000; // Clear timer counter
EPwm1Regs.TBPRD = PWM_HALF_PERIOD; // Set timer period (value = 7)
EPwm1Regs.TBPHS.half.TBPHS = 100; // Set timer phase
EPwm1Regs.CMPA.half.CMPA = PWM_DUTY_CYCLE; // Set PWM duty cycle (value = 4)
EPwm1Regs.CMPCTL.all = 0x0002; // Compare control register
EPwm1Regs.AQCTLA.all = 0x0060; // Action-qualifier control register A
EPwm1Regs.AQSFRC.all = 0x0000; // Action-qualifier s/w force register
EPwm1Regs.AQCSFRC.all = 0x0000; // Action-qualifier continuous s/w force register
EPwm1Regs.DBCTL.bit.OUT_MODE = 0; // Deadband disabled
EPwm1Regs.PCCTL.bit.CHPEN = 0; // PWM chopper unit disabled
EPwm1Regs.TZCTL.bit.TZA = 0x3; // Trip action disabled for output A
EPwm1Regs.TBCTL.bit.CTRMODE = 0x2; // Enable the timer in count up/down mode
//EPwm1Regs.TBPRD = PWM1_TIMER_TBPRD;
//EPwm1Regs.TBCTL.bit.CTRMODE = TB_COUNT_UP; // Count up
EPwm1Regs.ETSEL.bit.INTSEL = ET_CTR_ZERO; // Select INT on Zero event
EPwm1Regs.ETSEL.bit.INTEN = PWM1_INT_ENABLE; // Enable INT
EPwm1Regs.ETPS.bit.INTPRD = ET_1ST; // Generate INT on 1st event
//---------------------------------------------------------------------
//--- Enable the clocks to the ePWM module.
//--- Note: this should be done after all ePWM modules are configured
//--- to ensure synchronization between the ePWM modules.
//---------------------------------------------------------------------
asm(" EALLOW"); // Enable EALLOW protected register access
SysCtrlRegs.PCLKCR0.bit.TBCLKSYNC = 1; // HSPCLK to ePWM modules enabled
asm(" EDIS"); // Disable EALLOW protected register access
} // end InitEPwms()
Thanks in advance,
-Alex