This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

HV_Solar_DC_DC,Some assembler functions don't understand

Hi,

In the PWMDRV_1ch_UpDwnCnt.asm file,the following code:

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

 

; end of file

 1. I don't understand the above code, can you explain in detail the process and reason of each step of code execution?

 2. Variable AL didn't find a place to define.

thank you very much!

 

Regards,

 

Ren

  • This is pretty much explained with the comments associated with the code. It seems like you will need to review some material on Assembly Language Programming if you are not familiar with it. I will try to explain a little more than what is already there. After that if you still need help please review some material on Assembly language programming.

    Shamim

    MOVW DP, #_PWMDRV_1ch_UpDwnCnt_Duty:n:   ; load data page (DP ) for net pointer

    MOVL    XAR0, @_PWMDRV_1ch_UpDwnCnt_Duty:n: ; Load net pointer address to XAR0. This will cause the address of the variable (that has the Duty info) be loaded into XAR0.

    MOVL     XT,@_PWMDRV_1ch_UpDwnCnt_Period:n:; PWM period loaded to XT register

    QMPYL ACC,XT,*XAR0 ; ACC= (I8Q24) * (I16Q16) = (I24Q40): upper 32-bits -> ACC = (I24Q8) ; This will multiply period with duty and store the result in ACC.                        

    SFR ACC,#8     ; ACC>>8: AL = duty,  ; Save duty to ACC. ACC lower 8 bit (AL) will have the duty value

          

    MOVW DP,#_EPwm:n:Regs.CMPA

    MOV     @_EPwm:n:Regs.CMPA.half.CMPA,AL; Now move duty from AL to Compare A register.