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.

TMS320F28386S: Resetting the stack pointer and PC

Part Number: TMS320F28386S


I am copying code from flash to ram and after doing so I want to reset the stack pointer.

What are the preferred methods for doing this from a running program that is cognizant of the address set in the cmd file?

I have seen something like this but I don't know how to specify the address set in the cmd file.

__asm("MOV SP, #__stack ;");

To branch to the new location would a function pointer be used, a branch, or a PC register load?

I set the cmd file up like this:

SECTIONS
{
   codestart        : > BEGIN

   kernel_section : //>> FLASH5 | FLASH6 | FLASH7 | FLASH8 | FLASH9 | FLASH11 | FLASH12
   {
		flash_kernel_c28x_dual_ex1_boot_cpu1.obj(.text)
		flash_kernel_c28x_dual_ex1_erase_cpu1.obj(.text)
		flash_kernel_c28x_dual_ex1_sci_boot_cpu1.obj(.text)
		flash_kernel_c28x_dual_ex1_sci_flash_kernel_cpu1.obj(.text)
		flash_kernel_c28x_dual_ex1_sci_get_function_cpu1.obj(.text)
		flash_kernel_c28x_dual_ex1_verify_cpu1.obj(.text)

   }    LOAD >> FLASH5,// | FLASH6 | FLASH7 | FLASH8 | FLASH9 | FLASH11 | FLASH12,
        RUN >> RAMLS0 | RAMLS1 | RAMLS2 |RAMLS3,
        LOAD_START(RamfuncsLoadStart),
        LOAD_SIZE(RamfuncsLoadSize),
        LOAD_END(RamfuncsLoadEnd),
        RUN_START(RamfuncsRunStart),
        RUN_SIZE(RamfuncsRunSize),
        RUN_END(RamfuncsRunEnd),
        ALIGN(4)

   .text            : >>RAMGS1 | RAMGS2 | RAMGS3 | RAMGS4
   .cinit           : > RAMM0
   .switch          : > RAMM0
   .reset           : > RESET,    TYPE = DSECT /* not used, */

   .stack           : > RAMM1
#if defined(__TI_EABI__)
   .bss            : > RAMGS5
   .data           : > RAMGS5
   .const          : > RAMGS5
   .init_arry      : > RAMM0
   .sysmem         : > RAMGS5
#else
   .pinit           : > RAMM0
   .ebss            : > RAMGS5
   .econst          : > RAMGS5
   .esysmem         : > RAMGS5
#endif

   Filter_RegsFile  : > RAMGS5

#ifdef __TI_COMPILER_VERSION__
    #if __TI_COMPILER_VERSION__ >= 15009000
       .TI.ramfunc      : > RAMGS5
    #else
       ramfuncs         : > RAMGS5
    #endif
#endif

   MSGRAM_CPU1_TO_CPU2 > CPU1TOCPU2RAM_0, type=NOINIT
   MSGRAM_CPU1_TO_CPU2_COPY_TO_M1_RAM > CPU1TOCPU2RAM_1, type=NOINIT
   MSGRAM_CPU2_TO_CPU1 > CPU2TOCPU1RAM, type=NOINIT
   MSGRAM_CPU_TO_CM   > CPUTOCMRAM, type=NOINIT
   MSGRAM_CM_TO_CPU   > CMTOCPURAM, type=NOINIT



    /* The following section definition are for SDFM examples */
   Filter1_RegsFile : > RAMGS10,	 fill=0x1111
   Filter2_RegsFile : > RAMGS11,	 fill=0x2222
   Filter3_RegsFile : > RAMGS12,	 fill=0x3333
   Filter4_RegsFile : > RAMGS13,     fill=0x4444
   Difference_RegsFile : >RAMGS14, 	 fill=0x3333

}

Thanks,

John