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.

How to update duty of HRPWM with assembly code?

Other Parts Discussed in Thread: CONTROLSUITE

Hi,

I have a switching frequency of 500 kHz on the DC/DC converter and the DSP is a f28335 running at 150 MHz. Due to the high switching frequency I have problems with doing all the calculations needed during one period.

So if I could change how the calculations to the HRPWM register is made from C to Assembly I could save some time, I think.

There is an example in the pdf http://www.ti.com/lit/ug/sprug02b/sprug02b.pdf  (see below), which uses assembly code to calculate and update the registers but I don't know how to implement this.

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, #0x180 ; 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

So again, how could you create a callable asm file which have a Duty cycle, D, as input and then updates the PWM and HRPWM register with the least amount of operations.

Thanks in advance // Johan

  • Johan,

    The following doc details how to create a C callable assembly function quickly

    http://www.ti.com/lit/an/spra806/spra806.pdf

    Just for your information the issue that you are having is a common one for high frequency converters, therefore most of our application kits use assembly ISRs. 

    We have a Digital Power Library that uses a framework for assembly ISRs and uses macros etc, it is available through controlSUITE

  • Thanks for the reply Manish:)

    Have taken a look into DP Library, but since I'm not used to either C or Assembly I'm having some problems understanding how to use/call all the files properly.

    Does there exist any examples (Allready completed ones) that utilises the DP library, which I can have a look at and maybe understand how it works?

  • Johan,

    There are several system examples like PFC which uses interleaved boost, PSFB, digital lighting control etc that use this digital power library. The kits and relevant documentation to understand the workings is available under  controlSUITE.

    Use the update manager to install the kit software and then find the code under /developement_kits/ .. in the controlSUITE directory

    also was the documentation for the digital power library not sufficient? the docs are found at 

    controlSUITE\libs\app_libs\digital_power\f2803x_v3.3\Doc