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.

TMS320F28388D: error() in HRPWM example.

Part Number: TMS320F28388D
Other Parts Discussed in Thread: C2000WARE

Hello,  Experts

The function error() in HRPWM examples in C2000Ware is not clear to me.

What happens to the system when this function is executed if the PWM output is performing?

void error (void)

{

    ESTOP0;

}

 

Thank you for your help.

Best regards,

Wenjing

  • Hi Wenjing,

    If the number of MEP steps exceeds 255 then auto conversion may not function properly, hence the error function is present to halt the code.

    Please check the snippet below taken from example:

    //! with MEP_ScaleFactor value
    //! - returns 2 if error: MEP_ScaleFactor is greater than maximum value of 255
    //!   (Auto-conversion may not function properly under this condition)

    Hope this helps.

    Thanks,

    Aditya

  • What happens to the system when this function is executed if the PWM output is performing?

    If the CPU is halted, the TBCTL register has a bit [FREE_SOFT] based on which you can select the operation of PWM on CPU halt. You can set the bit as per your requirement.

  • Hi, Aditya,

     

    Thank you for reply.

     

    On page 2853 of TRM, it is said “the routine returns a 2 if there is an error, and the MEP_ScaleFactor is greater

    than the maximum 255 fine steps per coarse EPWMCLK cycle. In this case, the HRMSTEP register will

    maintain the last MEP scale factor value less than 256 for auto conversion.”

    Does is mean that Auto-conversion can still function with the last MEP scale factor value even if the routine returns an error as value 2.

    Thanks.

    Wenjing

  • Wenjing,

    The point is that the operation may not be as desired under that condition. Hence the error flag. You may want to stop the PWM if the error function is executed using the bits [TBCTL:FREE_SOFT]

    Aditya

  • Hi, Aditya

    Thank you for comments.

    I think your comments is for the case of error() is executed.

    Let me explain more.

    if I only read the status of SFO() and not call error() as follows.

    (So ESTOP0 should not be executed)

     

    {

    ret_s16 = 0;

    status = SFO(); // in background, MEP calibration module

                      // continuously updates MEP_ScaleFactor

      if (status == SFO_ERROR)

      {

         ret_s16 = -1;

      }

      return (ret_s16);

    }

     

    In this case, can auto-conversion still function with the last MEP scale factor value when status = SFO_ERROR?

  • Auto-conversion will still function in this case but may not give you the desired result. It may perform different than the expected behavior.

    MEP is expected to update according to multiple factors, but it may remain at the last value less than 256 which would not update. This may cause the HRPWM feature to not perform the way it is expected.

    Hope this helps. You may or may not see major issues, but the documented behavior may not be seen.

    Thanks,

    Aditya

  • Hi, Aditya

    Thank you for the detailed explaining.


    If I only read the status of SFO() and not call error(), when SFO error causes the HRPWM feature to not perform the way it is expected,
    will there be a PWM error with a width larger than the normal EPWM clock(EPWMCLK) period, or will there be a larger problem?

    You may or may not see major issues, but the documented behavior may not be seen.

    What does “the documented behavior” refer to?

    Thank you.

    Wenjing

  • Hi Wenjing,

    Let me chime in the hardware experts as well to provide a detailed insight on the documented vs non-documented behavior. Appreciate your patience.

    Aditya

  • SFO should never return an error code. What is the value returned from your SFO?

  • Hi, Nima

    As I asked befor,

    On page 2853 of TRM, it is said “the routine returns a 2 if there is an error, and the MEP_ScaleFactor is greater

    than the maximum 255 fine steps per coarse EPWMCLK cycle. In this case, the HRMSTEP register will

    maintain the last MEP scale factor value less than 256 for auto conversion.”

    It is said “the routine of SFO() returns a 2 if there is an error”

    In my project, I did not get this error as a value 2.

    What I want to know is if SFO() returns a value of 2, will it affect the performance of the PWM when PWM is gating?

    Thank you.

    Wenjing

  • What is the frequency of your ePWM? (your clock divider settings)

  • Hi, Nima

    I am using F28388D and the system clock is 200MHz.

    My project provides PWM output frequency from 200Hz to 2MHz.

    The EPWM clock divider setting is determined based on the PWM output frequency. So there are 3 cases for divider setting (TBCTL.bit.CLKDIV).

    • EPWM clock frequency is 200MHz (TBCTL.bit.CLKDIV = 0) for 1.6kHz - 2MHz PWM output
    • EPWM clock frequency is 100MHz (TBCTL.bit.CLKDIV = 1) for 0.8kHz - 1.6kHz PWM output
    • EPWM clock frequency is 5MHz (TBCTL.bit.CLKDIV = 4) for 0.2kHz – 0.8kHz PWM output

     

    Thank you.

    Wenjing

  • The HRPWM has a minimum frequency requirement. Are you sure you are not operating below the HRPWM minimum frequency?

  • Thank you for reminding.

    With HRPWM, I plan to run only the case TBCTL.bit.CLKDIV = 0 (1.6kHz - 2MHz PWM output) in up-down count.

    If the system clock is 200MHz, in my understanding, HRPWM can support the range of 1.6kHz - 2MHz PWM.

    If there is still other restrictions, I really appreciate your pointing out.

    For the original question, if SFO() returns a value 2, could you tell me if this will affect PWM gating?

     

    Thanks,

    Wenjing

  • There is a minimum HRPWM frequency that can be supported.

    You cant go below 60MHz.

    Nima

  • Hi, Nima

    Thank you for comments.

    My HRPWM clock frequency is 200MHz higher than 60MHz. I think HRPWM supports it.

    Sorry to keep bothering you, but could you please tell me if SFO() returns a value of 2 without executing ESTOP0, will it affect the PWM gating?

     

    Thanks,

    Wenjing

  • Well we need to see why you are getting the ERROR. That should not be occuring. Did you start from an HRPWM driverlib example?

    Nima

  • Thank you for reply.

    Actually I did NOT get this error.

    But since the error mentioned on page 2853 of TRM (see below),

    I have the concern that if it affect PWM gating in case of SFO() returns an error as a value 2.

    On page 2853 of TRM, it is said:

    • This routine returns a 1 when calibration is finished and a new scale factor has been calculated, or a 0 if
    calibration is still running. The routine returns a 2 if there is an error, and the MEP_ScaleFactor is greater
    than the maximum 255 fine steps per coarse EPWMCLK cycle. In this case, the HRMSTEP register will
    maintain the last MEP scale factor value less than 256 for auto conversion.

    Wenjing

  • Then yes you are okay to proceed.

  • Thank you very much.

    Wenjing