APRD
TSCTR
FFFFFFFF
ACMP
0000000C
APWMx
(o/p pin)
On
time
Off−time
Period
1000h
500h
300h
Application of the APWM Mode
855
SPRUHE8E – October 2012 – Revised November 2019
Copyright © 2012–2019, Texas Instruments Incorporated
C28 Enhanced Capture (eCAP) Module
8.8
Application of the APWM Mode
In this example, the eCAP module is configured to operate as a PWM generator. Here a very simple
single channel PWM waveform is generated from output pin APWMx. The PWM polarity is active high,
which means that the compare value (CAP2 reg is now a compare register) represents the on-time (high
level) of the period. Alternatively, if the APWMPOL bit is configured for active low, then the compare value
represents the off-time. Note here values are in hexadecimal (“h”) notation.
8.8.1 Example 1 - Simple PWM Generation (Independent Channel/s)
Figure 8-27. PWM Waveform Details of APWM Mode Operation
Example 8-1. Code Snippet for APWM Mode
// Code snippet for APWM mode Example 1
// Initialization Time
//=======================
// ECAP module 1 config ECap1Regs.CAP1 = 0x1000;
// Set period value ECap1Regs.CTRPHS = 0x0;
// make phase zero ECap1Regs.ECCTL2.bit.CAP_APWM = EC_APWM_MODE;
ECap1Regs.ECCTL2.bit.APWMPOL = EC_ACTV_HI;
// Active high ECap1Regs.ECCTL2.bit.SYNCI_EN = EC_DISABLE;
// Synch not used ECap1Regs.ECCTL2.bit.SYNCO_SEL = EC_SYNCO_DIS;
// Synch not used ECap1Regs.ECCTL2.bit.TSCTRSTOP = EC_RUN;
// Allow TSCTR to run
// Run Time (Instant 1, for example, ISR call)
//======================
ECap1Regs.CAP2 = 0x300;