SPRUI30H November 2015 – May 2024 DRA745 , DRA746 , DRA750 , DRA756
An effective PWM peripheral must be able to generate complex pulse width waveforms with minimal CPU overhead or intervention. It needs to be highly programmable and very flexible while being easy to understand and use. The ePWM unit described here addresses these requirements by allocating all needed timing and control resources on a per PWM channel basis. Cross coupling or sharing of resources has been avoided; instead, the ePWM is built up from smaller single channel modules with separate resources and that can operate together as required to form a system. This modular approach results in an orthogonal architecture and provides a more transparent view of the peripheral structure, helping users to understand its operation quickly.
As already described in Section 29.1.3, the letter x within a signal or module name is used to indicate a generic ePWM instance on a device. For example, output signals EPWMxA and EPWMxB refer to the output signals from the ePWMx instance. Thus, EPWM1A and EPWM1B belong to ePWM1, EPWM2A and EPWM2B belong to ePWM2, etc.
The ePWM module represents one complete PWM channel composed of two PWM outputs: EPWMxA and EPWMxB. A given ePWM module functionality can be extended with the so called High-Resolution Pulse Width modulator. Refer to the Section 29.1.3, to determine which ePWM instances include the HRPWM feature. The HRPWM functionalities are described in Section 29.2.45. Each ePWM module is indicated by a numerical value starting with 1. For example ePWM1 is the first instance, the ePWM2 is the second instance in the device, etc. The ePWMx indicates any instance.
As also described in Section 29.1.3.1.2, the ePWM modules are chained together via a clock synchronization scheme that allows them to operate as a single system when required. Additionally, the PWMSSn integration allows this synchronization scheme to be extended to the capture peripheral modules (eCAP). The number of modules is device-dependent and based on target application needs. Modules can also operate stand-alone.
Each ePWM module supports the following features:
Each ePWM module is connected to the input/output signals shown in Figure 29-5. The signals are described in detail in subsequent sections.
The order in which the ePWM modules are connected may differ from what is shown in Figure 29-5. See Section 29.1.3.1.2 for the actual synchronization scheme implemented in the device. Each ePWM module consists of seven submodules and is connected within a system via the signals shown in Figure 29-6.
Figure 29-7 shows more internal details of a single ePWM module. The main signals used by the ePWM module are:
According to the device ePWMx (where x= 1to 3) trip zone i/f implementation, the number of input signals implemented is k=1, which means ONLY the ePWMx TZ0 input is available at chip level. Refer to the Section 29.1.3, for details on trip zone input implementation.
Figure 29-7 also shows the key internal submodule interconnect signals. Each submodule is described in Section 29.2.2.
Seven submodules are included in each ePWM peripheral. There are some instances that include a high-resolution submodule that allows more precise control of the PWM outputs. Each of these submodules performs specific tasks that can be configured by software.
Table 29-15 lists the eight key submodules together with a list of their main configuration parameters. For example, if you need to adjust or control the duty cycle of a PWM waveform, then you should see the counter-compare submodule in Section 29.2.14 for relevant details.
Submodule | Configuration Parameter or Option | |
---|---|---|
Time-base (TB) |
| |
Counter-compare (CC) |
| |
Action-qualifier (AQ) |
| |
Dead-band (DB) |
| |
PWM-chopper (PC) |
| |
Trip-zone (TZ) |
| |
Event-trigger (ET) |
| |
High-Resolution PWM (HRPWM) |
|
The system clock - SYSCLKOUT is the ePWM functional clock derived from the PWMSSn gateable interface and functional clock PWMSSn_GICLK, described in the Section 29.1.3.
Code examples are provided in the remainder of this chapter that show how to implement various ePWM module configurations. These examples use the constant definitions shown in Section 29.2.4.
// TBCTL (Time-Base Control)
// = = = = = = = = = = = = = = = = = = = = = = = = = =
// TBCNT MODE bits
#define TB_COUNT_UP 0x0
#define TB_COUNT_DOWN 0x1
#define TB_COUNT_UPDOWN 0x2
#define TB_FREEZE 0x3
// PHSEN bit
#define TB_DISABLE 0x0
#define TB_ENABLE 0x1
// PRDLD bit
#define TB_SHADOW 0x0
#define TB_IMMEDIATE 0x1
// SYNCOSEL bits
#define TB_SYNC_IN 0x0
#define TB_CTR_ZERO 0x1
#define TB_CTR_CMPB 0x2
#define TB_SYNC_DISABLE 0x3
// HSPCLKDIV and CLKDIV bits
#define TB_DIV1 0x0
#define TB_DIV2 0x1
#define TB_DIV4 0x2
// PHSDIR bit
#define TB_DOWN 0x0
#define TB_UP 0x1
// CMPCTL (Compare Control)
// = = = = = = = = = = = = = = = = = = = = = = = = = =
// LOADAMODE and LOADBMODE bits
#define CC_CTR_ZERO 0x0
#define CC_CTR_PRD 0x1
#define CC_CTR_ZERO_PRD 0x2
#define CC_LD_DISABLE 0x3
// SHDWAMODE and SHDWBMODE bits
#define CC_SHADOW 0x0
#define CC_IMMEDIATE 0x1
// AQCTLA and AQCTLB (Action-qualifier Control)
// = = = = = = = = = = = = = = = = = = = = = = = = = =
// ZRO, PRD, CAU, CAD, CBU, CBD bits
#define AQ_NO_ACTION 0x0
#define AQ_CLEAR 0x1
#define AQ_SET 0x2
#define AQ_TOGGLE 0x3
// DBCTL (Dead-Band Control)
// = = = = = = = = = = = = = = = = = = = = = = = = = =
// MODE bits
#define DB_DISABLE 0x0
#define DBA_ENABLE 0x1
#define DBB_ENABLE 0x2
#define DB_FULL_ENABLE 0x3
// POLSEL bits
#define DB_ACTV_HI 0x0
#define DB_ACTV_LOC 0x1
#define DB_ACTV_HIC 0x2
#define DB_ACTV_LO 0x3
// PCCTL (chopper control)
// = = = = = = = = = = = = = = = = = = = = = = = = = =
// CHPEN bit
#define CHP_ENABLE 0x0
#define CHP_DISABLE 0x1
// CHPFREQ bits
#define CHP_DIV1 0x0
#define CHP_DIV2 0x1
#define CHP_DIV3 0x2
#define CHP_DIV4 0x3
#define CHP_DIV5 0x4
#define CHP_DIV6 0x5
#define CHP_DIV7 0x6
#define CHP_DIV8 0x7
// CHPDUTY bits
#define CHP1_8TH 0x0
#define CHP2_8TH 0x1
#define CHP3_8TH 0x2
#define CHP4_8TH 0x3
#define CHP5_8TH 0x4
#define CHP6_8TH 0x5
#define CHP7_8TH 0x6
// TZSEL (Trip-zone Select)
// = = = = = = = = = = = = = = = = = = = = = = = = = =
// CBCn and OSHTn bits
#define TZ_ENABLE 0x0
#define TZ_DISABLE 0x1
// TZCTL (Trip-zone Control)
// = = = = = = = = = = = = = = = = = = = = = = = = = =
// TZA and TZB bits
#define TZ_HIZ 0x0
#define TZ_FORCE_HI 0x1
#define TZ_FORCE_LO 0x2
#define TZ_DISABLE 0x3
// ETSEL (Event-trigger Select)
// = = = = = = = = = = = = = = = = = = = = = = = = = =
// INTSEL, SOCASEL, SOCBSEL bits
#define ET_CTR_ZERO 0x1
#define ET_CTR_PRD 0x2
#define ET_CTRU_CMPA 0x4
#define ET_CTRD_CMPA 0x5
#define ET_CTRU_CMPB 0x6
#define ET_CTRD_CMPB 0x7
// ETPS (Event-trigger Prescale)
// = = = = = = = = = = = = = = = = = = = = = = = = = =
// INTPRD, SOCAPRD, SOCBPRD bits
#define ET_DISABLE 0x0
#define ET_1ST 0x1
#define ET_2ND 0x2
#define ET_3RD 0x3
When the ePWM peripheral clock is enabled it may be possible that interrupt flags may be set due to spurious events due to the ePWM registers not being properly initialized. The proper procedure for initializing the ePWM peripheral is:
Each ePWM module has its own time-base submodule that determines all of the event timing for the ePWM module. Built-in synchronization logic allows the time-base of multiple ePWM modules (ePWMx) to work together as a single system. Figure 29-8 illustrates the time-base module's place within the ePWM.
You can configure the time-base submodule for the following:
Table 29-16 lists the registers used to control and monitor the time-base submodule.
Acronym | Register Description | Address Offset | Shadowed |
---|---|---|---|
EPWM_TBCTL | Time-Base Control Register | 0h | No |
EPWM_TBSTS | Time-Base Status Register | 2h | No |
HRPWM_TBPHSHR | HRPWM extension Phase Register (1) | 4h | No |
EPWM_TBPHS | Time-Base Phase Register | 6h | No |
EPWM_TBCNT | Time-Base Counter Register | 8h | No |
EPWM_TBPRD | Time-Base Period Register | Ah | Yes |
Figure 29-9 shows the critical signals and registers of the time-base submodule. Table 29-17 provides descriptions of the key signals associated with the time-base submodule.
Signal | Description |
---|---|
EPWMxSYNCI | Time-base synchronization input. |
Input pulse used to synchronize the time-base counter with the counter of ePWM module earlier in the synchronization chain. An ePWM peripheral can be configured to use or ignore this signal. For the first ePWM module (EPWM1) this signal comes from a device pin . For subsequent ePWM modules this signal is passed from another ePWM peripheral. For example, EPWM2SYNCI is generated by the ePWM1 peripheral and the EPWM3SYNCI is generated by ePWM2. See Section 29.2.11 for information on the synchronization order of a particular device. | |
EPWMxSYNCO | Time-base synchronization output. |
This output pulse is used to synchronize the counter of an ePWM module later in the synchronization chain. The ePWM module generates this signal from one of three event sources:
| |
TBCNT = PRD | Time-base counter equal to the specified period. |
This signal is generated whenever the counter value is equal to the active period register value. That is when TBCNT = TBPRD. | |
TBCNT = 0 | Time-base counter equal to zero. |
This signal is generated whenever the counter value is zero. That is when TBCNT equals 0000h. | |
TBCNT = CMPB | Time-base counter equal to active counter-compare B register (TBCNT = CMPB). |
This event is generated by the counter-compare submodule and used by the synchronization out logic. | |
CTR_dir | Time-base counter direction. |
Indicates the current direction of the ePWM's time-base counter. This signal is high when the counter is increasing and low when it is decreasing. | |
CTR_max | Time-base counter equal max value. (TBCNT = FFFFh) |
Generated event when the EPWM_TBCNT value reaches its maximum value. This signal is only used only as a status bit. | |
TBCLK | Time-base clock. |
This is a prescaled version of the system clock - SYSCLKOUT(1) and is used by all submodules within the ePWMn. This clock determines the rate at which time-base counter increments or decrements. |
The frequency of PWM events is controlled by the time-base period (EPWM_TBPRD) register and the mode of the time-base counter. Figure 29-10 shows the period (Tpwm) and frequency (Fpwm) relationships for the up-count, down-count, and up-down-count time-base counter modes when when the period is set to 4 (EPWM_TBPRD register bitfield TBPRD = 0x4). The time increment for each step is defined by the time-base clock (TBCLK) which is a prescaled version of the system clock (SYSCLKOUT).
The time-base counter has three modes of operation selected by the time-base control register (EPWM_TBCTL):
The time-base period register (EPWM_TBPRD) has a shadow register. Shadowing allows the register update to be synchronized with the hardware. The following definitions are used to describe all shadow registers in the ePWM module:
The memory address of the shadow period register is the same as the active register. Which register is written to or read from is determined by the EPWM_TBCTL[3] PRDLD bit. This bit enables and disables the EPWM_TBPRD shadow register as follows:
A time-base synchronization scheme connects all of the ePWM modules on a device. Each ePWM module has a synchronization input (EPWMxSYNCI) and a synchronization output (EPWMxSYNCO). The input synchronization for the first instance (ePWM1) comes from an external pin . For the device ePWM environment sync pin details refer to the Section 29.1.2. The possible synchronization connections for the remaining ePWM modules is shown in Figure 29-11.
Each ePWM module can be configured to use or ignore the synchronization input. If the EPWM_TBCTL[2] PHSEN bit is set, then the time-base counter (TBCNT) of the ePWM module (register EPWM_TBCNT) will be automatically loaded with the phase register (EPWM_TBPHS) contents when one of the following conditions occur:
This feature enables the ePWM module to be automatically synchronized to the time base of another ePWM module. Lead or lag phase control can be added to the waveforms generated by different ePWM modules to synchronize them. In up-down-count mode, the EPWM_TBCTL[13] PHSDIR bit configures the direction of the time-base counter immediately after a synchronization event. The new direction is independent of the direction prior to the synchronization event. The TBPHS bit is ignored in count-up or count-down modes. See Figure 29-12 through Figure 29-15 for examples.
Clearing the EPWM_TBCTL[2] PHSEN bit configures the ePWM to ignore the synchronization input pulse. The synchronization pulse can still be allowed to flow-through to the EPWMxSYNCO and be used to synchronize other ePWM modules. In this way, you can set up a master time-base (for example, ePWM1) and downstream modules (ePWM2 - ePWMx) may elect to run in synchronization with the master.
As already described in the Section 29.1.3.1.3, PWMSS1_TBCLKEN through PWMSS3_TBCLKEN bits in the CTRL_CORE_CONTROL_IO_2 register of the device Core Control Module can be used to individually control or globally synchronize the time-base clocks of all enabled ePWM modules on a device. When all PWMSSN_TBCLKEN (where n = 1 to 3) bits are set to 0b0, the time-base clocks of all ePWMx (where x = 1 to 3) modules are stopped (default). When all PWMSSn_TBCLKEN bits are simultaneously set in SW to 0b1, all ePWMx modules (x = 1 to 3) time-base clocks are started with the rising edge of TBCLK aligned. For perfectly synchronized TBCLKs, the prescaler bits in the EPWM_TBCTL register of each ePWM module must be set identically. The proper procedure for enabling the ePWM clocks is as follows:
The time-base counter operates in one of four modes:
To illustrate the operation of the first three modes, Figure 29-12 to Figure 29-15 show when events are generated and how the time-base responds to an EPWMxSYNCI signal.
Figure 29-16 illustrates the counter-compare submodule within the ePWM. Figure 29-17 shows the basic structure of the counter-compare submodule.
The counter-compare submodule takes as input the time-base counter value. This value is continuously compared to the counter-compare A (EPWM_CMPA) and counter-compare B (EPWM_CMPB) registers. When the time-base counter is equal to one of the compare registers, the counter-compare unit generates an appropriate event.
The counter-compare submodule:
Table 29-18 lists the registers used to control and monitor the counter-compare submodule. Table 29-19 lists the key signals associated with the counter-compare submodule.
Acronym | Register Description | Address Offset | Shadowed |
---|---|---|---|
EPWM_CMPCTL | Counter-Compare Control Register. | Eh | No |
HRPWM_CMPAHR | HRPWM Counter-Compare A Extension Register (1) | 10h | Yes |
EPWM_CMPA | Counter-Compare A Register | 12h | Yes |
EPWM_CMPB | Counter-Compare B Register | 14h | Yes |
Signal | Description of Event | Register Bitfields Compared |
---|---|---|
TBCNT = CMPA | Time-base counter equal to the active counter-compare A value | TBCNT = CMPA |
TBCNT = CMPB | Time-base counter equal to the active counter-compare B value | TBCNT = CMPB |
TBCNT = PRD | Time-base counter equal to the active period. Used to load active counter-compare A and B registers from the shadow register | TBCNT = TBPRD |
TBCNT = 0 | Time-base counter equal to zero. Used to load active counter-compare A and B registers from the shadow register | TBCNT = 0000h |
The counter-compare submodule is responsible for generating two independent compare events based on two compare registers:
For up-count or down-count mode, each event occurs only once per cycle. For up-down-count mode each event occurs twice per cycle, if the compare value is between 0000h and TBPRD; and occurs once per cycle, if the compare value is equal to 0000h or equal to TBPRD. These events are fed into the action-qualifier submodule where they are qualified by the counter direction and converted into actions if enabled. Refer to Section 29.2.20 for more details.
The counter-compare registers EPWM_CMPA and EPWM_CMPB each have an associated shadow register. Shadowing provides a way to keep updates to the registers synchronized with the hardware. When shadowing is used, updates to the active registers only occurs at strategic points. This prevents corruption or spurious operation due to the register being asynchronously modified by software. The memory address of the active register and the shadow register is identical. Which register is written to or read from is determined by the EPWM_CMPCTL[4] SHDWAMODE and EPWM_CMPCTL[6] SHDWBMODE bits. These bits enable and disable the EPWM_CMPA shadow register and EPWM_CMPB shadow register respectively. The behavior of the two load modes is described below:
If the shadow register is enabled then the content of the shadow register is transferred to the active register on one of the following events:
Which of these three events is specified by the EPWM_CMPCTL[1:0] LOADAMODE and EPWM_CMPCTL[3:2] LOADBMODE register bits. Only the active register contents are used by the counter-compare submodule to generate events to be sent to the action-qualifier.
The counter-compare module can generate compare events in all three count modes:
To best illustrate the operation of the first three modes, the timing diagrams in Figure 29-18 to Figure 29-21 show when events are generated and how the EPWMxSYNCI signal interacts.
Figure 29-22 shows the action-qualifier (AQ) submodule (see shaded block) in the ePWM system. The action-qualifier submodule has the most important role in waveform construction and PWM generation. It decides which events are converted into various action types, thereby producing the required switched waveforms at the EPWMxA and EPWMxB outputs.
The action-qualifier submodule is responsible for the following:
Table 29-20 lists the registers used to control and monitor the action-qualifier submodule.
Acronym | Register Description | Address Offset | Shadowed |
---|---|---|---|
EPWM_AQCTLA | Action-Qualifier Control Register For Output A (EPWMxA) | 16h | No |
EPWM_AQCTLB | Action-Qualifier Control Register For Output B (EPWMxB) | 18h | No |
EPWM_AQSFRC | Action-Qualifier Software Force Register | 1Ah | No |
EPWM_AQCSFRC | Action-Qualifier Continuous Software Force | 1Ch | Yes |
The action-qualifier submodule is based on event-driven logic. It can be thought of as a programmable cross switch with events at the input and actions at the output, all of which are software controlled via the set of registers shown in Figure 29-23. The possible input events are summarized again in Table 29-21.
Signal | Description | Register Bitfield Compared |
---|---|---|
TBCNT = PRD | Time-base counter equal to the period value | TBCNT = TBPRD |
TBCNT = 0 | Time-base counter equal to zero | TBCNT = 0000h |
TBCNT = CMPA | Time-base counter equal to the counter-compare A | TBCNT = CMPA |
TBCNT = CMPB | Time-base counter equal to the counter-compare B | TBCNT = CMPB |
Software forced event | Asynchronous event initiated by software |
The software forced action is a useful asynchronous event. This control is handled by registers EPWM_AQSFRC and EPWM_AQCSFRC.
The action-qualifier submodule controls how the two outputs EPWMxA and EPWMxB behave when a particular event occurs. The event inputs to the action-qualifier submodule are further qualified by the counter direction (up or down). This allows for independent action on outputs on both the count-up and count-down phases.
The possible actions imposed on outputs EPWMxA and EPWMxB are:
Actions are specified independently for either output (EPWMxA or EPWMxB). Any or all events can be configured to generate actions on a given output. For example, both TBCNT = CMPA and TBCNT = CMPB can operate on output EPWMxA. All qualifier actions are configured via the control registers found at the end of this section.
For clarity, the drawings in this chapter use a set of symbolic actions. These symbols are summarized in Figure 29-24. Each symbol represents an action as a marker in time. Some actions are fixed in time (zero and period) while the CMPA and CMPB actions are moveable and their time positions are programmed via the counter-compare A and B registers, respectively. To turn off or disable an action, use the "Do Nothing option"; it is the default at reset.
It is possible for the ePWM action qualifier to receive more than one event at the same time. In this case events are assigned a priority by the hardware. The general rule is events occurring later in time have a higher priority and software forced events always have the highest priority. The event priority levels for up-down-count mode are shown in Table 29-22. A priority level of 1 is the highest priority and level 7 is the lowest. The priority changes slightly depending on the direction of TBCNT.
Priority Level | Event if TBCNT is Incrementing TBCNT = 0 up to TBCNT = TBPRD | Event if TBCNT is Decrementing TBCNT = TBPRD down to TBCNT = 1 |
---|---|---|
1 (Highest) | Software forced event | Software forced event |
2 | Counter equals CMPB on up-count (CBU) | Counter equals CMPB on down-count (CBD) |
3 | Counter equals CMPA on up-count (CAU) | Counter equals CMPA on down-count (CAD) |
4 | Counter equals zero | Counter equals period (TBPRD in EPWM_TBPRD active register) |
5 | Counter equals CMPB on down-count (CBD) (1) | Counter equals CMPB on up-count (CBU) (1) |
6 (Lowest) | Counter equals CMPA on down-count (CAD) (1) | Counter equals CMPA on up-count (CBU) (1) |
Table 29-23 shows the action-qualifier priority for up-count mode. In this case, the counter direction is always defined as up and thus down-count events will never be taken.
Priority Level | Event |
---|---|
1 (Highest) | Software forced event |
2 | Counter equal to period (TBPRD) |
3 | Counter equal to CMPB on up-count (CBU) |
4 | Counter equal to CMPA on up-count (CAU) |
5 (Lowest) | Counter equal to Zero |
Table 29-24 shows the action-qualifier priority for down-count mode. In this case, the counter direction is always defined as down and thus up-count events will never be taken.
Priority Level | Event |
---|---|
1 (Highest) | Software forced event |
2 | Counter equal to Zero |
3 | Counter equal to CMPB on down-count (CBD) |
4 | Counter equal to CMPA on down-count (CAD) |
5 (Lowest) | Counter equal to period (TBPRD) |
It is possible to set the compare value greater than the period. In this case the action will take place as shown in Table 29-25.
Counter Mode | Compare on Up-Count Event CAU/CBU | Compare on Down-Count Event CAU/CBU |
---|---|---|
Up-Count Mode | If CMPA/CMPB ≤ TBPRD period, then the event occurs on a compare match (TBCNT = CMPA or CMPB). | Never occurs. |
If CMPA/CMPB > TBPRD, then the event will not occur. | ||
Down-Count Mode | Never occurs. | If CMPA/CMPB < TBPRD, the event will occur on a compare match (TBCNT = CMPA or CMPB). |
If CMPA/CMPB ≥ TBPRD, the event will occur on a period match (TBCNT = TBPRD). | ||
Up-Down-Count Mode | If CMPA/CMPB < TBPRD and the counter is incrementing, the event occurs on a compare match (TBCNT = CMPA or CMPB). | If CMPA/CMPB < TBPRD and the counter is decrementing, the event occurs on a compare match (TBCNT = CMPA or CMPB). |
If CMPA/CMPB is ≥ TBPRD, the event will occur on a period match (TBCNT = TBPRD). | If CMPA/CMPB ≥ TBPRD, the event occurs on a period match (TBCNT = TBPRD). |
The waveforms in this chapter show the ePWMs behavior for a static compare register value. In a running system, the active compare registers (EPWM_CMPA and EPWM_CMPB) are typically updated from their respective shadow registers once every period. The user specifies when the update will take place; either when the time-base counter reaches zero or when the time-base counter reaches period. There are some cases when the action based on the new value can be delayed by one period or the action based on the old value can take effect for an extra period. Some PWM configurations avoid this situation. These include, but are not limited to, the following:
Use up-down-count mode to generate a symmetric PWM:
This means there will always be a pulse of at least one TBCLK cycle in a PWM period which, when very short, tend to be ignored by the system.
Use up-down-count mode to generate an asymmetric PWM:
When using up-count mode to generate an asymmetric PWM:
Figure 29-25 shows how a symmetric PWM waveform can be generated using the up-down-count mode of the TBCNT. In this mode 0%-100% DC modulation is achieved by using equal compare matches on the up count and down count portions of the waveform. In the example shown, CMPA is used to make the comparison. When the counter is incrementing the CMPA match will pull the PWM output high. Likewise, when the counter is decrementing the compare match will pull the PWM signal low. When CMPA = 0, the PWM signal is low for the entire period giving the 0% duty waveform. When EPWM_CMPA = EPWM_TBPRD, the PWM signal is high achieving 100% duty.
When using this configuration in practice, if you load CMPA/CMPB on zero, then use CMPA/CMPB values greater than or equal to 1. If you load CMPA/CMPB on period, then use CMPA/CMPB values less than or equal to TBPRD-1. This means there will always be a pulse of at least one TBCLK cycle in a PWM period which, when very short, tend to be ignored by the system.
The PWM waveforms in Figure 29-26 through Figure 29-31 show some common action-qualifier configurations. Some conventions used in the figures are as follows:
Table 29-26 and Table 29-27 contains initialization and runtime register configurations for the waveforms in Figure 29-26.
Register | Bitfield | Value | Comments |
---|---|---|---|
EPWM_TBPRD | TBPRD | 600 (258h) | Period = 601 TBCLK counts |
EPWM_TBPHS | TBPHS | 0 | Clear Phase Register to 0 |
EPWM_TBCNT | TBCNT | 0 | Clear TB counter |
EPWM_TBCTL | CTRMODE | TB_UP | |
PHSEN | TB_DISABLE | Phase loading disabled | |
PRDLD | TB_SHADOW | ||
SYNCOSEL | TB_SYNC_DISABLE | ||
HSPCLKDIV | TB_DIV1 | TBCLK = SYSCLKOUT | |
CLKDIV | TB_DIV1 | ||
EPWM_CMPA | CMPA | 350 (15Eh) | Compare A = 350 TBCLK counts |
EPWM_CMPB | CMPB | 200 (C8h) | Compare B = 200 TBCLK counts |
EPWM_CMPCTL | SHDWAMODE | CC_SHADOW | |
SHDWBMODE | CC_SHADOW | ||
LOADAMODE | CC_CTR_ZERO | Load on TBCNT = 0 | |
LOADBMODE | CC_CTR_ZERO | Load on TBCNT = 0 | |
EPWM_AQCTLA | ZRO | AQ_SET | |
CAU | AQ_CLEAR | ||
EPWM_AQCTLB | ZRO | AQ_SET | |
CBU | AQ_CLEAR |
Register | Bitfield | Value | Comments |
---|---|---|---|
EPWM_CMPA | CMPA | Duty1A | Adjust duty for output EPWM1A |
EPWM_CMPB | CMPB | Duty1B | Adjust duty for output EPWM1B |
Table 29-28 and Table 29-29 contains initialization and runtime register configurations for the waveforms in Figure 29-27.
Register | Bitfiled | Value | Comments |
---|---|---|---|
EPWM_TBPRD | TBPRD | 600 (258h) | Period = 601 TBCLK counts |
EPWM_TBPHS | TBPHS | 0 | Clear Phase Register to 0 |
EPWM_TBCNT | TBCNT | 0 | Clear TB counter |
EPWM_TBCTL | CTRMODE | TB_UP | |
PHSEN | TB_DISABLE | Phase loading disabled | |
PRDLD | TB_SHADOW | ||
SYNCOSEL | TB_SYNC_DISABLE | ||
HSPCLKDIV | TB_DIV1 | TBCLK = SYSCLKOUT | |
CLKDIV | TB_DIV1 | ||
EPWM_CMPA | CMPA | 350 (15Eh) | Compare A = 350 TBCLK counts |
EPWM_CMPB | CMPB | 200 (C8h) | Compare B = 200 TBCLK counts |
EPWM_CMPCTL | SHDWAMODE | CC_SHADOW | |
SHDWBMODE | CC_SHADOW | ||
LOADAMODE | CC_CTR_ZERO | Load on TBCNT = 0 | |
LOADBMODE | CC_CTR_ZERO | Load on TBCNT = 0 | |
EPWM_AQCTLA | PRD | AQ_CLEAR | |
CAU | AQ_SET | ||
EPWM_AQCTLB | PRD | AQ_CLEAR | |
CBU | AQ_SET |
Register | Bit | Value | Comments |
---|---|---|---|
EPWM_CMPA | CMPA | Duty1A | Adjust duty for output EPWM1A |
EPWM_CMPB | CMPB | Duty1B | Adjust duty for output EPWM1B |
Table 29-30 and Table 29-31 contains initialization and runtime register configurations for the waveforms Figure 29-28. Use the code in Section 29.2.4 to define the headers.
Register | Bitfield | Value | Comments |
---|---|---|---|
EPWM_TBPRD | TBPRD | 600 (258h) | Period = 601 TBCLK counts |
EPWM_TBPHS | TBPHS | 0 | Clear Phase Register to 0 |
EPWM_TBCNT | TBCNT | 0 | Clear TB counter |
EPWM_TBCTL | CTRMODE | TB_UP | |
PHSEN | TB_DISABLE | Phase loading disabled | |
PRDLD | TB_SHADOW | ||
SYNCOSEL | TB_SYNC_DISABLE | ||
HSPCLKDIV | TB_DIV1 | TBCLK = SYSCLKOUT | |
CLKDIV | TB_DIV1 | ||
EPWM_CMPA | CMPA | 200 (C8h) | Compare A = 200 TBCLK counts |
EPWM_CMPB | CMPB | 400 (190h) | Compare B = 400 TBCLK counts |
EPWM_CMPCTL | SHDWAMODE | CC_SHADOW | |
SHDWBMODE | CC_SHADOW | ||
LOADAMODE | CC_CTR_ZERO | Load on TBCNT = 0 | |
LOADBMODE | CC_CTR_ZERO | Load on TBCNT = 0 | |
EPWM_AQCTLA | CAU | AQ_SET | |
CBU | AQ_CLEAR | ||
EPWM_AQCTLB | ZRO | AQ_TOGGLE |
Register | Bitfield | Value | Comments |
---|---|---|---|
EPWM_CMPA | CMPA | EdgePosA | Adjust duty for output EPWM1A |
EPWM_CMPB | CMPB | EdgePosB |
Table 29-32 and Table 29-33 contains initialization and runtime register configurations for the waveforms in Figure 29-29. Use the code in Section 29.2.4 to define the headers.
Register | Bitfield | Value | Comments |
---|---|---|---|
EPWM_TBPRD | TBPRD | 600 (258h) | Period = 601 TBCLK counts |
EPWM_TBPHS | TBPHS | 0 | Clear Phase Register to 0 |
EPWM_TBCNT | TBCNT | 0 | Clear TB counter |
EPWM_TBCTL | CTRMODE | TB_UPDOWN | |
PHSEN | TB_DISABLE | Phase loading disabled | |
PRDLD | TB_SHADOW | ||
SYNCOSEL | TB_SYNC_DISABLE | ||
HSPCLKDIV | TB_DIV1 | TBCLK = SYSCLKOUT | |
CLKDIV | TB_DIV1 | ||
EPWM_CMPA | CMPA | 400 (190h) | Compare A = 400 TBCLK counts |
EPWM_CMPB | CMPB | 500 (1F4h) | Compare B = 500 TBCLK counts |
EPWM_CMPCTL | SHDWAMODE | CC_SHADOW | |
SHDWBMODE | CC_SHADOW | ||
LOADAMODE | CC_CTR_ZERO | Load on TBCNT = 0 | |
LOADBMODE | CC_CTR_ZERO | Load on TBCNT = 0 | |
EPWM_AQCTLA | CAU | AQ_SET | |
CAD | AQ_CLEAR | ||
EPWM_AQCTLB | CBU | AQ_SET | |
CBD | AQ_CLEAR |
Register | Bitfield | Value | Comments |
---|---|---|---|
EPWM_CMPA | CMPA | Duty1A | Adjust duty for output EPWM1A |
EPWM_CMPB | CMPB | Duty1B | Adjust duty for output EPWM1B |
Table 29-34 and Table 29-35 contains initialization and runtime register configurations for the waveforms in Figure 29-30. Use the code in Section 29.2.4 to define the headers.
Register | Bitfield | Value | Comments |
---|---|---|---|
EPWM_TBPRD | TBPRD | 600 (258h) | Period = 601 TBCLK counts |
EPWM_TBPHS | TBPHS | 0 | Clear Phase Register to 0 |
EPWM_TBCNT | TBCNT | 0 | Clear TB counter |
EPWM_TBCTL | CTRMODE | TB_UPDOWN | |
PHSEN | TB_DISABLE | Phase loading disabled | |
PRDLD | TB_SHADOW | ||
SYNCOSEL | TB_SYNC_DISABLE | ||
HSPCLKDIV | TB_DIV1 | TBCLK = SYSCLKOUT | |
CLKDIV | TB_DIV1 | ||
EPWM_CMPA | CMPA | 350 (15Eh) | Compare A = 350 TBCLK counts |
EPWM_CMPB | CMPB | 400 (190h) | Compare B = 400 TBCLK counts |
EPWM_CMPCTL | SHDWAMODE | CC_SHADOW | |
SHDWBMODE | CC_SHADOW | ||
LOADAMODE | CC_CTR_ZERO | Load on TBCNT = 0 | |
LOADBMODE | CC_CTR_ZERO | Load on TBCNT = 0 | |
EPWM_AQCTLA | CAU | AQ_SET | |
CAD | AQ_CLEAR | ||
EPWM_AQCTLB | CBU | AQ_CLEAR | |
CBD | AQ_SET |
Register | Bitfield | Value | Comments |
---|---|---|---|
EPWM_CMPA | CMPA | Duty1A | Adjust duty for output EPWM1A |
EPWM_CMPB | CMPB | Duty1B | Adjust duty for output EPWM1B |
Table 29-36 and Table 29-37 contains initialization and runtime register configurations for the waveforms in Figure 29-31. Use the code in Section 29.2.4 to define the headers.
Register | Bitfield | Value | Comments |
---|---|---|---|
EPWM_TBPRD | TBPRD | 600 (258h) | Period = 601 TBCLK counts |
EPWM_TBPHS | TBPHS | 0 | Clear Phase Register to 0 |
EPWM_TBCNT | TBCNT | 0 | Clear TB counter |
EPWM_TBCTL | CTRMODE | TB_UPDOWN | |
PHSEN | TB_DISABLE | Phase loading disabled | |
PRDLD | TB_SHADOW | ||
SYNCOSEL | TB_SYNC_DISABLE | ||
HSPCLKDIV | TB_DIV1 | TBCLK = SYSCLKOUT | |
CLKDIV | TB_DIV1 | ||
EPWM_CMPA | CMPA | 250 (FAh) | Compare A = 250 TBCLK counts |
EPWM_CMPB | CMPB | 450 (1C2h) | Compare B = 450 TBCLK counts |
EPWM_CMPCTL | SHDWAMODE | CC_SHADOW | |
SHDWBMODE | CC_SHADOW | ||
LOADAMODE | CC_CTR_ZERO | Load on TBCNT = 0 | |
LOADBMODE | CC_CTR_ZERO | Load on TBCNT = 0 | |
EPWM_AQCTLA | CAU | AQ_SET | |
CBD | AQ_CLEAR | ||
EPWM_AQCTLB | ZRO | AQ_CLEAR | |
PRD | AQ_SET |
Figure 29-32 illustrates the dead-band generator submodule within the ePWM module.
The "Action-qualifier (AQ) Module" section discussed how it is possible to generate the required dead-band by having full control over edge placement using both the CMPA and CMPB resources of the ePWM module. However, if the more classical edge delay-based dead-band with polarity control is required, then the dead-band generator submodule should be used.
The key functions of the dead-band generator submodule are:
The dead-band generator submodule operation is controlled and monitored via the following registers:
Acronym | Register Description | Address Offset | Shadowed |
---|---|---|---|
EPWM_DBCTL | Dead-Band Control Register | 1Eh | No |
EPWM_DBRED | Dead-Band Rising Edge Delay Count Register | 20h | No |
EPWM_DBFED | Dead-Band Falling Edge Delay Count Register | 22h | No |
The following sections provide the operational highlights.
The dead-band submodule has two groups of independent selection options as shown in Figure 29-33.
Although all combinations are supported, not all are typical usage modes. Table 29-39 lists some classical dead-band configurations. These modes assume that the EPWM_DBCTL[5:4] IN_MODE is configured such that EPWMxA In is the source for both falling-edge and rising-edge delay. Enhanced, or non-traditional modes can be achieved by changing the input signal source. The modes shown in Table 29-39 fall into the following categories:
Mode | Mode Description (1) | EPWM_DBCTL[3:2] POLSEL | EPWM_DBCTL[1:0] OUT_MODE | |||
---|---|---|---|---|---|---|
S3 | S2 | S1 | S0 | |||
1 | EPWMxA and EPWMxB Passed Through (No Delay) | x | x | 0 | 0 | |
2 | Active High Complementary (AHC) | 1 | 0 | 1 | 1 | |
3 | Active Low Complementary (ALC) | 0 | 1 | 1 | 1 | |
4 | Active High (AH) | 0 | 0 | 1 | 1 | |
5 | Active Low (AL) | 1 | 1 | 1 | 1 | |
6 | EPWMxA Out = EPWMxA In (No Delay) | 0 or 1 | 0 or 1 | 0 | 1 | |
EPWMxB Out = EPWMxA In with Falling Edge Delay | ||||||
7 | EPWMxA Out = EPWMxA In with Rising Edge Delay | 0 or 1 | 0 or 1 | 1 | 0 | |
EPWMxB Out = EPWMxB In with No Delay |
Figure 29-34 shows waveforms for typical cases where 0% < duty < 100%.
The dead-band submodule supports independent values for rising-edge (RED) and falling-edge (FED) delays. The amount of delay is programmed using the EPWM_DBRED and EPWM_DBFED registers. These are 10-bit registers and their value represents the number of time-base clock, TBCLK, periods a signal edge is delayed by. For example, the formula to calculate falling-edge-delay and rising-edge-delay are:
FED = EPWM_DBFED × TTBCLK
RED = EPWM_DBRED × TTBCLK
Where TTBCLK is the period of TBCLK, the prescaled version of SYSCLKOUT.
Figure 29-35 illustrates the PWM-chopper (PC) submodule within the ePWM module. The PWM-chopper submodule allows a high-frequency carrier signal to modulate the PWM waveform generated by the action-qualifier and dead-band submodules. This capability is important if you need pulse transformer-based gate drivers to control the power switching elements.
The key functions of the PWM-chopper submodule are:
The PWM-chopper submodule operation is controlled via the register in Table 29-40.
Acronym | Register Description | Address Offset | Shadowed |
---|---|---|---|
EPWM_PCCTL | PWM-chopper Control Register | 3Ch | No |
Figure 29-36 shows the operational details of the PWM-chopper submodule. The carrier clock is derived from SYSCLKOUT. Its frequency and duty cycle are controlled via the CHPFREQ and CHPDUTY bits in the EPWM_PCCTL register. The one-shot block is a feature that provides a high energy first pulse to ensure hard and fast power switch turn on, while the subsequent pulses sustain pulses, ensuring the power switch remains on. The one-shot width is programmed via the OSHTWTH bits. The PWM-chopper submodule can be fully disabled (bypassed) via the CHPEN bit.
Figure 29-37 shows simplified waveforms of the chopping action only; one-shot and duty-cycle control are not shown. Details of the one-shot and duty-cycle control are discussed in the following sections.
The width of the first pulse can be programmed to any of 16 possible pulse width values. The width or period of the first pulse is given by:
T1stpulse = TSYSCLKOUT × 8 × OSHTWTH
Where TSYSCLKOUT is the period of the system clock (SYSCLKOUT) and OSHTWTH is the four control bits (value from 1 to 16)
Figure 29-38 shows the first and subsequent sustaining pulses.
Pulse transformer-based gate drive designs need to comprehend the magnetic properties or characteristics of the transformer and associated circuitry. Saturation is one such consideration. To assist the gate drive designer, the duty cycles of the second and subsequent pulses have been made programmable. These sustaining pulses ensure the correct drive strength and polarity is maintained on the power switch gate during the on period, and hence a programmable duty cycle allows a design to be tuned or optimized via software control.
Figure 29-39 shows the duty cycle control that is possible by programming the CHPDUTY bits. One of seven possible duty ratios can be selected ranging from 12.5% to 87.5%.
Figure 29-40 shows how the trip-zone (TZ) submodule fits within the ePWM module. Each ePWM module is connected to every TZ signal that are sourced from the GPIO MUX. These signals indicates external fault or trip conditions, and the ePWM outputs can be programmed to respond accordingly when faults occur. See Section 29.1.3 to determine the number of trip-zone pins available for the device.
The key functions of the trip-zone submodule are:
For each ePWMx, from the tripzone inputs EPWM_TRIP_TZ[5:0], ONLY the EPWM_TRIP_TZ[0] input of ePWM tripzone is chip accessible and usable, i.e. k=1.
The trip-zone submodule operation is controlled and monitored through the following registers:
Acronym | Register Description | Address Offset | Shadowed |
---|---|---|---|
EPWM_TZSEL | Trip-Zone Select Register | 24h | No |
EPWM_TZCTL | Trip-Zone Control Register | 28h | No |
EPWM_TZEINT | Trip-Zone Enable Interrupt Register | 2Ah | No |
EPWM_TZFLG | Trip-Zone Flag Register | 2Ch | No |
EPWM_TZCLR | Trip-Zone Clear Register | 2Eh | No |
EPWM_TZFRC | Trip-Zone Force Register | 30h | No |
The following sections describe the operational highlights and configuration options for the trip-zone submodule.
The trip-zone signals at pin TZ0 to TZk-1 is an active-low input signal. When the pin goes low, it indicates that a trip event has occurred. Each ePWM module can be individually configured to ignore or use each of the trip-zone pins. Which trip-zone pins are used by a particular ePWM module is determined by the EPWM_TZSEL register for that specific ePWM module. The trip-zone signal may or may not be synchronized to the system clock (SYSCLKOUT). A minimum of 1 SYSCLKOUT low pulse on the TZn inputs is sufficient to trigger a fault condition in the ePWM module. The asynchronous trip makes sure that if clocks are missing for any reason, the outputs can still be tripped by a valid event present on the TZk inputs.
Only the TZ[0] input is accessible at chip level (i.e. k=1).
The TZk input can be individually configured to provide either a cycle-by-cycle or one-shot trip event for a ePWM module. The configuration is determined by the EPWM_TZSEL[7:0] CBCk and EPWM_TZSEL[15:8] OSHTk bits (where k corresponds to the trip pin) respectively.
The specified condition on the pins is automatically cleared when the ePWM time-base counter reaches zero (EPWM_TBCNT bitfield TBCNT = 0000h) if the trip event is no longer present. Therefore, in this mode, the trip event is cleared or reset every PWM cycle. The EPWM_TZFLG[1] CBC flag bit will remain set until it is manually cleared by writing to the EPWM_TZCLR[1] CBC bit. If the cycle-by-cycle trip event is still present when the EPWM_TZFLG[1] CBC bit is cleared, then it will again be immediately set.
The action taken when a trip event occurs can be configured individually for each of the ePWM output pins by way of the EPWM_TZCTL[1:0] TZA and EPWM_TZCTL[3:2] TZB register bits. One of four possible actions, shown in Table 29-42, can be taken on a trip event.
EPWM_TZCTL[1:0] TZA and/or EPWM_TZCTL[3:2] TZB | EPWMxA and/or EPWMxB | Comment |
---|---|---|
0 | High-Impedance | Tripped |
1h | Force to High State | Tripped |
2h | Force to Low State | Tripped |
3h | No Change | Do Nothing. No change is made to the output. |
Scenario A:
A one-shot trip event on
TZ0 pulls both EPWM1A, EPWM1B low and also forces EPWM2A and EPWM2B high.
Figure 29-41 and Figure 29-42 illustrate the trip-zone submodule control and interrupt logic, respectively.
Figure 29-43 shows the event-trigger (ET) submodule in the ePWM system. The event-trigger submodule manages the events generated by the time-base submodule and the counter-compare submodule to generate an aggregated interrupt request.
The ePWMx ET interrupt request output is further routed via the device IRQ_CROSSBAR, to different device host interrupt controllers, located outside PWMSSn. For more details on interrupt event routing outside the ePWM, refer to the Section 29.1.3.
The key functions of the event-trigger submodule are:
The key registers used to configure the event-trigger submodule are shown in Table 29-43:
Acronym | Register Description | Address Offset | Shadowed |
---|---|---|---|
EPWM_ETSEL | Event-Trigger Selection Register | 32h | No |
EPWM_ETPS | Event-Trigger Prescale Register | 34h | No |
EPWM_ETFLG | Event-Trigger Flag Register | 36h | No |
EPWM_ETCLR | Event-Trigger Clear Register | 38h | No |
EPWM_ETFRC | Event-Trigger Force Register | 3Ah | No |
The following sections describe the event-trigger submodule's operational highlights.
Each ePWM module has one interrupt request line as shown in Figure 29-44. Mapping interrupt lines to device host interrupt controllers is device specific and is covered in the Section 29.1.3.
The event-trigger submodule monitors various event conditions (the left side inputs to event-trigger submodule shown in Figure 29-45) and can be configured to prescale these events before issuing an Interrupt request. The event-trigger prescaling logic can issue Interrupt requests at:
A more detailed look at how the various register bits interact with the Interrupt is shown in Figure 29-46.
Figure 29-46 shows the event-trigger's interrupt generation logic. The interrupt-period (EPWM_ETPS[1:0] INTPRD) bits specify the number of events required to cause an interrupt pulse to be generated. The choices available are:
An interrupt cannot be generated on every fourth or more events.
Which event can cause an interrupt is configured by the interrupt selection (EPWM_ETSEL[2:0] INTSEL) bits. The event can be one of the following:
The number of events that have occurred can be read from the interrupt event counter (EPWM_ETPS[3:2] INTCNT) register bits. That is, when the specified event occurs the EPWM_ETPS[3:2] INTCNT bits are incremented until they reach the value specified by EPWM_ETPS[1:0] INTPRD. When EPWM_ETPS[3:2] INTCNT = EPWM_ETPS[1:0] INTPRD the counter stops counting and its output is set. The counter is only cleared when an interrupt is sent to the interrupt controller.
When EPWM_ETPS[3:2] INTCNT reaches EPWM_ETPS[1:0] INTPRD, one of the following behaviors will occur:
Writing to the INTPRD bits will automatically clear the counter INTCNT = 0 and the counter output will be reset (so no interrupts are generated). Writing a 1 to the EPWM_ETFRC[0] INT bit will increment the event counter INTCNT. The counter will behave as described above when INTCNT = INTPRD. When INTPRD = 0, the counter is disabled and hence no events will be detected and the EPWM_ETFRC[0] INT bit is also ignored.
Figure 29-47 shows the high-resolution PWM (HRPWM) submodule in the ePWM system. Some devices include the high-resolution PWM submodule, see Section 29.1.3 to determine which ePWM instances include this feature.
The enhanced high-resolution pulse-width modulator (eHRPWM) 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:
The ePWM peripheral is used to perform a function that is mathematically equivalent to a digital-to-analog converter (DAC). As shown in Figure 29-48, the effective resolution for conventionally generated PWM is a function of PWM frequency (or period) and system clock frequency.
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 29-44 shows resolution in bits for various PWM frequencies. Table 29-44 values assume a MEP step size of 180 ps. See your device-specific data manual for typical and maximum performance specifications for the MEP.
PWM Frequency (kHz) | Regular Resolution (PWM) | High Resolution (HRPWM) | |||
---|---|---|---|---|---|
Bits | % | Bits | % | ||
20 | 12.3 | 0.0 | 18.1 | 0.000 | |
50 | 11.0 | 0.0 | 16.8 | 0.001 | |
100 | 10.0 | 0.1 | 15.8 | 0.002 | |
150 | 9.4 | 0.2 | 15.2 | 0.003 | |
200 | 9.0 | 0.2 | 14.8 | 0.004 | |
250 | 8.6 | 0.3 | 14.4 | 0.005 | |
500 | 7.6 | 0.5 | 13.8 | 0.007 | |
1000 | 6.6 | 1.0 | 12.4 | 0.018 | |
1500 | 6.1 | 1.5 | 11.9 | 0.027 | |
2000 | 5.6 | 2.0 | 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:
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. The HRPWM also has a self-check software diagnostics mode to check if the MEP logic is running optimally, under all operating conditions.
Figure 29-49 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 (HRPWM_CMPAHR).
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 programming combinations are possible, only a few are needed and practical.
The MEP of the HRPWM is controlled by two extension registers, each 8-bits wide. These two HRPWM registers are concatenated with the 16-bit EPWM_TBPHS and EPWM_CMPA registers used to control PWM operation.
Table 29-45 lists the registers used to control and monitor the high-resolution PWM submodule.
Acronym | Register Description | Address Offset | Shadowed |
---|---|---|---|
HRPWM_TBPHSHR | Extension Register for HRPWM Phase | 4h | No |
HRPWM_CMPAHR | Extension Register for HRPWM Duty | 10h | Yes |
HRPWM_HRCTL | HRPWM Configuration Register | 1040h | No |
Once the ePWM has been configured to provide conventional PWM of a given frequency and polarity, the HRPWM is configured by programming the HRPWM_HRCTL register located at offset address 1040h. This register provides configuration options for the following key operating modes:
The MEP logic is capable of placing an edge in one of 255 (8 bits) discrete time steps, each of which has a time resolution on the order of 150 ps. The MEP works with the TBM and CCM registers to be certain that time steps are optimally applied and that edge placement accuracy is maintained over a wide range of PWM frequencies, system clock frequencies and other operating conditions. Table 29-46 shows the typical range of operating frequencies supported by the HRPWM.
System (MHz) | MEP Steps Per SYSCLKOUT(1) (2) (3) | PWM Minimum (Hz)(4) | PWM Maximum (MHz) | Resolution at Maximum (Bits)(5) |
---|---|---|---|---|
50.0 | 111 | 763 | 2.50 | 11.1 |
60.0 | 93 | 916 | 3.00 | 10.9 |
70.0 | 79 | 1068 | 3.50 | 10.6 |
80.0 | 69 | 1221 | 4.00 | 10.4 |
90.0 | 62 | 1373 | 4.50 | 10.3 |
100.0 | 56 | 1526 | 5.00 | 10.1 |
In a typical power control loop (switch modes, digital motor control (DMC), uninterruptible power supply (UPS)), a digital controller (PID, 2pole/2zero, lag/lead, etc.) issues a duty command, usually expressed in a per unit or percentage terms.
In the following example, assume that for a particular operating point, the demanded duty cycle is 0.405 or 40.5% on-time and the required converter PWM frequency is 1.25 MHz. In conventional PWM generation with a system clock of 100 MHz, the duty cycle choices are in the vicinity of 40.5%. In Figure 29-50, a compare value of 32 counts (duty = 40%) is the closest to 40.5% that you can attain. This is equivalent to an edge position of 320 ns instead of the desired 324 ns. This data is shown in Table 29-47.
By utilizing the MEP, you can achieve an edge position much closer to the desired point of 324 ns. Table 29-47 shows that in addition to the CMPA value, 22 steps of the MEP (HRPWM_CMPAHR register) will position the edge at 323.96 ns, resulting in almost zero error. In this example, it is assumed that the MEP has a step resolution of 180 ns.
CMPA (count)(1) (2) (3) | DUTY (%) | High Time (ns) | CMPA (count) | CMPAHR (count) | Duty (%) | High Time (ns) | |
---|---|---|---|---|---|---|---|
28 | 35.0 | 280 | 32 | 18 | 40.405 | 323.24 | |
29 | 36.3 | 290 | 32 | 19 | 40.428 | 323.42 | |
30 | 37.5 | 300 | 32 | 20 | 40.450 | 323.60 | |
31 | 38.8 | 310 | 32 | 21 | 40.473 | 323.78 | |
32 | 40.0 | 320 | 32 | 22 | 40.495 | 323.96 | |
33 | 41.3 | 330 | 32 | 23 | 40.518 | 324.14 | |
34 | 42.5 | 340 | 32 | 24 | 40.540 | 324.32 | |
32 | 25 | 40.563 | 324.50 | ||||
Required | 32 | 26 | 40.585 | 324.68 | |||
32.40 | 40.5 | 324 | 32 | 27 | 40.608 | 324.86 |
The mechanics of how to position an edge precisely in time has been demonstrated using the resources of the standard (EPWM_CMPA) and MEP (HRPWM_CMPAHR) registers. In a practical application, however, it is necessary to seamlessly provide the CPU a mapping function from a per-unit (fractional) duty cycle to a final integer (non-fractional) representation that is written to the [CMPA:CMPAHR] register combination.
To do this, first examine the scaling or mapping steps involved. It is common in control software to express duty cycle in a per-unit or percentage basis. This has the advantage of performing all needed math calculations without concern for the final absolute duty cycle, expressed in clock counts or high time in ns. Furthermore, it makes the code more transportable across multiple converter types running different PWM frequencies.
To implement the mapping scheme, a two-step scaling procedure is required.
Assumptions for this example:
System clock, SYSCLKOUT | = | 10 ns (100 MHz) |
PWM frequency | = | 1.25 MHz (1/800 ns) |
Required PWM duty cycle, PWMDuty | = | 0.405 (40.5%) |
PWM period in terms of coarse steps, PWMperiod (800 ns/10 ns) | = | 80 |
Number of MEP steps per coarse step at 180 ps (10 ns/180 ps), MEP_SF | = | 55 |
Value to keep CMPAHR within the range of 1-255 and fractional rounding constant (default value) | = | 180h |
Step 1: Percentage Integer Duty value conversion for EPWM_CMPA register
EPWM_CMPA register value | = | int(PWMDuty × PWMperiod); int means integer part |
= | int(0.405 × 80) | |
= | int(32.4) | |
EPWM_CMPA register value | = | 32 (20h) |
Step 2: Fractional value conversion for HRPWM_CMPAHR register
HRPWM_CMPAHR register value | = | (frac(PWMDuty × PWMperiod) × MEP_SF) << 8) + 180h; frac means fractional part |
= | (frac(32.4) × 55 <<8) + 180h; Shift is to move the value as CMPAHR high byte | |
= | ((0.4 × 55) <<8) + 180h | |
= | (22 <<8) + 180h | |
= | 22 × 256 + 180h ; Shifting left by 8 is the same multiplying by 256. | |
= | 5632 + 180h | |
= | 1600h + 180h | |
HRPWM_CMPAHR value | = | 1780h; HRPWM_CMPAHR value = 1700h, lower 8 bits will be ignored by hardware. |
In high resolution mode, the MEP is not active for 100% of the PWM period. It becomes operational 3 SYSCLKOUT cycles after the period starts.
Duty cycle range limitations are illustrated in Figure 29-51. This limitation imposes a lower duty cycle limit on the MEP. For example, precision edge control is not available all the way down to 0% duty cycle. Although for the first 3 or 6 cycles, the HRPWM capabilities are not available, regular PWM duty control is still fully operational down to 0% duty. In most applications this should not be an issue as the controller regulation point is usually not designed to be close to 0% duty cycle.
If the application demands HRPWM operation in the low percent duty cycle region, then the HRPWM can be configured to operate in count-down mode with the rising edge position (REP) controlled by the MEP. This is illustrated in Figure 29-52. In this case low percent duty limitation is no longer an issue.
The Table 29-48 lists the groups of ePWM and the high-resolution PWM module registers according to their functionalities.
Register Name | Offset | Size (×16) | Shadow | Register Description |
---|---|---|---|---|
Time-Base Submodule Registers | ||||
EPWM_TBCTL | 0h | 1 | No | Time-Base Control Register |
EPWM_TBSTS | 2h | 1 | No | Time-Base Status Register |
EPWM_TBPHS | 6h | 1 | No | Time-Base Phase Register |
EPWM_TBCNT | 8h | 1 | No | Time-Base Counter Register |
EPWM_TBPRD | Ah | 1 | Yes | Time-Base Period Register |
Counter-Compare Submodule Registers | ||||
EPWM_CMPCTL | Eh | 1 | No | Counter-Compare Control Register |
EPWM_CMPA | 12h | 1 | Yes | Counter-Compare A Register |
EPWM_CMPB | 14h | 1 | Yes | Counter-Compare B Register |
Action-Qualifier Submodule Registers | ||||
EPWM_AQCTLA | 16h | 1 | No | Action-Qualifier Control Register for Output A (EPWMxA) |
EPWM_AQCTLB | 18h | 1 | No | Action-Qualifier Control Register for Output B (EPWMxB) |
EPWM_AQSFRC | 1Ah | 1 | No | Action-Qualifier Software Force Register |
EPWM_AQCSFRC | 1Ch | 1 | Yes | Action-Qualifier Continuous S/W Force Register Set |
Dead-Band Generator Submodule Registers | ||||
EPWM_DBCTL | 1Eh | 1 | No | Dead-Band Generator Control Register |
EPWM_DBRED | 20h | 1 | No | Dead-Band Generator Rising Edge Delay Count Register |
EPWM_DBFED | 22h | 1 | No | Dead-Band Generator Falling Edge Delay Count Register |
Trip-Zone Submodule Registers | ||||
EPWM_TZSEL | 24h | 1 | No | Trip-Zone Select Register |
EPWM_TZCTL | 28h | 1 | No | Trip-Zone Control Register |
EPWM_TZEINT | 2Ah | 1 | No | Trip-Zone Enable Interrupt Register |
EPWM_TZFLG | 2Ch | 1 | No | Trip-Zone Flag Register |
EPWM_TZCLR | 2Eh | 1 | No | Trip-Zone Clear Register |
EPWM_TZFRC | 30h | 1 | No | Trip-Zone Force Register |
Event-Trigger Submodule Registers | ||||
EPWM_ETSEL | 32h | 1 | No | Event-Trigger Selection Register |
EPWM_ETPS | 34h | 1 | No | Event-Trigger Pre-Scale Register |
EPWM_ETFLG | 36h | 1 | No | Event-Trigger Flag Register |
EPWM_ETCLR | 38h | 1 | No | Event-Trigger Clear Register |
EPWM_ETFRC | 3Ah | 1 | No | Event-Trigger Force Register |
PWM-Chopper Submodule Registers | ||||
EPWM_PCCTL | 3Ch | 1 | No | PWM-Chopper Control Register |
High-Resolution PWM (HRPWM) Submodule Registers | ||||
HRPWM_TBPHSHR | 4h | 1 | No | Extension for HRPWM Phase Register |
HRPWM_CMPAHR | 10h | 1 | No | Extension for HRPWM Counter-Compare A Register |
HRPWM_HRCTL | 40h | 1 | No | HRPWM Control Register |
This section provides description of the device PWMSS ePWM and High Resolution-PWM relevant functional registers.
Module Name | Module Base Address L4_PER2 Interconnect | Size (Bytes) |
---|---|---|
PWMSS1_EPWM | 0x4843 E200 | 136 Bytes |
PWMSS2_EPWM | 0x4844 0200 | 136 Bytes |
PWMSS3_EPWM | 0x4844 2200 | 136 Bytes |
Register Name | Type | Register Width (Bits) | Address Offset | PWMSS1_EPWM Physical Address L4_PER2 Interconnect | PWMSS2_EPWM Physical Address L4_PER2 Interconnect | PWMSS3_EPWM Physical Address L4_PER2 Interconnect |
---|---|---|---|---|---|---|
EPWM_TBCTL | RW | 16 | 0x0000 0000 | 0x4843 E200 | 0x4844 0200 | 0x4844 2200 |
EPWM_TBSTS | RW | 16 | 0x0000 0002 | 0x4843 E202 | 0x4844 0202 | 0x4844 2202 |
HRPWM_TBPHSHR | RW | 16 | 0x0000 0004 | 0x4843 E204 | 0x4844 0204 | 0x4844 2204 |
EPWM_TBPHS | RW | 16 | 0x0000 0006 | 0x4843 E206 | 0x4844 0206 | 0x4844 2206 |
EPWM_TBCNT | RW | 16 | 0x0000 0008 | 0x4843 E208 | 0x4844 0208 | 0x4844 2208 |
EPWM_TBPRD | RW | 16 | 0x0000 000A | 0x4843 E20A | 0x4844 020A | 0x4844 220A |
EPWM_CMPCTL | RW | 16 | 0x0000 000E | 0x4843 E20E | 0x4844 020E | 0x4844 220E |
HRPWM_CMPAHR | RW | 16 | 0x0000 0010 | 0x4843 E210 | 0x4844 0210 | 0x4844 2210 |
EPWM_CMPA | RW | 16 | 0x0000 0012 | 0x4843 E212 | 0x4844 0212 | 0x4844 2212 |
EPWM_CMPB | RW | 16 | 0x0000 0014 | 0x4843 E214 | 0x4844 0214 | 0x4844 2214 |
EPWM_AQCTLA | RW | 16 | 0x0000 0016 | 0x4843 E216 | 0x4844 0216 | 0x4844 2216 |
EPWM_AQCTLB | RW | 16 | 0x0000 0018 | 0x4843 E218 | 0x4844 0218 | 0x4844 2218 |
EPWM_AQSFRC | RW | 16 | 0x0000 001A | 0x4843 E21A | 0x4844 021A | 0x4844 221A |
EPWM_AQCSFRC | RW | 16 | 0x0000 001C | 0x4843 E21C | 0x4844 021C | 0x4844 221C |
EPWM_DBCTL | RW | 16 | 0x0000 001E | 0x4843 E21E | 0x4844 021E | 0x4844 221E |
EPWM_DBRED | RW | 16 | 0x0000 0020 | 0x4843 E220 | 0x4844 0220 | 0x4844 2220 |
EPWM_DBFED | RW | 16 | 0x0000 0022 | 0x4843 E222 | 0x4844 0222 | 0x4844 2222 |
EPWM_TZSEL | RW | 16 | 0x0000 0024 | 0x4843 E224 | 0x4844 0224 | 0x4844 2224 |
EPWM_TZCTL | RW | 16 | 0x0000 0028 | 0x4843 E228 | 0x4844 0228 | 0x4844 2228 |
EPWM_TZEINT | RW | 16 | 0x0000 002A | 0x4843 E22A | 0x4844 022A | 0x4844 222A |
EPWM_TZFLG | R | 16 | 0x0000 002C | 0x4843 E22C | 0x4844 022C | 0x4844 222C |
EPWM_TZCLR | RW | 16 | 0x0000 002E | 0x4843 E22E | 0x4844 022E | 0x4844 222E |
EPWM_TZFRC | RW | 16 | 0x0000 0030 | 0x4843 E230 | 0x4844 0230 | 0x4844 2230 |
EPWM_ETSEL | RW | 16 | 0x0000 0032 | 0x4843 E232 | 0x4844 0232 | 0x4844 2232 |
EPWM_ETPS | RW | 16 | 0x0000 0034 | 0x4843 E234 | 0x4844 0234 | 0x4844 2234 |
EPWM_ETFLG | R | 16 | 0x0000 0036 | 0x4843 E236 | 0x4844 0236 | 0x4844 2236 |
EPWM_ETCLR | RW | 16 | 0x0000 0038 | 0x4843 E238 | 0x4844 0238 | 0x4844 2238 |
EPWM_ETFRC | RW | 16 | 0x0000 003A | 0x4843 E23A | 0x4844 023A | 0x4844 223A |
EPWM_PCCTL | RW | 16 | 0x0000 003C | 0x4843 E23C | 0x4844 023C | 0x4844 223C |
HRPWM_HRCTL | RW | 16 | 0x0000 00C0 | 0x4843 E2C0 | 0x4844 02C0 | 0x4844 22C0 |
Address Offset | 0x0000 0000 | ||
Physical Address | 0x4843 E200 0x4844 0200 0x4844 2200 | Instance | PWMSS1_EPWM PWMSS2_EPWM PWMSS3_EPWM |
Description | |||
Type | RW |
15 | 14 | 13 | 12 | 11 | 10 | 9 | 8 | 7 | 6 | 5 | 4 | 3 | <