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.

TMS320F28027: HVLLC code questions

Part Number: TMS320F28027


Hi,

my customer is testing the board TMDSHVRESLLCKIT.

PWMDRV_LLC_1ch_UpCntDB_Comp.asm code is as below:

;=============================
PWMDRV_LLC_1ch_UpCntDB_Compl .macro
;=============================
MOVW DP, #_PWMDRV_LLC_1ch_UpCntDB_Compl_Duty2 ; load DP for net pointer
MOVL XAR0, @_PWMDRV_LLC_1ch_UpCntDB_Compl_Duty2 ; Load net pointer address to XAR0
MOVL XAR1, @_PWMDRV_LLC_1ch_UpCntDB_Compl_Period2 ; Load net pointer address to XAR1

MOVL ACC, *XAR1
SFR ACC, #14 ; ACC>>14: AL = Period (Q10)
MOVW DP, #_EPwm2Regs.TBPRD
MOV @_EPwm2Regs.TBPRD, AL ; Update period register

MOVL XT, @_EPwm2Regs.TBPRD ; 注意这里是MOVL指令,即XT=TBPRD<<16
QMPYL ACC, XT, *XAR0 ; ACC = (I16Q16) * (I8Q24) = (I24Q40): upper 32-bits -> ACC = (I24Q8) 
SFR ACC, #8 ; ACC>>8: AL = Duty*Period (Q16)
SUB @T, AL ; T = Period - Duty*Period

MOVW DP, #_EPwm2Regs.CMPA
MOV @_EPwm2Regs.CMPA.half.CMPA, T ; Update CMPA

ROR ACC ; AL = Duty*Period/2
SUB ACC, #13 ; compensate for 1st sample bug
ADD @T, AL

MOVW DP, #_EPwm2Regs.CMPB
MOV @_EPwm2Regs.CMPB, T ; Update CMPB = Duty midpoint

MOVL ACC, *XAR1
SFR ACC, #14 ; ACC>>14: AL = Period (Q10)
MOVW DP, #_EPwm2Regs.DBFED 
SUB AL, @_EPwm2Regs.DBFED ; use FED value to create Falling Edge Margin (advance falling edge)
MOVW DP, #_EPwm2Regs.TBPRD
MOV @_EPwm2Regs.TBPRD, AL ; Update period register (with FEM)

.endm

The question is:

1. Why there is no "EALLOW" when writing to registers such as EPwm2Regs.TBPRD? And by single step with CCS3.3, EPwm2Regs.TBPRD is not updated

2. Is "CMPB= 0.5*period*duty-13+period-duty*period=period-0.5*period*duty-13", in the comment it's said that 13 is compensated for 1st sample bug, what's sample bug, and why it's 13?

  • Hi Howard,

    Please see my answers below.

    1. Why there is no "EALLOW" when writing to registers such as EPwm2Regs.TBPRD? And by single step with CCS3.3, EPwm2Regs.TBPRD is not updated

    HN: This is simply because TBPRD register is not EALLOW write protected. This information can be found in the user guide.

    2. Is "CMPB= 0.5*period*duty-13+period-duty*period=period-0.5*period*duty-13", in the comment it's said that 13 is compensated for 1st sample bug, what's sample bug, and why it's 13?

    HN: This was needed for some initial Silicon of these devices (Rev A). Briefly, this ADC bug caused the first conversion result in a sequence of back-to-back ADC conversions to be less reliable. The solution was to have a dummy conversion first (incurring the extra 13 cycles) and then converting the required channel, which provides reliable ADC conversion result.

    I hope this helps.

    Hrishi