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.

TMS570LS1224: How can I jump from one address to another at runtime ?

Part Number: TMS570LS1224

Hello everbody,

I am trying to adapt the following code written for Arm Cortex M3 for TMS570LS1224;

__attribute__((noinline)) static void prv_enable_vfp( void )
{
  volatile uint32_t *cpacr = (volatile uint32_t *)0x20000000;
  *cpacr |= 0xf << 20;
}

static void start_app(uint32_t pc, uint32_t sp)
{
  __asm volatile ("MSR msp, %0" : : "r" (sp) : );
  void (*application_reset_handler)(void) = (void *)pc;
  application_reset_handler();
}

int main(void)
{
	prv_enable_vfp();
}

So, how to write CMSIS Cortex-R4F Core Function/Instruction ?

  • Hello,

    Here is the link to download the CMSIS for Hercules devices:

    Most algorithms in CMSIS are available in floating-point and various fixed-point formats and are optimized for the Cortex-R series processors. The Cortex-R4 processor implementation uses the ARM DSP SIMD (Single Instruction Multiple Data) instruction set and floating-point hardware to enable fully the capabilities of the Cortex-R4 processor for signal processing algorithms. 

  • Hi, thank you for your answer. I try to change main stack pointer but I'm a stranger to the Cortex-R4 family. For example, when I try to use(Cortex M) this;

    __set_MSP(*(volatile uint32_t *) (<some_address>); 

    I can set the stack pointer for Cortex M as shown above, but I couldn't find any macro or function for Cortex R4. Do you have any suggestion? 

  • This macro is not used for Hercules devices.

    You can use the following instruction to jump to a address:

            ((void (*)(void))g_Address)();

  • I try to use your jump function but I got an error like this;

    CortexR4: File Loader: Memory write failed: Flash algorithm returned an error during Flash programming. Note: Auto ECC generation is on, please make sure that the data sections are 64-bit memory aligned in your linker file; alternately, turn off Auto ECC generation in the On-Chip Flash settings

    My linker file as below;

    /* Linker Settings                                                            */
    
    --retain="*(.intvecs)"
    
    /* USER CODE BEGIN (1) */
    /* USER CODE END */
    
    /*----------------------------------------------------------------------------*/
    /* Memory Map                                                                 */
    
    MEMORY
    {
        FLASH0  (RX) : origin=0x00009040 length=0x00136FC0
        STACKS  (RW) : origin=0x08000000 length=0x00001500
        RAM     (RW) : origin=0x08001500 length=0x0002EB00
    
    /* USER CODE BEGIN (2) */
    /* USER CODE END */
    }
    
    /* USER CODE BEGIN (3) */
    /* USER CODE END */
    
    /*----------------------------------------------------------------------------*/
    /* Section Configuration                                                      */
    
    SECTIONS
    {
        .intvecs : {} > FLASH0
        .text    : {} > FLASH0 
        .const   : {} > FLASH0 
        .cinit   : {} > FLASH0 
        .pinit   : {} > FLASH0 
        .bss     : {} > RAM
        .data    : {} > RAM
        .sysmem  : {} > RAM
        
        FEE_TEXT_SECTION : {} > FLASH0
        FEE_CONST_SECTION : {} > FLASH0
        FEE_DATA_SECTION : {} > RAM
    
    /* USER CODE BEGIN (4) */
    /* USER CODE END */
    }

    My main ;

    void main(void)
    {
        peripheral_init();  //0x00010020        //0x00008020
    
        ((void (*)(void))0x00009040)();
    
        while(1)
        {
          //there is some code but the stack pointer shouldn't get here anyway.
        }
    
    }

    And I try to jump this addres :0x00009040.

    1) Is my linker file wrong?

    2) If my linker is true, how to pass auto ECC generation fault? 

  • 1. If there is no valid instruction at the 0x9040m you will get an error

    2. When CCS loads the program to flash, the ECC is programmed automatically if the option is enabled:

        CCS-->tools --> on-chip flash-->flash setting --> auto ecc generation