下面是LLC中更新Period值得一段代码:
PWMDRV_LLC_ComplPairDB .macro n
;=============================
MOVW DP, #_PWMDRV_LLC_ComplPairDB_Duty:n: ; load DP for net pointer
MOVL XAR0, @_PWMDRV_LLC_ComplPairDB_Duty:n: ; Load net pointer address to XAR0
MOVL XAR1, @_PWMDRV_LLC_ComplPairDB_Period:n: ; Load net pointer address to XAR0
MOVL ACC, *XAR1
SFR ACC, #14 ; ACC>>14: AL = Period (Q10)
MOVW DP, #_EPwm:n:Regs.TBPRD
MOV @_EPwm:n:Regs.TBPRD, AL ; Update period register
问:这里_EPwm:n:Regs.TBPRD是上一步骤的AL 为Q10,为什么下面都注释成I16Q16了呢?
MOVL XT, @_EPwm:n:Regs.TBPRD
QMPYL ACC, XT, *XAR0 ; ACC = (I16Q16) * (I8Q24) = (I24Q40): upper 32-bits -> ACC = (I24Q8)
SFR ACC, #8 ; ACC>>8: AL = Duty*Period (Q16)
问:ACC=(I24Q8),经过SFR指令右移8位后为什么AL还是Q16????
MOVW DP, #_EPwm:n:Regs.CMPA
MOV @_EPwm:n:Regs.CMPA.half.CMPA, AL ; Update CMPA
ROR ACC
MOVW DP, #_EPwm:n:Regs.CMPB
MOV @_EPwm:n:Regs.CMPB, AL ; Update CMPB = Duty cycle midpoint
.endm
Seven Han:看下文档TMS320C28x CPU and Instruction Set reference guide:www.ti.com/…/spru430f.pdf
下面是LLC中更新Period值得一段代码:
PWMDRV_LLC_ComplPairDB .macro n
;=============================
MOVW DP, #_PWMDRV_LLC_ComplPairDB_Duty:n: ; load DP for net pointer
MOVL XAR0, @_PWMDRV_LLC_ComplPairDB_Duty:n: ; Load net pointer address to XAR0
MOVL XAR1, @_PWMDRV_LLC_ComplPairDB_Period:n: ; Load net pointer address to XAR0
MOVL ACC, *XAR1
SFR ACC, #14 ; ACC>>14: AL = Period (Q10)
MOVW DP, #_EPwm:n:Regs.TBPRD
MOV @_EPwm:n:Regs.TBPRD, AL ; Update period register
问:这里_EPwm:n:Regs.TBPRD是上一步骤的AL 为Q10,为什么下面都注释成I16Q16了呢?
MOVL XT, @_EPwm:n:Regs.TBPRD
QMPYL ACC, XT, *XAR0 ; ACC = (I16Q16) * (I8Q24) = (I24Q40): upper 32-bits -> ACC = (I24Q8)
SFR ACC, #8 ; ACC>>8: AL = Duty*Period (Q16)
问:ACC=(I24Q8),经过SFR指令右移8位后为什么AL还是Q16????
MOVW DP, #_EPwm:n:Regs.CMPA
MOV @_EPwm:n:Regs.CMPA.half.CMPA, AL ; Update CMPA
ROR ACC
MOVW DP, #_EPwm:n:Regs.CMPB
MOV @_EPwm:n:Regs.CMPB, AL ; Update CMPB = Duty cycle midpoint
.endm
user5089339:
回复 Seven Han:
我就是看过了,按照文档上的在这里解释不了啊