TMS320F28P650SH: Fail to Start RAM Initialization - ITRAP

Part Number: TMS320F28P650SH

Tool/software:

Hi Champ,

My customer use below code to start ram initialization. We find if we put below code at the at the beginning of main(), everything works well. 

    EALLOW;
    *(volatile int *) (MEMCFG_BASE + MEMCFG_O_DXINIT)  = 0x0003;               /* RAM INIT FOR M0/M1 Memory      */
    while(!(*(volatile int *) (MEMCFG_BASE + MEMCFG_O_DXINITDONE) == 0x3));   /* Wait for InitDone Status       */
 
    *(volatile int *)(MEMCFG_BASE + MEMCFG_O_LSXINIT) = 0x00FF;               /* RAM INIT FOR LS1..LS7  Memory  */
    while(!(*(volatile int *) (MEMCFG_BASE + MEMCFG_O_LSXINITDONE) == 0xFF)); /* Wait for InitDone Status       */
 
    *(volatile int *)(MEMCFG_BASE + MEMCFG_O_GSXINIT) = 0x000F;               /* RAM INIT FOR GS0.GS3 Memory    */
    while(!(*(volatile int *) (MEMCFG_BASE + MEMCFG_O_GSXINITDONE) == 0xF));  /* Wait for InitDone Status       */
    EDIS;

But when we change the position, put the code after the peripheral initialization like below, it will trigger ITRAP interrupt when we execute code of start RAM initialization. 

Could you please give us some guidance to debug the issue? Thanks a lot!

BR,

Fengyu