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.

TMS320F28379D: Variables in stack not updating after Device_cal() called

Part Number: TMS320F28379D
Other Parts Discussed in Thread: C2000WARE

I’m encountering an issue with my F2837xD microcontroller project in Code Composer Studio (CCS). Specifically, I’ve noticed that variables in the stack are not updating after calling the Device_cal() function.

I'm testing this with a variable I call "temp" placed before and after Device_cal(). The variable is only updated prior to Device_cal() but not after this function is called.  The variable is located in the stack RAMM1 memory location.

    test++;
#ifndef _FLASH
    //
    // Call Device_cal function when run using debugger
    // This function is called as part of the Boot code. The function is called
    // in the InitSysCtrl function since during debug time resets, the boot code
    // will not be executed and the gel script will reinitialize all the
    // registers and the calibrated values will be lost.
    Device_cal();
    test++;
#endif

I'm using C2000Ware 3.2.0.00 and Device_cal() is defined in F2837xD_Examples.h as the following:

#define Device_cal ((void (*)(void))((uintptr_t)0x070282))

I step through the assembly and it steps through with no issues and returns out of Device_cal() with no visible issues.  The SP remains at 0x0456 during before and after Device_cal() is called. 

If I comment out Device_cal, my variable temp can be updated.  I would like to keep this function in the code as it seems standard to all ti examples.  Do you have any suggestions on how to debug the fact that I can't write to a variabel on the stack after Device_cal() is executed?

  • Could you please try the most recent version of C2000ware (5.02)?

  • I upgraded my C2000Ware to 5.2.0.00 but I'm still observing the same issue.

  • Hi Ryan,

    Are you trying out any example from C2000Ware SDK or is it different one?

    Let me try out any bitfield example from my side and shall update on my findings.

    Thanks

    Aswin

  • Thanks for your quick response.  The code I'm using is a project that I've been working on for a long time now and not example code.  However, your suggestion to try out an example on your side encouraged me to look through relevant ti examples that can be used to easily reproduce the problem.  In doing so I found that examples such as buffdac_ex2_random called SysCtrl_deviceCal() from driverlib (\driverlib\f2837xd\driverlib) instead of Device_cal() directly.  The code in C2000Ware_3_02_00_00 driverlib SysCtrl_deviceCal() is as follows:

    static inline void
    SysCtl_deviceCal(void)
    {
        //
        // Save the core registers used by Device_cal function in the stack
        //
        asm(" PUSH ACC");
        asm(" PUSH DP");
        asm(" PUSH XAR0");
        asm(" PUSH XAR2");
        asm(" PUSH XAR3");
        asm(" PUSH XAR4");
        asm(" PUSH XAR5");
    
        //
        // Call the Device_cal function
        //
        Device_cal();
    
        //
        // Restore the core registers
        //
        asm(" POP XAR5");
        asm(" POP XAR4");
        asm(" POP XAR3");
        asm(" POP XAR2");
        asm(" POP XAR0");
        asm(" POP DP");
        asm(" POP ACC");
    }

    Later C2000Ware versions similarly save/restore core registers with the asm PUSH/POP instructions.  

    I've added these asm PUSH/POP instructions to my code and it seems to allow my "test" variable to appropriately updated along with other local variables on the stack after Device_cal() is called.  I haven't done extensive testing yet but initial results look promising.  I'll continue testing and report back.  Any comments, suggestions, or insight you might have would be very much appreciated.  Thank you!

  • Hi Ryan,

    Glad to hear that the test variable is getting updated using the PUSH/POP instructions.

    Please let me know if you have any other queries.

    Thanks

    Aswin

  • The PUSH/POP instructions for the core registers appears to resolve this issue.  Thanks for your help.