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.

Argument changes value when stepping into function - TMS320F28069

Other Parts Discussed in Thread: TMS320F28069, CONTROLSUITE

Hi,

I'm working on a TMS320F28069 used to control a gimbal with brushless DC motors.

Currently, I'm working on interfacing, but I'm having some trouble when stepping into inline functions. The equivalent of the follow situation is happening:

Standing in function fooA():

inline void fooA(uint16_t chan)
{
    // Here the debugger correctly shows chan = 0
    fooB(chan);
}

inline void fooB(uint16_t chan) // This is positioned above fooA
{
    // Here the debugger evaluates chan = 1
    some_global_array[chan];
}

Another thing I noticed was that prior to this position in the program execution, the stack pointer had the value 0x086C, which I believe is outside the stack area. Here is an excerpt of the ram linker file (i'm just using the default, from controlSUITE.

SECTIONS
{
   //...

   .stack           : > RAMM1,      PAGE = 1

   //...
}

MEMORY
{
PAGE 0 :
   /* BEGIN is used for the "boot to SARAM" bootloader mode   */

   BEGIN       : origin = 0x000000, length = 0x000002
   RAMM0       : origin = 0x000050, length = 0x0003B0
   RAML0_L3    : origin = 0x008000, length = 0x002000	 /* RAML0-3 combined for size of .text */
   														 /* in Example_F2806xSWPrioritezedInterrupts */
   RESET       : origin = 0x3FFFC0, length = 0x000002
   FPUTABLES   : origin = 0x3FD860, length = 0x0006A0	 /* FPU Tables in Boot ROM */
   IQTABLES    : origin = 0x3FDF00, length = 0x000B50    /* IQ Math Tables in Boot ROM */
   IQTABLES2   : origin = 0x3FEA50, length = 0x00008C    /* IQ Math Tables in Boot ROM */
   IQTABLES3   : origin = 0x3FEADC, length = 0x0000AA	 /* IQ Math Tables in Boot ROM */

   BOOTROM    : origin = 0x3FF3B0, length = 0x000C10


PAGE 1 :

   BOOT_RSVD   : origin = 0x000002, length = 0x00004E     /* Part of M0, BOOT rom will use this for stack */
   RAMM1       : origin = 0x000400, length = 0x000400     /* on-chip RAM block M1 */
   RAML4       : origin = 0x00A000, length = 0x002000     /* on-chip RAM block L4 */
   RAML5       : origin = 0x00C000, length = 0x002000     /* on-chip RAM block L5 */
   RAML6       : origin = 0x00E000, length = 0x002000     /* on-chip RAM block L6 */
   RAML7       : origin = 0x010000, length = 0x002000     /* on-chip RAM block L7 */
   RAML8       : origin = 0x012000, length = 0x002000     /* on-chip RAM block L8 */
   USB_RAM     : origin = 0x040000, length = 0x000800     /* USB RAM		  */
}

How does this happen?

  • I have discovered that alot of my large structs were declared automaticly, thus taking up alot of memory. I have moved them to the heap by using malloc instead. This resulted in the stack pointer never moving above about 0x450, but the aforementioned problem is still there.
  • Glenn Bitar said:
    Currently, I'm working on interfacing, but I'm having some trouble when stepping into inline functions.

    Glenn,

    When functions are in-lined the code is inserted directly and optimizations can take place.  It is possible that "chan" is being held in a register and not the stack?  Looking at the at the disassembly may provide some clues.

    -Lori