www.ti.com
Operational Description of HRPWM
345
SPRUI07–March 2020
Submit Documentation Feedback
Copyright © 2020, Texas Instruments Incorporated
High-Resolution Pulse Width Modulator (HRPWM)
Example 4-9 shows an assembly example of run-time code that can execute in a high-speed ISR loop.
Example 4-9. PWM DAC Function Run-Time Code
EPWM1_BASE .set 0x6800
CMPAHR1 .set EPWM1_BASE+0x8
;=================================================
HRPWM_DAC_DRV; (can execute within an ISR or loop)
;=================================================
MOVW DP, #_HRDAC_In
MOVL XAR2,@_HRDAC_In ; Pointer to input Q15 duty (XAR2)
MOVL XAR3,#CMPAHR1 ; Pointer to HRPWM CMPA reg (XAR3)
; Output for EPWM1A (HRPWM)
MOV T,*XAR2 ; T <= duty
MPY ACC,T,@_hrDAC_period ; Q15 to Q0 scaling based on period
ADD ACC,@_HrDAC_period<<15 ; Offset for bipolar operation
MOV T,@_MEP_ScaleFactor ; MEP scale factor (from optimizer s/w)
MPYU P,T,@AL ; P <= T * AL, optimizer scaling
MOVH @AL,P ; AL <= P, move result back to ACC
ADD ACC, #0x180 ; MEP range and rounding adjustment
MOVL *XAR3,ACC ; CMPA:CMPAHR(31:8) <= ACC
; Output for EPWM1B (Regular Res) Optional - for comparison purpose only
MOV *+XAR3[2],AH ; Store ACCH to regular CMPB