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.

SFO() Issue

Other Parts Discussed in Thread: TMS320F28027

Hello everybody,

i'm trying to get SFO() function working but without an success. The code is running on C2000 LaunchPad XL with TMS320F28027. 

My code is as simple as this:

---

main () {
while (1){
int status, x;
status = SFO_INCOMPLETE;
while (status==SFO_INCOMPLETE) {
status = SFO();
}
if(status!=SFO_ERROR) { // IF SFO() is complete with no errors
EALLOW;
EPwm1Regs.HRMSTEP=MEP_ScaleFactor;
EDIS;
}
}
}
---

The problem is in that SFO() function don't return anything else than 0 and 2 so it can't update HRMSTEPS. I have tried both version of LIB file, standard and "b" version, the same issue. Other header files are included correctly, compilation pass without an problem.

I put some break-points in code and observe all relevant vars from this code. Most of time, looping is done in first "while" statement then exit that loop and skip next "if" branch, because return status was "2".

Also tried similar code in other program, same problem.
What can be an problem here? Maybe some clock configuration (tried 50MHz and 60MHz)?

Thank You in advance.

  • I have attached an example for SFO() at the 28069 (90MHz).The SFO-function itself will store the new scale factor in register EPWM1.HRMSTEP, no need to do it yourself. I am not sure why your code returns 2 instead of 1.  Did you enable the PWM-clocks before you call SFO()?

     

     

  • I can't find the cause for such behaviors.

    In other example/code I have tried, I have proper PWM (HRPWM) initialization code before SFO() call and PWM itself generates correct output signals.

    The main problem is in that SFO() function returns "2" which is an error state. In some examples I observed, if that state reach "2", usually program is instructed to STOP processor!?

    As I understand the documentation correct, this function need to return something > 2, some "measured" calibration value, but I can't get that.

    If someone can post files of some working example for CCS5.x will be great. I can try that code to see does it will work. Maybe I making somewhere other type of misconfiguration which leads to this problem. 

    I'm "new" to TI MCU platforms, have some experience with other MCUs. 

  • Alex,

    when I run my example from my previous post, the "do{...}while(status==0)" is left with status = 1. I never get status = 2. So I guess there is something wrong with your initialization of the PWM. Did you enable the HRPWMENCLK - bit in PCLKCR0? When I intentionally remove this enable instruction from my code (in InitSysCtrl()), I also get status =2.

  • I got somehow SFO() working from Example_2802xHRPWM_PrdUpDown_SFO_V6.

    The similar problem was here:
    http://e2e.ti.com/support/microcontrollers/c2000/f/171/p/229662/807606.aspx#807606

    I didn't find the exact cause for such behavior, probably somewhere in my project configuration.

    Maybe I chose the most complicated module in Piccolo - HRPWM for my first project, but because of that PWM I have choose this MCU ;)

    Anyway, I have observed  MEP_ScaleFactor and it really change over time, mostly regarding IC temperature, when temperature rise this register have smaller value, not too much, about 2-3-4 steps agains large temperature change (30 ~ 80 ℃). 

  • hello

    I'm having the same problem,
    Have you solved this problem?
    If you have resolved to help me, please
    Thank you.

  • hi,Aleksandar Markovic。

    first,make sure epwm1 is running as you  set。then,debug your code one by one step to see the result of SFO()。

    if you still get status with “2”,l suggest you can do your SFO() in epwm1 interrupt code。