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 SFO_v8 library init problem

Part Number: TMS320F28379D
Other Parts Discussed in Thread: LAUNCHXL-F28379D, C2000WARE

Tool/software: Code Composer Studio

Godd morning.

I'm adding HRPWM capabilities to "pfc3phvienna_nonpowerSUITE_F2837x" project running it on LAUNCHXL-F28379D.

I'm quite in trouble wirth the SFO library initialization.

I added a debug counter to check SFO enties on init loop (see below).

sfo_status = SFO_INCOMPLETE;

    // Calling SFO() updates the HRMSTEP register with calibrated MEP_ScaleFactor.
    // HRMSTEP must be populated with a scale factor value prior to enabling
    // high resolution period control.
    while(sfo_status == SFO_INCOMPLETE) // Call until complete
    {
        debug_cnt++;
        sfo_status = SFO();
        if (sfo_status == SFO_ERROR)
        {
            error();    // SFO function returns 2 if an error occurs & # of MEP
        }               // steps/coarse step exceeds maximum of 255.
    }


Running it in "hrpwm_deadband_sfo_cpu01" project, SFO() is runned 3143 times, MEP_ScaleFactor and HRMSTEP are set to 0x003E. (reasonable 62 steps)

Running it in "pfc3phvienna_nonpowerSUITE_F2837x" project, SFO() is runned 6 times, MEP_ScaleFactor is set to 0x8000 and HRMSTEP is set to 0x0000 (not so reasonable).

I add SFO() init loop immediately after "setupDevice();" line in main. 

Project is in FLASH configuration with SFO added to "ramfuncs".

I suppose there is something wrong in my initialization but I can't fix it.

I hope that someone can help.

Best regards,

Giovanni

  • Hi,

    Please let me know how are you adding the SFO to ramfuncs. Also, check in linker cmd file if it is getting allocated to desired memory location.

    Thanks

    Vasudha

  • Hi,

    I tried to rawly add

    #pragma CODE_SECTION(SFO,"ramfuncs");
    

    in SFO_V8.h

    Looking at .map file, it's clear that this trick does not work. "ramfuncs" block size does not change commenting the line.

    Maybe this will be the point? I'm not sure about it.

    Thanks

  • Hi.

    I create a new RAM configuration with "2837x_RAM_lnk_cpu1.cmd"  file.

    Now ALL the code is running from RAM but the behaviour is exactly the same.

    The problem seems to be somewhere in "setupDevice();" (something that needs to be powered on after first SFO() call?) but I really can't find it.

    Best regards,

    Giovanni

  • Hi,

    I tried adding the SFO code to the example mentioned above and could see the correct MEP scale factor value getting calculated. I used the default Flash configuration available with the pfcvienna example. Hence, the setupDevice() has no  relation with the above error.

    Is there any specific requirement to run the SFO code from RAM?  The method used above won't work as the SFO code is already compiled and added as lib in the project.

    Thanks

    Vasudha

  • Hi,

    To run SFO from RAM, make below changes in project linker command file.

       GROUP
       {
           .TI.ramfunc
           {
           }
           ramfuncs
           sfoLib
           {
             --library=SFO_v8_fpu_lib_build_c28_driverlib_coff.lib(.text)
           }
    
       } LOAD = FLASHD,
    	 RUN =  RAMGS0GS1,
    	 LOAD_START(_RamfuncsLoadStart),
    	 LOAD_SIZE(_RamfuncsLoadSize),
    	 LOAD_END(_RamfuncsLoadEnd),
    	 RUN_START(_RamfuncsRunStart),
    	 RUN_SIZE(_RamfuncsRunSize),
    	 RUN_END(_RamfuncsRunEnd),
    	 PAGE = 0, ALIGN(4)

    Thanks

    Vasudha

  • Thanks Vasudha.

    Your changes work correctly but there is no particular reason to run SFO  from RAM. It was just a try.

    I beleive that I have not imported SFO library correctly or something is missing for it.

    I got the same behaviour even switching off PWM counters...

    i.e. if I call SFO() before "setupDevice();" line, it does not return SFO_ERROR.

    Disassembly expansion of SFO() call looks correct.

    Any ideas?

    Thanks

    Giovanni

  • Hi,

    Which lib are you using for your project? The project uses driverlib. Please use the latest driverlib based SFO lib from latest C2000Ware package and try. PFB the location:

    C2000Ware_2_00_00_02\libraries\calibration\hrpwm\f2837xd\lib

    Thanks

    Vasudha

  • Thanks Vasudha.

    It works!

    As you suggested the problem was in library version or, better, in my C2000Ware version.

    In C2000Ware_1_00_06_00 there is only one SFO_v8_fpu_lib_build_c28.lib file that works only with bitfield.

    In C2000Ware_2_00_00_02 there is the are the two version (bitfield/driverlib).

    Now SFO() is called 2138 times and returns a HRMSTEP value of 62 (which is a reasonable one).

    Thanks again. Now I can attack HRPWM.

    Best regards

    Giovanni