SPRUIW9C October 2021 – March 2024 TMS320F280033 , TMS320F280034 , TMS320F280034-Q1 , TMS320F280036-Q1 , TMS320F280036C-Q1 , TMS320F280037 , TMS320F280037-Q1 , TMS320F280037C , TMS320F280037C-Q1 , TMS320F280038-Q1 , TMS320F280038C-Q1 , TMS320F280039 , TMS320F280039-Q1 , TMS320F280039C , TMS320F280039C-Q1
High-resolution period control using the MEP logic is supported on devices with a Type 1 ePWM module or greater.
The scaling procedure described for duty cycle in Section 20.15.1.5.2 applies for high-resolution period as well:
Assumptions for this example:
TBCLK | = 10ns (100MHz) |
Required PWM frequency | = 175kHz (period of 571.428) |
Number of MEP steps per coarse step at 180ps (10ns/180ps), (MEP_ScaleFactor) | = 55 |
Value to keep TBPRDHR within range of 1-255 and fractional rounding constant (default value) | = 0.5 (0080h in Q8 format) |
Problem:
In up-count mode:
In up-down count mode:
Solution:
With 55 MEP steps per coarse step at 180ps each:
Step 1: Percentage Integer Period value conversion for TBPRD register
Integer period value | = 571 * TTBCLK | |
= int (571.428) * TTBCLK | ||
= int (PWMperiod) * TTBCLK | ||
In up-count mode: | ||
TBPRD | = 570 (TBPRD = period value - 1) | |
= 023Ah | ||
In up-down count mode: | = 285 (TBPRD = period value/2) | |
TBPRD | = 011Dh |
Step 2: Fractional value conversion for TBPRDHR register
In up-count mode:TBPRDHR register value | = (frac(PWMperiod) * MEP_ScaleFactor + 0.5) |
If auto-conversion enabled and HRMSTEP = | |
MEP_ScaleFactor value (55): | = frac (PWMperiod) << 8 (Shifting is to move the value to the high byte of TBPRDHR) |
TBPRDHR register value | = frac (571.428) << 8 |
= 0.428 × 256 | |
= 6D00h | |
The auto-conversion then automatically performs the calculation, such that TBPRDHR MEP delay is scaled by hardware to: | = ((TBPRDHR(15:0) >> 8) × HRMSTEP + 80h) << 8 |
= (006Dh × 55 + 80h) >> 8 | |
= (17EBh) >> 8 | |
Period MEP delay | = 0017h MEP Steps |
TBPRDHR register value | = (frac(PWMperiod) * MEP_ScaleFactor + 0.5) |
If auto-conversion enabled and HRMSTEP = | |
MEP_ScaleFactor value (55): | = frac (PWMperiod / 2) << 8 (Shifting is to move the value to the high byte of TBPRDHR) |
TBPRDHR register value | = frac (285.714) << 8 |
= 0.714 × 256 | |
= B600h | |
The auto-conversion then automatically performs the calculation, such that TBPRDHR MEP delay is scaled by hardware to: | = ((TBPRDHR(15:0) >> 8) × HRMSTEP + 80h) << 8 |
= (00B6h × 55 + 80h) >> 8 | |
= (279Ah) >> 8 | |
Period MEP delay | = 0027h MEP Steps |