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.

Compiler/TMS320F28379D: ISR doesn´t start when executed from Flash

Part Number: TMS320F28379D

Tool/software: TI C/C++ Compiler

Hi,

I´am facing some difficulties with changing from RAM to FLASH:

Timer0 gets called ever sec and an GPIO gets Toggled. Before the Timer gets Enabled the Gpio gets Toggled 5 times.

If I download the programm to the FLASH everything works fine. But if i restart the Controller. The GPio Toggles 5 time (which is not Timer0 controlled) but after this nothing happens,

It seems to me that the memcpy isrfnc is the problem. The ISR is linked via the isr.cmd

#include "F28x_Project.h"
#include "F2837xD_Ipc_drivers.h"

extern uint16_t isrfuncLoadStart;
extern uint16_t isrfuncLoadEnd;
extern uint16_t isrfuncRunStart;
extern uint16_t isrfuncLoadSize;

__interrupt void cpu_timer0_isr(void);

#pragma CODE_SECTION(cpu_timer0_isr,"isrfunc")

#ifdef _FLASH

extern Uint16 RamfuncsLoadStart;
extern Uint16 RamfuncsLoadSize;
extern Uint16 RamfuncsRunStart;
#endif

void main(void)
{

#ifdef _FLASH
  EALLOW;
  Flash0EccRegs.ECC_ENABLE.bit.ENABLE = 0;
  memcpy(&RamfuncsRunStart, &RamfuncsLoadStart, (size_t)&RamfuncsLoadSize);
  memcpy(&isrfuncRunStart, &isrfuncLoadStart, (uint32_t)&isrfuncLoadSize); //  Copy ISR routine to a specified RAM location to determine the size
  EDIS;
#endif
  
    InitSysCtrl();
    
    InitGpio();

    EALLOW;
    GpioCtrlRegs.GPADIR.bit.GPIO31 = 1;
    GpioDataRegs.GPACLEAR.bit.GPIO31 = 1;
    GpioCtrlRegs.GPBDIR.bit.GPIO34 = 1;
    GpioDataRegs.GPBCLEAR.bit.GPIO34 = 1;
    EDIS;


    EALLOW;
    ClkCfgRegs.CLKSRCCTL3.bit.XCLKOUTSEL = 0;  // *8 = SYSCLK
    ClkCfgRegs.SYSCLKDIVSEL.bit.PLLSYSCLKDIV = 0;
    ClkCfgRegs.LOSPCP.bit.LSPCLKDIV = 0; // Set LSPCKL (Clock for UART) to SYSCKL  (=160MHz)
    GpioCtrlRegs.GPCMUX1.bit.GPIO73 = 3;
    EDIS;

    DINT;

    InitPieCtrl();

//
// Disable CPU interrupts and clear all CPU interrupt flags:
//
    IER = 0x0000;
    IFR = 0x0000;

    InitPieVectTable();

    EALLOW;
    PieVectTable.TIMER0_INT = &cpu_timer0_isr;
    EDIS;

    InitCpuTimers();

    ConfigCpuTimer(&CpuTimer0, 160, 100000);

    CpuTimer0Regs.TCR.all = 0x4000;

    EINT;  // Enable Global interrupt INTM
    ERTM;  // Enable Global realtime interrupt DBGM

    int i;
    for(i=0;i<5;i++)
           {
               GpioDataRegs.GPBSET.bit.GPIO34 = 1;
               GpioDataRegs.GPASET.bit.GPIO31 = 1;
               DELAY_US(1000*500);
               GpioDataRegs.GPBCLEAR.bit.GPIO34 = 1;
               GpioDataRegs.GPACLEAR.bit.GPIO31 = 1;
               DELAY_US(1000*500);
           }
    IER |= M_INT1;

    PieCtrlRegs.PIEIER1.bit.INTx7 = 1;
}

__interrupt void cpu_timer0_isr(void)
{

    GpioDataRegs.GPBTOGGLE.bit.GPIO34 = 1;
    CpuTimer0.InterruptCount++;

    PieCtrlRegs.PIEACK.all = PIEACK_GROUP1;
}


With kind regards

Manuel 

  • Hi Manuel,

    Based on the code that you sent, it looks like you start the CPU timer before you toggle GPIO 5 times inside the for loop. Can you try moving "CpuTimer0Regs.TCR.all = 0x4000; (line 70)" to the end after you enable interrupt i.e. after "PieCtrlRegs.PIEIER1.bit.INTx7 = 1;"?

    Regards,
    Nirav
  • Hi Nirav,

    i moved the line, but nothing changed.
    Just as before the Code runs perfect directly after flashing (toggles 5 time the two Gpios and afterwards only the GPIO34 toggles). But if i restart the Controller (without flashingthe program again), after the for-loop (5 times toggling) nothing happens.
    So my guess is that the Controller doesn´t correctly boot from Flash, respectively the memcpy of the isrfnc doesn´t work.

    With kind regards.
    Manuel Stadler
  • Hi Manuel,

    Can you send your linker command file?

    Regards,
    Nirav
  • Hi Nirav,

    my linker command file is the isr.cmd

    MEMORY
    {
        PAGE 0 :   /* Program Memory */
           
        
        PAGE 1 :   /* Data Memory */
    
    }
    
    /* 
        Allocate sections to memory blocks.   
    */
    
    
    SECTIONS
    {
    
       /* Allocate program areas: */
       
       isrfunc            : LOAD = RAMD0 |  RAMLS0 | RAMLS1 | RAMLS2 | RAMLS3 | RAMLS4,
                             RUN = RAMGS15,
                             LOAD_START(_isrfuncLoadStart),
                             LOAD_END(_isrfuncLoadEnd),
                             RUN_START(_isrfuncRunStart),
    						 LOAD_SIZE(_isrfuncLoadSize),
    						 PAGE = 0
    						 
    }

    Furthermore I have included the 2837xD_FLASH_lnk_cpu1.cmd and F2837xD_Headers_nonBIOS_cpu1.cmd command files via the File Search Path under Properties-C2000 Linker.

    PS: I am not quit sure how the linker command files should work. Is there a tutorial for this issue?

    With kind regards

    Manuel

  • Hi Manuel,

    I think I know what the problem could be, in your ISR linker .cmd file you are loading the section into RAM instead of Flash. You can try below to see if it fixes your problem.

    LOAD = RAMD0 | RAMLS0 | RAMLS1 | RAMLS2 | RAMLS3 | RAMLS4,

    to

    LOAD = FLASHD,

    I will check with our SW team if they have any tutorial on linker command file.

    Regard,s

    Nirav

  • Thank you very much.

    The LOAD=FLASHD solved the issue.

    With kind regards
    Manuel