This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

ePWM 50Hz output

Hi,

I configured ePWM3 to generate a 50Hz output (50% duty), but the result measured is not exactly 50, it is 50.49Hz, is there anyone give me some advices? Thanks a lot!

Felix

 

unsigned int EPWM3_TIMER_TBPRD = 37500;     // Period register - 50Hz, up-down count mode @ 60 MHz/16

void InitEPwm3Example()
{

   EPwm3Regs.TBPRD = EPWM3_TIMER_TBPRD;             // Set timer period
   EPwm3Regs.TBPHS.half.TBPHS = 0x0000;             // Phase is 0
   EPwm3Regs.TBCTR = 0x0000;                        // Clear counter
  
  
   // Setup TBCLK
   EPwm3Regs.TBCTL.bit.CTRMODE = TB_COUNT_UPDOWN;  // Count up-down
   EPwm3Regs.TBCTL.bit.PHSEN = TB_DISABLE;         // Disable phase loading
   EPwm3Regs.TBCTL.bit.HSPCLKDIV = TB_DIV4;        // Clock ratio to SYSCLKOUT
   EPwm3Regs.TBCTL.bit.CLKDIV = TB_DIV4;           // Slow so we can observe on the scope

   // Setup compare
   EPwm3Regs.CMPA.half.CMPA = EPWM3_TIMER_TBPRD/2;

   // Set actions
   EPwm3Regs.AQCTLA.bit.CAU = AQ_SET;               // Set PWM3A on Zero
   EPwm3Regs.AQCTLA.bit.CAD = AQ_CLEAR;
  

   EPwm3Regs.AQCTLB.bit.CAU = AQ_CLEAR;             // Set PWM3A on Zero
   EPwm3Regs.AQCTLB.bit.CAD = AQ_SET;

   // Active high complementary PWMs - Setup the deadband
   EPwm3Regs.DBCTL.bit.OUT_MODE = DB_FULL_ENABLE;
   EPwm3Regs.DBCTL.bit.POLSEL = DB_ACTV_HIC;
   EPwm3Regs.DBCTL.bit.IN_MODE = DBA_ALL;
   EPwm3Regs.DBRED = EPWM3_MIN_DB;
   EPwm3Regs.DBFED = EPWM3_MIN_DB;
   EPwm3_DB_Direction = DB_UP;
  
   // Interrupt where we will change the deadband
   EPwm3Regs.ETSEL.bit.INTSEL = ET_CTR_ZERO;        // Select INT on Zero event
   EPwm3Regs.ETSEL.bit.INTEN = 0;                   // Enable INT
   EPwm3Regs.ETPS.bit.INTPRD = ET_1ST;              // Generate INT on 3rd event    
}