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
EPWM1_BASE .set 0x6800
CMPAHR1 .set EPWM1_BASE+0x8
;===============================================
HRBUCK_DRV; (can execute within an ISR or loop)
;===============================================
MOVW DP, #_HRBUCK_In
MOVL XAR2,@_HRBUCK_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
MPYU ACC,T,@_hrbuck_period ; Q15 to Q0 scaling based on Period
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, #0x080 ; 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