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.

CCS/TMS320F28379D: HRPWM phase-shift for non-integer TBPHS values

Part Number: TMS320F28379D

Tool/software: Code Composer Studio

Hello,

I am using matlab to generate hrpwm phase-shift code for delfino. I am having trouble with non-integer values of TBPHS. Actual phase-shift goes in the opposite direction for non integer values and a abrupt jump in phase-shift is observed at integer values. Here is an example. The generated C code is also given below.

TBPHS -> Phase-Shift(degree)

150         158.1
150.5      158.8
150.8      159.2
151         156.8
152         155.5

EPwm2Regs.TBPHS.bit.TBPHS = ICN_PFC_Controller_P.twodelta_Value;

/*-- Update TBPHSHR --*/
{
extern int MEP_ScaleFactor;
real_T TBPHSf = ICN_PFC_Controller_P.twodelta_Value;
TBPHSf -= EPwm2Regs.TBPHS.bit.TBPHS;
TBPHSf *=65536;
EPwm2Regs.TBPHS.bit.TBPHSHR = (uint16_T)TBPHSf;
}

  • Hi,

    The TBPHSHR configuration does not seem correct, the fractional part should be multipled by MEP_Scale Factor and to be written in 8-bit space instead of 16-bit space because last 8 bits of TBPHS register are reserved as shown in below figure. 

    So the configuration should be somewhat like :

    TBPHSf -= EPwm2Regs.TBPHS.bit.TBPHS;
    TBPHSf *=MEP_ScaleFactor;
    EPwm2Regs.TBPHS.bit.TBPHSHR = (uint16_T)(TBPHSf << 8);

    If my reply answers your question please click on "This resolved my issue" button located at the bottom of my post.

    Regards

    Himanshu

  • Himanshu,

    Thanks for your reply. I tried your recommended code snippet. I am getting the following compilation error.

    error: expression must have integral type. 

  • Hi,

    I just provided the pseudo code to explain the programming of High Resolution Phase register, you need to convert it into legitimate code based on your definitions of structures and variables.  Also I am guessing the compilation error results of because of performing left shift operation on the floating variable. Typecasting it should fix this if that's the case :

    EPwm2Regs.TBPHS.bit.TBPHSHR = (uint16_T)(((uint16_T)TBPHSf )<< 8);

    If my reply answers your question please click on "This resolved my issue" button located at the bottom of my post.

    Regards

    Himanshu