Functional Description
1443
SLAU723A – October 2017 – Revised October 2018
Copyright © 2017–2018, Texas Instruments Incorporated
Pulse Width Modulator (PWM)
The PWM generator's mode control, including fault condition handling, is provided in the PWMnCTL
register. This register determines whether the input or a combination of MnFAULTn input signals and/or
digital comparator triggers (as configured by the PWMnFLTSRC0 and PWMnFLTSRC1 registers) is used
to generate a fault condition. The PWMnCTL register also selects whether the fault condition is maintained
as long as the external condition lasts or if it is latched until the fault condition until cleared by software.
Finally, this register also enables a counter that may be used to extend the period of a fault condition for
external events to assure that the duration is a minimum length. The minimum fault period count is
specified in the PWMnMINFLTPER register.
NOTE:
When using an ADC digital comparator as a fault source, the LATCH and MINFLTPER bits
in the PWMnCTL register should be set to 1 to ensure trigger assertions are captured.
Status regarding the specific fault cause is provided in the PWMnFLTSTAT0 and PWMnFLTSTAT1
registers. Note that the fault status registers, PWMnFLTSTAT0 and PWMnFLTSTAT1, reflect the status of
all fault sources, regardless of what fault sources are enabled for that particular generator.
PWM generator fault conditions may be promoted to a controller interrupt using the PWMINTEN register.
21.3.9 Output Control Block
The output control block performs the final conditioning of the pwmA' and pwmB' signals before they are
output on the pins as the MnPWMn signals. Through a single register, the PWM Output Enable
(PWNENABLE) register, the set of PWM signals that are actually enabled to the pins can be modified.
This function can be used, for example, to perform commutation of a brushless DC motor with a single
register write (and without modifying the individual PWM generators, which are modified by the feedback
control loop). In addition, the updating of the bits in the PWMENABLE register can be configured to be
immediate or locally or globally synchronized to the next synchronous update using the PWM Enable
Update (PWMENUPD) register.
During fault conditions, the PWM output signals, MnPWMn, usually must be driven to safe values so that
external equipment may be safely controlled. The PWMFAULT register specifies whether during a fault
condition, the generated signal continues to be passed driven or to an encoding specified in the
PWMFAULTVAL register.
A final inversion can be applied to any of the MnPWMn signals, making them active Low instead of the
default active High using the PWM Output Inversion (PWMINVERT). The inversion is applied even if a
value has been enabled in the PWMFAULT register and specified in the PWMFAULTVAL register. In
other words, if a bit is set in the PWMFAULT, PWMFAULTVAL, and PWMINVERT registers, the output on
the MnPWMn signal is 0, not 1 as specified in the PWMFAULTVAL register.
21.4 Initialization and Configuration
The following example shows how to initialize PWM Generator 0 with a 25-kHz frequency, a 25% duty
cycle on the MnPWM0 pin, and a 75% duty cycle on the MnPWM1 pin. This example assumes the system
clock is 20 MHz.
1. Enable the PWM clock by setting its corresponding bit in the RCGCPWM register in the System
Control module (RCGCPWM) (see
).
2. Enable the clock to the appropriate GPIO module using the RCGCGPIO register in the System Control
module (RCGCGPIO) (see
).
3. Enable the appropriate pins in the GPIO module for their alternate function using the GPIOAFSEL
register. To determine which GPIOs to configure, see the device-specific data sheet.
4. Configure the PMCn fields in the GPIOPCTL register to assign the PWM signals to the appropriate
pins (see
and the device-specific data sheet).
5. Configure the PWM Clock Configuration (PWMCC) register to use the PWM divide (USEPWMDIV) and
set the divider (PWMDIV) to divide by 2 (0x0).
6. Configure the PWM generator for countdown mode with immediate updates to the parameters.
a. Write the PWM0CTL register with a value of 0x0000.0000.
b. Write the PWM0GENA register with a value of 0x0000.008C.