Example 3-14. Code Snippet for Configuration in
//===========================================================================
// Config
// Initialization Time
//===========================================================================
EPwm1Regs.TBPRD = 300;
// Period = 300 TBCLK counts // (200 KHz @ 60MHz clock)
EPwm1Regs.TBPHS.half.TBPHS = 0; // Set Phase register to zero
EPwm1Regs.TBCTL.bit.CTRMODE = TB_COUNT_UP; // Asymmetrical mode
EPwm1Regs.TBCTL.bit.PHSEN = TB_DISABLE; // Phase loading disabled
EPwm1Regs.TBCTL.bit.HSPCLKDIV = TB_DIV1; // Clock ratio to SYSCLKOUT
EPwm1Regs.TBCTL.bit.CLKDIV = TB_DIV1;
EPwm1Regs.TBCTL.bit.PRDLD = TB_SHADOW;
Pwm1Regs.AQCTLA.bit.ZRO = AQ_SET; // Set PWM1A on Zero
// Define an event (DCAEVT2) based on
// Comparator 1 Output
EPwm1Regs.DCTRIPSEL.bit.DCAHCOMPSEL = DC_COMP1OUT; // DCAH = Comparator 1 output
EPwm1Regs.TZDCSEL.bit.DCAEVT2 = TZ_DCAH_HI; // DCAEVT2 = DCAH high(will become active
// as Comparator output goes high)
EPwm1Regs.DCACTL.bit.EVT2SRCSEL = DC_EVT2; // DCAEVT2 = DCAEVT2 (not filtered)
EPwm1Regs.DCACTL.bit.EVT2FRCSYNCSEL = DC_EVT_ASYNC; // Take async path // Enable DCAEVT2 as a
// one-shot trip source
// Note: DCxEVT1 events can be defined as
// one-shot.
// DCxEVT2 events can be defined as
// cycle-by-cycle.
EPwm1Regs.TZSEL.bit.DCAEVT2 = 1; // What do we want the DCAEVT1 and DCBEVT1
// events to do?
// DCAEVTx events can force EPWMxA
// DCBEVTx events can force EPWMxB
EPwm1Regs.TZCTL.bit.TZA = TZ_FORCE_LO; // EPWM1A will go low
//===========================================================================
// Run Time
//===========================================================================
// Adjust reference peak current to Comparator 1 negative input
Enhanced Pulse Width Modulator (ePWM) Module
SPRUH18I – JANUARY 2011 – REVISED JUNE 2022
TMS320x2806x Microcontrollers
325
Copyright © 2022 Texas Instruments Incorporated
Summary of Contents for TMS320 2806 Series
Page 2: ......