请问下
论坛的高手们一些问题:
源代码(官方无桥PFC例程)的一段
PFC_BL_ICMD .macro n
;=============================
MOVW DP, #_PFC_BL_ICMD_Vcmd:n:
MOVL XAR0,@_PFC_BL_ICMD_VinvSqr:n: ; Net pointer to VinvSqr (XAR0)
MOVL XAR1,@_PFC_BL_ICMD_VacRect:n: ; Net pointer to VacRect (XAR1)
MOVL XAR2,@_PFC_BL_ICMD_Vcmd:n: ; Net pointer to Vcmd (XAR2)
MOVL XAR3,@_PFC_BL_ICMD_Out:n:
MOVL XAR4,@_PFC_BL_ICMD_Vpfc:n:
MOVL XAR5,@_PFC_BL_ICMD_Duty:n:
MOVL XT,*XAR0 ; XT = VinvSqr Q24
QMPYL ACC,XT,*XAR1 ; ACC = VinvSqr * VacRect = Q24* Q24 = I16Q48
LSL ACC,#8 ; ACC = I8Q24
MOVL XT,@ACC ; XT = VinvSqr * VacRect (Q24)
QMPYL ACC,XT,*XAR2 ; ACC = VinvSqr * VacRect * Vcmd
LSL ACC,#8 ; ACC = I8Q24
MOVL XT,@ACC ; XT = VacRect * VinvSqr * Vcmd
QMPYL ACC,XT,@_PFC_BL_ICMD_VmaxOverVmin:n: ; ACC = VacRect * VinvSqr * Vcmd * VmaxOverVmin
LSL ACC,#8 ; ACC = Q24
MOVL *XAR3,ACC ; Store result in output pointer loca
tion
;;===============================================
; set terminal pointer to ZeroNet
MOVL XAR2, #ZeroNet
MOVW DP, #_PWMDRV_1ch_UpDwnCnt_Duty:n:
MOVL @_PWMDRV_1ch_UpDwnCnt_Duty:n:, XAR2
MOVW DP,#_EPwm:n:Regs.TBPRD
MOVL ACC,@_EPwm:n:Regs.TBPRD
MOV AL,#0
MOVW DP, #_PWMDRV_1ch_UpDwnCnt_Duty:n:
MOVL @_PWMDRV_1ch_UpDwnCnt_Period:n:,ACC
.endm
PWMDRV_1ch_UpDwnCnt .macro n
;=============================
MOVW DP, #_PWMDRV_1ch_UpDwnCnt_Duty:n: ; load DP for net pointer
MOVL XAR0, @_PWMDRV_1ch_UpDwnCnt_Duty:n: ; Load net pointer address to XAR0
MOVL XT,@_PWMDRV_1ch_UpDwnCnt_Period:n:
QMPYL ACC,XT,*XAR0 ; ACC= (I8Q24) * (I16Q16) = (I24Q40): upper 32-bits -> ACC = (I24Q8)
SFR ACC,#8 ; ACC>>8: AL = duty,
MOVW DP,#_EPwm:n:Regs.CMPA
MOV @_EPwm:n:Regs.CMPA.half.CMPA,AL
.endm
例程结束。
问题:请问下这句QMPYL ACC,XT,*XAR1 ; ACC = VinvSqr * VacRect = Q24* Q24 = I16Q48
Q24*Q24为什么 ==I16*Q48 I18什么意思呢?
LSL ACC,#8 ; ACC = I8Q24 为什么逻辑左移8位又变成了I8Q24呢?
QMPYL ACC,XT,*XAR0 ; ACC= (I8Q24) * (I16Q16) = (I24Q40): upper 32-bits -> ACC = (I24Q8)
我们知道XT就是存放的周期值(300),而XAR0是Q24的占空比值,结果(周期*占空比为占空比真实值)为啥是I8Q24 * I16Q16呢??
还有这这段:
MOVW DP,#_EPwm:n:Regs.TBPRD
MOVL ACC,@_EPwm:n:Regs.TBPRD
MOV AL,#0
MOVW DP, #_PWMDRV_1ch_UpDwnCnt_Duty:n:
MOVL @_PWMDRV_1ch_UpDwnCnt_Period:n:,ACC
MOVL是移动32位数据,而_EPwm:n:Regs.TBPRD 是16位寄存器,那MOVL ACC,@_EPwm:n:Regs.TBPRD意思就是16位寄存器的值放到
32位的ACC里,是高16位补0吗?但看后面有句话MOV AL,#0 把低16位清0了,那前面这句话都没意义了。所以应该是低16位补0,对吗?