To use high-resolution period, the ePWMx module must be initialized in the exact order presented.
The following steps use CMPA with shadow registers and the corresponding HRCNFG bits for high-resolution operation on EPWMxA. For high-resolution operation on EPWMxB, make the appropriate substitutions with the B channel fields.
- Enable ePWMx clock
- Enable HRPWM clock
- Disable TBCLKSYNC
- Configure ePWMx registers - AQ, TBPRD, CC, and so on.
- ePWMx can only be configured for up-count or up-down count modes. High-resolution period is not compatible with down-count mode.
- TBPRD and CC registers must be configured for shadow loads.
- CMPCTL[LOADAMODE]
- In up-count mode: CMPCTL[LOADAMODE] = 1 (load on CTR = PRD)
- In up-down count mode: CMPCTL[LOADAMODE] = 2 (load on CTR=0 or CTR=PRD)
- Configure the HRCNFG register such that:
- HRCNFG[HRLOAD] = 2 (load on either CTR = 0 or CTR = PRD)
- HRCNFG[AUTOCONV] = 1 (Enable auto-conversion)
- HRCNFG[EDGMODE] = 3 (MEP control on both edges)
- For TBPHS:TBPHSHR synchronization with high-resolution period, set both HRPCTL[TBPSHRLOADE] = 1 and TBCTL[PHSEN] = 1. In up-down count mode these bits must be set to 1 regardless of the contents of TBPHSHR.
- Enable high-resolution period control (HRPCTL[HRPE] = 1)
- Enable TBCLKSYNC
- TBCTL[SWFSYNC] = 1
- HRMSTEP must contain an accurate MEP scale factor (# of MEP steps per EPWMCLK coarse step) because auto-conversion is enabled. The MEP scale factor can be acquired using the SFO() function described in Section 13.15.2.
- To control high-resolution period, write to the TBPRDHR(M) registers.
Note:
When high-resolution period mode is enabled, an EPWMxSYNC pulse introduces ±1-2 cycle jitter to the PWM (±1 cycle in up-count mode and ±2 cycle in up-down count mode). For this reason, EPWMxSYNCO source cannot be set to CTR = 0 or CTR = CMPB. Otherwise, the jitter occurs on every PWM cycle with the synchronization pulse.
When EPWMxSYNCI is EPWMxSYNCO source, a software synchronization pulse can be issued only once during high-resolution period initialization. If a software sync pulse is applied while the PWM is running, the jitter appears on the PWM output at the time of the sync pulse.