TMS320x2802x, 2803x Piccolo High Resolution
Pulse Width Modulator (HRPWM)
Reference Guide
Literature Number: SPRUGE8D
February 2009–Revised October 2009
2 SPRUGE8D–February 2009–Revised October 2009
Submit Documentation Feedback
Copyright © 2009, Texas Instruments Incorporated
Preface ....................................................................................................................................... 6
1 Introduction ........................................................................................................................ 9
2 Operational Description of HRPWM ..................................................................................... 11
2.1 Controlling the HRPWM Capabilities ................................................................................ 12
2.2 Configuring the HRPWM .............................................................................................. 14
2.3 Principle of Operation ................................................................................................. 15
2.4 Scale Factor Optimizing Software (SFO) ........................................................................... 24
2.5 HRPWM Examples Using Optimized Assembly Code. ........................................................... 25
3 HRPWM Register Descriptions ............................................................................................ 31
3.1 Register Summary ..................................................................................................... 31
3.2 Registers and Field Descriptions .................................................................................... 32
Appendix A SFO Library Software - SFO_TI_Build_V6.lib ............................................................... 37
A.1 Scale Factor Optimizer Function - int SFO() ...................................................................... 37
A.2 Software Usage ....................................................................................................... 38
A.3 SFO Library Version Software Differences ........................................................................ 39
Appendix B Revision History ...................................................................................................... 41
3SPRUGE8D–February 2009–Revised October 2009 Table of Contents
Submit Documentation Feedback
Copyright © 2009, Texas Instruments Incorporated
www.ti.com
List of Figures
1 Resolution Calculations for Conventionally Generated PWM......................................................... 9
2 Operating Logic Using MEP ............................................................................................. 11
3 HRPWM Extension Registers and Memory Configuration ........................................................... 12
4 HRPWM System Interface ............................................................................................... 13
5 HRPWM Block Diagram .................................................................................................. 14
6 Required PWM Waveform for a Requested Duty = 40.5% .......................................................... 16
7 Low % Duty Cycle Range Limitation Example (HRPCTL[HRPE] = 0) ............................................. 19
8 High % Duty Cycle Range Limitation Example (HRPCTL[HRPE] = 0) ............................................ 21
9 Up-Count Duty Cycle Range Limitation Example (HRPCTL[HRPE]=1)............................................ 21
10 Up-Down Count Duty Cycle Range Limitation Example (HRPCTL[HRPE]=1) .................................... 22
11 Simple Buck Controlled Converter Using a Single PWM ............................................................ 26
12 PWM Waveform Generated for Simple Buck Controlled Converter ................................................ 26
13 Simple Reconstruction Filter for a PWM Based DAC ................................................................ 28
14 PWM Waveform Generated for the PWM DAC Function ............................................................ 28
15 HRPWM Configuration Register (HRCNFG)........................................................................... 32
16 Counter Compare A High Resolution Register (CMPAHR).......................................................... 33
17 TB Phase High Resolution Register (TBPHSHR)..................................................................... 33
18 Time Base Period High Resolution Register........................................................................... 33
19 Compare A High Resolution Mirror Register........................................................................... 34
20 Time-Base Period High Resolution Mirror Register................................................................... 34
21 High Resolution Period Control Register (HRPCTL) ................................................................. 35
22 High Resolution Micro Step Register (HRMSTEP) (EALLOW protected):......................................... 35
23 High Resolution Power Register (HRPWR) (EALLOW protected) .................................................. 36
4 List of Figures SPRUGE8D–February 2009–Revised October 2009
Submit Documentation Feedback
Copyright © 2009, Texas Instruments Incorporated
www.ti.com
List of Tables
1 Resolution for PWM and HRPWM ...................................................................................... 10
2 HRPWM Registers ........................................................................................................ 11
3 Relationship Between MEP Steps, PWM Frequency and Resolution .............................................. 15
4 CMPA vs Duty (left), and [CMPA:CMPAHR] vs Duty (right)......................................................... 17
5 Duty Cycle Range Limitation for 3 SYSCLK/TBCLK Cycles......................................................... 20
6 Register Descriptions ..................................................................................................... 31
7 HRPWM Configuration Register (HRCNFG) Field Descriptions .................................................... 32
8 Counter Compare A High Resolution Register (CMPAHR) Field Descriptions ................................... 33
9 TB Phase High Resolution Register (TBPHSHR) Field Descriptions .............................................. 33
10 Time Base Period High-Resolution Register (TBPRDHR) Field Descriptions..................................... 33
11 Compare A High-Resolution Mirror Register (CMPAHRM) Field Descriptions.................................... 34
12 Time-Base Period High-Resolution Mirror Register (TBPRDHRM) Field Descriptions .......................... 34
13 High Resolution Period Control Register (HRPCTL) Field Descriptions ........................................... 35
14 High Resolution Micro Step Register (HRMSTEP) Field Descriptions ............................................. 35
15 High Resolution Power Register (HRPWR) Field Descriptions ..................................................... 36
16 SFO Library Features ..................................................................................................... 37
17 Factor Values .............................................................................................................. 38
18 Revisions ................................................................................................................... 41
5SPRUGE8D–February 2009–Revised October 2009 List of Tables
Submit Documentation Feedback
Copyright © 2009, Texas Instruments Incorporated
Preface
SPRUGE8D–February 2009–Revised October 2009
Read This First
About This Manual
This document describes the operation of the high-resolution extension to the pulse width modulator
(HRPWM) on the TMS320x2802x, 2803x Piccolo™ devices. The HRPWM module described in this
reference guide is a Type 1 HRPWM. See the TMS320x28xx, 28xxx DSP Peripheral Reference Guide
(SPRU566) for a list of all devices with an HRPWM module of the same type, to determine the differences
between types, and for a list of device-specific differences within a type.
Notational Conventions
This document uses the following conventions.
• Hexadecimal numbers are shown with the suffix h. For example, the following number is 40
hexadecimal (decimal 64): 40h.
• Registers in this document are shown in figures and described in tables.
– Each register figure shows a rectangle divided into fields that represent the fields of the register.
Each field is labeled with its bit name, its beginning and ending bit numbers above, and its
read/write properties below. A legend explains the notation used for the properties.
– Reserved bits in a register figure designate a bit that is used for future device expansion.
Related Documentation From Texas Instruments
The following documents describe the C2000™ devices and related support tools. Copies of these
documents are available on the Internet at www.ti.com. Tip: Enter the literature number in the search box
provided at www.ti.com.
The current documentation that describes the devices, related peripherals, and other technical collateral,
is available in the C2000 product folder at: www.ti.com/c2000.
Data Manuals—
SPRS523 — TMS320F28020, TMS320F28021, TMS320F28022, TMS320F28023, TMS320F28026,
TMS320F28027 Piccolo Microcontrollers Data Manual contains the pinout, signal descriptions,
as well as electrical and timing specifications for the 2802x devices.
SPRZ292 — TMS320F28020, TMS320F28021, TMS320F28022, TMS320F28023, TMS320F28026,
TMS320F28027 Piccolo MCU Silicon Errata describes known advisories on silicon and provides
workarounds.
SPRS584 — TMS320F28032, TMS320F28033, TMS320F28034, TMS320F28035 Piccolo
Microcontrollers Data Manual contains the pinout, signal descriptions, as well as electrical and
timing specifications for the 2803x devices.
SPRZ295 — TMS320F28032, TMS320F28033, TMS320F28034, TMS320F28035 Piccolo MCU Silicon
Errata describes known advisories on silicon and provides workarounds.
CPU User's Guides—
SPRU430 — TMS320C28x CPU and Instruction Set Reference Guide describes the central processing
unit (CPU) and the assembly language instructions of the TMS320C28x fixed-point digital signal
processors (DSPs). It also describes emulation features available on these DSPs.
Peripheral Guides—
6 Preface SPRUGE8D–February 2009–Revised October 2009
Submit Documentation Feedback
Copyright © 2009, Texas Instruments Incorporated
www.ti.com Related Documentation From Texas Instruments
SPRUFN3 — TMS320x2802x Piccolo System Control and Interrupts Reference Guide describes the
various interrupts and system control features of the 2802x microcontrollers (MCUs).
SPRUGL8 — TMS320x2803x Piccolo System Control and Interrupts Reference Guide describes the
various interrupts and system control features of the 2803x microcontrollers (MCUs).
SPRU566 — TMS320x28xx, 28xxx DSP Peripheral Reference Guide describes the peripheral
reference guides of the 28x digital signal processors (DSPs).
SPRUGO0 — TMS320x2803x Piccolo Boot ROM Reference Guide describes the purpose and features
of the bootloader (factory-programmed boot-loading software) and provides examples of code. It
also describes other contents of the device on-chip boot ROM and identifies where all of the
information is located within that memory.
SPRUFN6 — TMS320x2802x Piccolo Boot ROM Reference Guide describes the purpose and features
of the bootloader (factory-programmed boot-loading software) and provides examples of code. It
also describes other contents of the device on-chip boot ROM and identifies where all of the
information is located within that memory.
SPRUGE6 — TMS320x2803x Piccolo Control Law Accelerator (CLA) Reference Guide describes the
operation of the Control Law Accelerator (CLA).
SPRUGE2 — TMS320x2803x Piccolo Local Interconnect Network (LIN) Module Reference Guide
describes the operation of the Local Interconnect Network (LIN) Module.
SPRUFK8 — TMS320x2803x Piccolo Enhanced Quadrature Encoder Pulse (eQEP) Reference Guide
describes the operation of the Enhanced Quadrature Encoder Pulse (eQEP) module, which is used
for interfacing with a linear or rotary incremental encoder to get position, direction, and speed
information from a rotating machine in high performance motion and position control systems. It
includes the module description on registers.
SPRUGL7 — TMS320x2803x Piccolo Enhanced Controller Area Network (eCAN) Reference Guide
describes the operation of the Enhanced Controller Area Network (eCAN) which uses established
protocol to communicate serially with other controllers in electrically noisy environments.
SPRUGE5 — TMS320x2802x, 2803x Piccolo Analog-to-Digital Converter (ADC) and Comparator
Reference Guide describes how to configure and use the on-chip ADC module, which is a 12-bit
pipelined ADC.
SPRUGE9 — TMS320x2802x, 2803x Piccolo Enhanced Pulse Width Modulator (ePWM) Module
Reference Guide describes the main areas of the enhanced pulse width modulator that include
digital motor control, switch mode power supply control, UPS (uninterruptible power supplies), and
other forms of power conversion.
SPRUGE8 — TMS320x2802x, 2803x Piccolo High-Resolution Pulse Width Modulator (HRPWM)
describes the operation of the high-resolution extension to the pulse width modulator (HRPWM).
SPRUGH1 — TMS320x2802x, 2803x Piccolo Serial Communications Interface (SCI) Reference
Guide describes how to use the SCI.
SPRUFZ8 — TMS320x2802x, 2803x Piccolo Enhanced Capture (eCAP) Module Reference Guide
describes the enhanced capture module. It includes the module description and registers.
SPRUG71 — TMS320x2802x, 2803x Piccolo Serial Peripheral Interface (SPI) Reference Guide
describes the SPI - a high-speed synchronous serial input/output (I/O) port - that allows a serial bit
stream of programmed length (one to sixteen bits) to be shifted into and out of the device at a
programmed bit-transfer rate.
SPRUFZ9 — TMS320x2802x, 2803x Piccolo Inter-Integrated Circuit (I2C) Reference Guide describes
the features and operation of the inter-integrated circuit (I2C) module.
Tools Guides—
7SPRUGE8D–February 2009–Revised October 2009 Read This First
Submit Documentation Feedback
Copyright © 2009, Texas Instruments Incorporated
Related Documentation From Texas Instruments www.ti.com
SPRU513 — TMS320C28x Assembly Language Tools v5.0.0 User's Guide describes the assembly
language tools (assembler and other tools used to develop assembly language code), assembler
directives, macros, common object file format, and symbolic debugging directives for the
TMS320C28x device.
SPRU514 — TMS320C28x Optimizing C/C++ Compiler v5.0.0 User's Guide describes the
TMS320C28x™ C/C++ compiler. This compiler accepts ANSI standard C/C++ source code and
produces TMS320 DSP assembly language source code for the TMS320C28x device.
SPRU608 — TMS320C28x Instruction Set Simulator Technical Overview describes the simulator,
available within the Code Composer Studio for TMS320C2000 IDE, that simulates the instruction
set of the C28x™ core.
Piccolo, C2000, TMS320C28x, C28x are trademarks of Texas Instruments.
8 Read This First SPRUGE8D–February 2009–Revised October 2009
Submit Documentation Feedback
Copyright © 2009, Texas Instruments Incorporated
PWM
t
TPWM
TSYSCLK
PWMresolution(%)=F /F x100%PWM SYSCLKOUT
PWMresolution(bits)=Log (T /T )2 PWM SYSCLKOUT
Reference Guide
SPRUGE8D–February 2009–Revised October 2009
High-Resolution Pulse Width Modulator (HRPWM)
This document is used in conjunction with the device-specific Enhanced Pulse Width Modulator (ePWM)
Module Reference Guide.
The HRPWM module extends the time resolution capabilities of the conventionally derived digital pulse
width modulator (PWM). HRPWM is typically used when PWM resolution falls below ~ 9-10 bits. The key
features of HRPWM are:
• Extended time resolution capability
• Used in both duty cycle and phase-shift control methods
• Finer time granularity control or edge positioning using extensions to the Compare A and Phase
registers
• Implemented using the A signal path of PWM, i.e., on the EPWMxA output. EPWMxB output has
conventional PWM capabilities
• Self-check diagnostics software mode to check if the micro edge positioner (MEP) logic is running
optimally
• Enables high resolution output on B signal path of PWM via PWM channel path swapping and
inversion.
• Enables high-resolution period control on the ePWMxA output on devices with a type 1 ePWM module.
See the device-specific data manual to determine if your device has a type 1 ePWM module for
high-resolution period support. The ePWMxB output is inoperable in this mode.
1 Introduction
The ePWM peripheral is used to perform a function that is mathematically equivalent to a digital-to-analog
converter (DAC). As shown in Figure 1, the effective resolution for conventionally generated PWM is a
function of PWM frequency (or period) and system clock frequency.
Figure 1. Resolution Calculations for Conventionally Generated PWM
If the required PWM operating frequency does not offer sufficient resolution in PWM mode, you may want
to consider HRPWM. As an example of improved performance offered by HRPWM, Table 1 shows
resolution in bits for various PWM frequencies. These values assume a MEP step size of 180 ps. See the
device-specific datasheet for typical and maximum performance specifications for the MEP.
9SPRUGE8D–February 2009–Revised October 2009 High-Resolution Pulse Width Modulator (HRPWM)
Submit Documentation Feedback
Copyright © 2009, Texas Instruments Incorporated
Introduction www.ti.com
Table 1. Resolution for PWM and HRPWM
PWM Freq Regular Resolution (PWM) High Resolution (HRPWM)
60 MHz SYSCLKOUT 50 MHz SYSCLKOUT
(kHz) Bits % Bits % Bits %
20 11.6 0.0 11.3 0 18.1 0.000
50 10.2 0.1 10 0.1 16.8 0.001
100 9.2 0.2 9 0.2 15.8 0.002
150 8.6 0.3 8.4 0.3 15.2 0.003
200 8.2 0.3 8 0.4 14.8 0.004
250 7.9 0.4 7.6 0.5 14.4 0.005
500 6.9 0.8 6.6 1 13.4 0.009
1000 5.9 1.7 5.6 2 12.4 0.018
1500 5.3 2.5 5.1 3 11.9 0.027
2000 4.9 3.3 4.6 4 11.4 0.036
Although each application may differ, typical low frequency PWM operation (below 250 kHz) may not
require HRPWM. HRPWM capability is most useful for high frequency PWM requirements of power
conversion topologies such as:
• Single-phase buck, boost, and flyback
• Multi-phase buck, boost, and flyback
• Phase-shifted full bridge
• Direct modulation of D-Class power amplifiers
10 High-Resolution Pulse Width Modulator (HRPWM) SPRUGE8D–February 2009–Revised October 2009
Submit Documentation Feedback
Copyright © 2009, Texas Instruments Incorporated
(1 SYSCLK cycle)
+ 0.5 (rounding)
(0x0080 in Q8 format)
(upper 8 bits)
www.ti.com Operational Description of HRPWM
2 Operational Description of HRPWM
The HRPWM is based on micro edge positioner (MEP) technology. MEP logic is capable of positioning an
edge very finely by sub-dividing one coarse system clock of a conventional PWM generator. The time step
accuracy is on the order of 150 ps. See the device-specific data sheet for the typical MEP step size on a
particular device. The HRPWM also has a self-check software diagnostics mode to check if the MEP logic
is running optimally, under all operating conditions. Details on software diagnostics and functions are in
Section 2.4.
Figure 2 shows the relationship between one coarse system clock and edge position in terms of MEP
steps, which are controlled via an 8-bit field in the Compare A extension register (CMPAHR).
Figure 2. Operating Logic Using MEP
To generate an HRPWM waveform, configure the TBM, CCM, and AQM registers as you would to
generate a conventional PWM of a given frequency and polarity. The HRPWM works together with the
TBM, CCM, and AQM registers to extend edge resolution, and should be configured accordingly. Although
many program