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.

omapl138 gel initialization

Other Parts Discussed in Thread: OMAPL138

 

hi:

 I write an application,the function of application is receive the binary file from serial port,when a binary file is received finish,receive data will send out through serial port.Serial port baud rate is set to 115200.

The program works well When I use the simulator to run the program,but when I Programmer off chip flash and boot from off chip flash,the receive data is incomplete,then I set serial port rate to 9600,When the serial receive that the size of the binary file about 5kb  will  not lost data,but the size of the binary file about 30kb still lost data.

after that,I add "PSC_All_On_Full_EVM()" function that copy from OMAPL138_ARM.gel  to my program ,program can receive complete data from serial prot when the size of binary file about 30kb.but if set serial prot baud rate to 115200,program still receive incomplete data.so I try to add "Core_300MHz_mDDR_132MHz();"function that copy from OMAPL138_ARM.gel to my program,but I failure,Error  will occur when program run at "DEVICE_mDDRConfig(132);"

my project use platforms of ti.sdo.ipc.examples.platforms.evmOMAPL138.arm

I use soft ware:ccs5.3  emulator: seed-xds560PLUS    bios:bios_6_34_02_18     ipc:ipc_1_25_00_01_06     chip:OMAPL138      the board is custom

Regards,

lizhang

  • lizhang,

    What is the input crystal clock frequency? Have you modified the GEL file to use the mDDR settings corresponding to your mDDR/DDR2 memory? Are you using the same UART as the one on TI evaluation platform? If not have you changed the PINMUX, PSC settings appropriately in the GEL file to account for this change? Did you try a simple loopback test on the UART similar to one provide in Starterware examples to verify the interface?

    Thanks and Regards,

    Rahul

  •   7610.uart2.cfg

       8877.arm9gel.h

    #include "arm9gel.h"
    
    //menuitem "Wake Core"
    void Wake_DSP()
    {
        PSC0_LPSC_enableCore(1, LPSC_DSP);
    
        //GEL_TextOut("\tDSP Wake Complete.\n","Output",1,1,1);
       // GEL_TextOut("\t---------------------------------------------\n","Output",1,1,1);
    }
    
    //menuitem "OMAP-L138 Memory Map"
    /* ------------------------------------------------------------------------ *
     *                                                                          *
     *  Clear_Memory_Map( )                                                     *
     *      Clear the Memory Map                                                *
     *                                                                          *
     * ------------------------------------------------------------------------ */
    void Clear_Memory_Map()
    {
       // GEL_MapOff( );
       // GEL_MapReset( );
        //GEL_TextOut("\tMemory Map Cleared.\n","Output",1,1,1);
       // GEL_TextOut("\t---------------------------------------------\n","Output",1,1,1);
    }
    
    void Setup_Memory_Map()
    {
        /*GEL_MapOn( );
        GEL_MapReset( );*/
    
        /* ARM */
      /*  GEL_MapAddStr( 0xFFFD0000, 0, 0x00010000, "R|W|AS4", 0 );   // ARM Local ROM
        GEL_MapAddStr( 0xFFFE0000, 0, 0x00002000, "R|W|AS4", 0 );   // ARM INTC
        GEL_MapAddStr( 0xFFFF0000, 0, 0x00002000, "R|W|AS4", 0 );   // ARM Local RAM
        GEL_MapAddStr( 0x01BC0000, 0, 0x00001000, "R|W|AS4", 0 );   // ARM ETB Memory
        GEL_MapAddStr( 0x01BC1000, 0, 0x00000800, "R|W|AS4", 0 );   // ARM ETB Regs
        GEL_MapAddStr( 0x01BC1800, 0, 0x00000100, "R|W|AS4", 0 );   // ARM Ice Crusher
    
        // DSP
        GEL_MapAddStr( 0x00700000, 0, 0x00100000, "R|W|AS4", 0 );   // DSP L2 ROM
        GEL_MapAddStr( 0x00800000, 0, 0x00040000, "R|W|AS4", 0 );   // DSP l2 RAM
        GEL_MapAddStr( 0x00E00000, 0, 0x00008000, "R|W|AS4", 0 );   // DSP L1P RAM
        GEL_MapAddStr( 0x00F00000, 0, 0x00008000, "R|W|AS4", 0 );   // DSP L1D RAM
        GEL_MapAddStr( 0x01800000, 0, 0x00010000, "R|W|AS4", 0 );   // DSP Interrupt Controller
        GEL_MapAddStr( 0x01810000, 0, 0x00001000, "R|W|AS4", 0 );   // DSP Powerdown Controller
        GEL_MapAddStr( 0x01811000, 0, 0x00001000, "R|W|AS4", 0 );   // DSP Security ID
        GEL_MapAddStr( 0x01812000, 0, 0x00008000, "R|W|AS4", 0 );   // DSP Revision ID
        GEL_MapAddStr( 0x01820000, 0, 0x00010000, "R|W|AS4", 0 );   // DSP EMC
        GEL_MapAddStr( 0x01830000, 0, 0x00010000, "R|W|AS4", 0 );   // DSP Internal Reserved
        GEL_MapAddStr( 0x01840000, 0, 0x00010000, "R|W|AS4", 0 );   // DSP Memory System
    
        GEL_MapAddStr( 0x11700000, 0, 0x00100000, "R|W|AS4", 0 );   // DSP L2 ROM (mirror)
        GEL_MapAddStr( 0x11800000, 0, 0x00040000, "R|W|AS4", 0 );   // DSP l2 RAM (mirror)
        GEL_MapAddStr( 0x11E00000, 0, 0x00008000, "R|W|AS4", 0 );   // DSP L1P RAM (mirror)
        GEL_MapAddStr( 0x11F00000, 0, 0x00008000, "R|W|AS4", 0 );   // DSP L1D RAM (mirror)
    
        // Shared RAM
       // GEL_MapAddStr( 0x80000000, 0, 0x00020000, "R|W|AS4", 0 );   // Shared RAM
    
        // EMIFA
        GEL_MapAddStr( 0x40000000, 0, 0x20000000, "R|W|AS4", 0 );   // EMIFA SDRAM Data
        GEL_MapAddStr( 0x60000000, 0, 0x02000000, "R|W|AS4", 0 );   // AEMIF CS2
        GEL_MapAddStr( 0x62000000, 0, 0x02000000, "R|W|AS4", 0 );   // AEMIF CS3
        GEL_MapAddStr( 0x64000000, 0, 0x02000000, "R|W|AS4", 0 );   // AEMIF CS4
        GEL_MapAddStr( 0x66000000, 0, 0x02000000, "R|W|AS4", 0 );   // AEMIF CS5
        GEL_MapAddStr( 0x68000000, 0, 0x00008000, "R|W|AS4", 0 );   // EMIFA Control
    
        // DDR
        GEL_MapAddStr( 0xB0000000, 0, 0x00008000, "R|W|AS4", 0 );   // DDR Control
        GEL_MapAddStr( 0xC0000000, 0, 0x20000000, "R|W|AS4", 0 );   // DDR Data
    
        // Peripherals
        GEL_MapAddStr( 0x01C00000, 0, 0x00008000, "R|W|AS4", 0 );   // TPCC0
        GEL_MapAddStr( 0x01C08000, 0, 0x00000400, "R|W|AS4", 0 );   // TPTC0
        GEL_MapAddStr( 0x01C08400, 0, 0x00000400, "R|W|AS4", 0 );   // TPTC1
        GEL_MapAddStr( 0x01C10000, 0, 0x00001000, "R|W|AS4", 0 );   // PSC 0
        GEL_MapAddStr( 0x01C11000, 0, 0x00001000, "R|W|AS4", 0 );   // PLL Controller 0
        GEL_MapAddStr( 0x01C12000, 0, 0x00001000, "R|W|AS4", 0 );   // Key Manager
        GEL_MapAddStr( 0x01C13000, 0, 0x00001000, "R|W|AS4", 0 );   // Security Controller
        GEL_MapAddStr( 0x01C14000, 0, 0x00001000, "R|W|AS4", 0 );   // BootConfig
        GEL_MapAddStr( 0x01C16000, 0, 0x00001000, "R|W|AS4", 0 );   // IOPU 0
        GEL_MapAddStr( 0x01C17000, 0, 0x00001000, "R|W|AS4", 0 );   // IOPU 2
        GEL_MapAddStr( 0x01C20000, 0, 0x00001000, "R|W|AS4", 0 );   // Timer64P 0
        GEL_MapAddStr( 0x01C21000, 0, 0x00001000, "R|W|AS4", 0 );   // Timer64P 1
        GEL_MapAddStr( 0x01C22000, 0, 0x00001000, "R|W|AS4", 0 );   // I2C 0
        GEL_MapAddStr( 0x01C23000, 0, 0x00001000, "R|W|AS4", 0 );   // RTC
        GEL_MapAddStr( 0x01C24000, 0, 0x00001000, "R|W|AS4", 0 );   // IOPU 1
        GEL_MapAddStr( 0x01C30000, 0, 0x00000200, "R|W|AS4", 0 );   // dMax Data RAM 0
        GEL_MapAddStr( 0x01C32000, 0, 0x00000200, "R|W|AS4", 0 );   // dMax Data RAM 1
        GEL_MapAddStr( 0x01C34000, 0, 0x00004000, "R|W|AS4", 0 );   // dMax Control Registers
        GEL_MapAddStr( 0x01C38000, 0, 0x00001000, "R|W|AS4", 0 );   // dMAX MAX0 Config Memory
        GEL_MapAddStr( 0x01C3C000, 0, 0x00001000, "R|W|AS4", 0 );   // dMAX MAX1 Config Memory
        GEL_MapAddStr( 0x01C40000, 0, 0x00001000, "R|W|AS4", 0 );   // MMC/SD 0
        GEL_MapAddStr( 0x01C41000, 0, 0x00001000, "R|W|AS4", 0 );   // SPI 0
        GEL_MapAddStr( 0x01C42000, 0, 0x00001000, "R|W|AS4", 0 );   // UART 0
        GEL_MapAddStr( 0x01C43000, 0, 0x00001000, "R|W|AS4", 0 );   // MPU 0
        GEL_MapAddStr( 0x01D00000, 0, 0x00001000, "R|W|AS4", 0 );   // McASP 0 Control
        GEL_MapAddStr( 0x01D01000, 0, 0x00001000, "R|W|AS4", 0 );   // McASP 0 FIFO Ctrl
        GEL_MapAddStr( 0x01D02000, 0, 0x00001000, "R|W|AS4", 0 );   // McASP 0 Data
        GEL_MapAddStr( 0x01D0C000, 0, 0x00001000, "R|W|AS4", 0 );   // UART 1
        GEL_MapAddStr( 0x01D0D000, 0, 0x00001000, "R|W|AS4", 0 );   // UART 2
        GEL_MapAddStr( 0x01D0E000, 0, 0x00001000, "R|W|AS4", 0 );   // IOPU 4
        GEL_MapAddStr( 0x01D10000, 0, 0x00000800, "R|W|AS4", 0 );   // McBSP 0 Control
        GEL_MapAddStr( 0x01D10800, 0, 0x00000200, "R|W|AS4", 0 );   // McBSP 0 FIFO Ctrl
        GEL_MapAddStr( 0x01D11000, 0, 0x00000800, "R|W|AS4", 0 );   // McBSP 1 Control
        GEL_MapAddStr( 0x01D11800, 0, 0x00000200, "R|W|AS4", 0 );   // McBSP 1 FIFO Ctrl
        GEL_MapAddStr( 0x01E00000, 0, 0x00010000, "R|W|AS4", 0 );   // USB0 (USB HS) Cfg
        GEL_MapAddStr( 0x01E10000, 0, 0x00001000, "R|W|AS4", 0 );   // UHPI Cfg
        GEL_MapAddStr( 0x01E11000, 0, 0x00001000, "R|W|AS4", 0 );   // UHPI (IODFT)
        GEL_MapAddStr( 0x01E13000, 0, 0x00001000, "R|W|AS4", 0 );   // LCD Controller
        GEL_MapAddStr( 0x01E14000, 0, 0x00001000, "R|W|AS4", 0 );   // MPU 1
        GEL_MapAddStr( 0x01E15000, 0, 0x00001000, "R|W|AS4", 0 );   // MPU 2
        GEL_MapAddStr( 0x01E16000, 0, 0x00001000, "R|W|AS4", 0 );   // UPP
        GEL_MapAddStr( 0x01E17000, 0, 0x00001000, "R|W|AS4", 0 );   // VPIF
        GEL_MapAddStr( 0x01E18000, 0, 0x00002000, "R|W|AS4", 0 );   // SATA
        GEL_MapAddStr( 0x01E1A000, 0, 0x00001000, "R|W|AS4", 0 );   // PLL Controller 1
        GEL_MapAddStr( 0x01E1B000, 0, 0x00001000, "R|W|AS4", 0 );   // MMC/SD 1
        GEL_MapAddStr( 0x01E20000, 0, 0x00002000, "R|W|AS4", 0 );   // EMAC CPPI port
        GEL_MapAddStr( 0x01E22000, 0, 0x00001000, "R|W|AS4", 0 );   // EMAC CPGMACSS registers
        GEL_MapAddStr( 0x01E23000, 0, 0x00001000, "R|W|AS4", 0 );   // EMAC CPGMAC registers
        GEL_MapAddStr( 0x01E24000, 0, 0x00001000, "R|W|AS4", 0 );   // EMAC MDIO port
        GEL_MapAddStr( 0x01E25000, 0, 0x00001000, "R|W|AS4", 0 );   // USB1 (USB FS)
        GEL_MapAddStr( 0x01E26000, 0, 0x00001000, "R|W|AS4", 0 );   // GPIO
        GEL_MapAddStr( 0x01E27000, 0, 0x00001000, "R|W|AS4", 0 );   // PSC 1
        GEL_MapAddStr( 0x01E28000, 0, 0x00001000, "R|W|AS4", 0 );   // I2C 1
        GEL_MapAddStr( 0x01E29000, 0, 0x00001000, "R|W|AS4", 0 );   // IOPU 3
        GEL_MapAddStr( 0x01E2A000, 0, 0x00001000, "R|W|AS4", 0 );   // PBIST Controller
        GEL_MapAddStr( 0x01E2B000, 0, 0x00001000, "R|W|AS4", 0 );   // PBIST Combiner
        GEL_MapAddStr( 0x01E2C000, 0, 0x00001000, "R|W|AS4", 0 );   // System Config
    
        GEL_MapAddStr( 0x01E30000, 0, 0x00008000, "R|W|AS4", 0 );   // TPCC1
        GEL_MapAddStr( 0x01E38000, 0, 0x00000400, "R|W|AS4", 0 );   // TPTC2
        GEL_MapAddStr( 0x01F00000, 0, 0x00001000, "R|W|AS4", 0 );   // EPWM 0
        GEL_MapAddStr( 0x01F01000, 0, 0x00001000, "R|W|AS4", 0 );   // HRPWM 0
        GEL_MapAddStr( 0x01F02000, 0, 0x00001000, "R|W|AS4", 0 );   // EPWM 1
        GEL_MapAddStr( 0x01F03000, 0, 0x00001000, "R|W|AS4", 0 );   // HRPWM 1
        GEL_MapAddStr( 0x01F06000, 0, 0x00001000, "R|W|AS4", 0 );   // ECAP 0
        GEL_MapAddStr( 0x01F07000, 0, 0x00001000, "R|W|AS4", 0 );   // ECAP 1
        GEL_MapAddStr( 0x01F08000, 0, 0x00001000, "R|W|AS4", 0 );   // ECAP 2
        GEL_MapAddStr( 0x01F0B000, 0, 0x00001000, "R|W|AS4", 0 );   // IOPU 5
        GEL_MapAddStr( 0x01F0C000, 0, 0x00001000, "R|W|AS4", 0 );   // Timer64P 2
        GEL_MapAddStr( 0x01F0D000, 0, 0x00001000, "R|W|AS4", 0 );   // Timer64P 3
        GEL_MapAddStr( 0x01F0E000, 0, 0x00001000, "R|W|AS4", 0 );   // SPI1
        GEL_MapAddStr( 0x01F10000, 0, 0x00001000, "R|W|AS4", 0 );   // McBSP 0 FIFO Data
        GEL_MapAddStr( 0x01F11000, 0, 0x00001000, "R|W|AS4", 0 );*/   // McBSP 1 FIFO Data*/
       // GEL_TextOut("\tMemory Map Setup Complete.\n","Output",1,1,1);
       // GEL_TextOut("\t---------------------------------------------\n","Output",1,1,1);
    }
    
    void Set_Core_300MHz() {
        device_PLL0(0,24,1,0,1,11,5);
       // GEL_TextOut("\tPLL0 init done for Core:300MHz, EMIF:25MHz\n","Output",1,1,1);
    }
    void Set_Core_200MHz() {
        device_PLL0(0,24,2,0,1,7,3);
       // GEL_TextOut("\tPLL0 init done for Core:200MHz, EMIFA:25MHz\n","Output",1,1,1);
    }
    void Set_Core_100MHz() {
        device_PLL0(0,24,5,0,1,3,1);
      //  GEL_TextOut("\tPLL0 init done for Core:100MHz, EMIFA:25MHz\n","Output",1,1,1);
    }
    
    void Set_DDRPLL_150MHz() {
        device_PLL1(24,1,0,1,2);
        //GEL_TextOut("\tPLL1 init done for DDR:150MHz\n","Output",1,1,1);
    }
    void Set_DDRPLL_132MHz() {
        device_PLL1(21,1,0,1,2);
       // GEL_TextOut("\tPLL1 init done for DDR:132MHz\n","Output",1,1,1);
    }
    void Set_DDRPLL_126MHz() {
        device_PLL1(20,1,0,1,2);
       // GEL_TextOut("\tPLL1 init done for DDR:126MHz\n","Output",1,1,1);
    }
    void Set_DDRPLL_102MHz() {
        device_PLL1(16,1,0,1,2);
       // GEL_TextOut("\tPLL1 init done for DDR:102MHz\n","Output",1,1,1);
    }
    
    void Set_mDDR_132MHz() {
       // GEL_TextOut("\tmDDR initialization is in progress....\n","Output",1,1,1);
        Set_DDRPLL_132MHz();
        DEVICE_mDDRConfig(132);
        //GEL_TextOut("\tmDDR init for 132 MHz is done\n","Output",1,1,1);
    }
    
    void Set_mDDR_126MHz() {
      //  GEL_TextOut("\tmDDR initialization is in progress....\n","Output",1,1,1);
        Set_DDRPLL_126MHz();
        DEVICE_mDDRConfig(126);
        //GEL_TextOut("\tmDDR init for 126 MHz is done\n","Output",1,1,1);
    }
    
    void Set_mDDR_102MHz() {
       // GEL_TextOut("\tmDDR initialization is in progress....\n","Output",1,1,1);
        Set_DDRPLL_102MHz();
        DEVICE_mDDRConfig(102);
       // GEL_TextOut("\tmDDR init for 102 MHz is done\n","Output",1,1,1);
    }
    
    //menuitem "Frequency Settings"
    void Core_300MHz_mDDR_132MHz() {
        Set_Core_300MHz();
        Set_mDDR_132MHz();
       // GEL_TextOut("\t---------------------------------------------\n","Output",1,1,1);
    }
    
    void Core_200MHz_mDDR_126MHz() {
        Set_Core_200MHz();
        Set_mDDR_126MHz();
       // GEL_TextOut("\t---------------------------------------------\n","Output",1,1,1);
    }
    
    void Core_100MHz_mDDR_102MHz() {
        Set_Core_100MHz();
        Set_mDDR_102MHz();
       // GEL_TextOut("\t---------------------------------------------\n","Output",1,1,1);
    }
    
    //menuitem "Experimenter"
    
    void PSC_All_On_Experimenter() {
       // GEL_TextOut("\tEnabling Experimenter PSCs...\n","Output",1,1,1);
        // PSC0
        PSC0_LPSC_enable(0, LPSC_EDMA_CC0);
        PSC0_LPSC_enable(0, LPSC_EDMA_TC0);
        PSC0_LPSC_enable(0, LPSC_EDMA_TC1);
    //    PSC0_LPSC_enable(0, LPSC_EMIFA);
        PSC0_LPSC_enable(0, LPSC_SPI0);
        PSC0_LPSC_enable(0, LPSC_MMCSD0);
        PSC0_LPSC_enable(0, LPSC_ARM_AINTC);
        PSC0_LPSC_enable(0, LPSC_ARM_RAMROM);
        PSC0_LPSC_enable(0, LPSC_UART0);
        PSC0_LPSC_enable(0, LPSC_SCR0);
        PSC0_LPSC_enable(0, LPSC_SCR1);
        PSC0_LPSC_enable(0, LPSC_SCR2);
    //    PSC0_LPSC_enable(0, LPSC_ARM);
    //    PSC0_LPSC_enable(1, LPSC_DSP);
    
        // PSC1
        PSC1_LPSC_enable(0, LPSC_EDMA_CC1);
        PSC1_LPSC_enable(0, LPSC_USB20);
        PSC1_LPSC_enable(0, LPSC_USB11);
        CFGCHIP2 = 0x09F2;  //Enable USB clock, PHY_PLLON, glue logic mux(USB2 ref clk input)
        PSC1_LPSC_enable(0, LPSC_GPIO);
        PSC1_LPSC_enable(0, LPSC_UHPI);
        PSC1_LPSC_enable(0, LPSC_EMAC);
        PSC1_LPSC_enable(0, LPSC_DDR);
        PSC1_LPSC_enable(0, LPSC_MCASP0);
        PSC1_LPSC_force(LPSC_SATA);
        PSC1_LPSC_enable(0, LPSC_SATA);
    //    PSC1_LPSC_enable(0, LPSC_VPIF);
        PSC1_LPSC_enable(0, LPSC_SPI1);
        PSC1_LPSC_enable(0, LPSC_I2C1);
        PSC1_LPSC_enable(0, LPSC_UART1);
        PSC1_LPSC_enable(0, LPSC_UART2);
        PSC1_LPSC_enable(0, LPSC_MCBSP0);
        PSC1_LPSC_enable(0, LPSC_MCBSP1);
    //    PSC1_LPSC_enable(0, LPSC_LCDC);
        PSC1_LPSC_enable(0, LPSC_EPWM);
        PSC1_LPSC_enable(0, LPSC_MMCSD1);
    //    PSC1_LPSC_enable(0, LPSC_UPP);
        PSC1_LPSC_enable(0, LPSC_ECAP);
        PSC1_LPSC_enable(0, LPSC_EDMA_TC2);
        PSC1_LPSC_enable(0, LPSC_SCR_F0);
        PSC1_LPSC_enable(0, LPSC_SCR_F1);
        PSC1_LPSC_enable(0, LPSC_SCR_F2);
        PSC1_LPSC_enable(0, LPSC_SCR_F6);
        PSC1_LPSC_enable(0, LPSC_SCR_F7);
        PSC1_LPSC_enable(0, LPSC_SCR_F8);
        PSC1_LPSC_enable(0, LPSC_BR_F7);
        PSC1_LPSC_enable(0, LPSC_SHARED_RAM);
    
       // GEL_TextOut("\tPSC Enable Complete.\n","Output",1,1,1);
       // GEL_TextOut("\t---------------------------------------------\n","Output",1,1,1);
    }
    
    //menuitem "Full EVM"
    
    void PSC_All_On_Full_EVM() {
       // GEL_TextOut("\tEnabling Full EVM PSCs...\n","Output",1,1,1);
        // PSC0
        PSC0_LPSC_enable(0, LPSC_EDMA_CC0);
        PSC0_LPSC_enable(0, LPSC_EDMA_TC0);
        PSC0_LPSC_enable(0, LPSC_EDMA_TC1);
        PSC0_LPSC_enable(0, LPSC_EMIFA);
        PSC0_LPSC_enable(0, LPSC_SPI0);
        PSC0_LPSC_enable(0, LPSC_MMCSD0);
        PSC0_LPSC_enable(0, LPSC_ARM_AINTC);
        PSC0_LPSC_enable(0, LPSC_ARM_RAMROM);
        PSC0_LPSC_enable(0, LPSC_UART0);
        PSC0_LPSC_enable(0, LPSC_SCR0);
        PSC0_LPSC_enable(0, LPSC_SCR1);
        PSC0_LPSC_enable(0, LPSC_SCR2);
    //    PSC0_LPSC_enable(0, LPSC_ARM);
    //    PSC0_LPSC_enable(1, LPSC_DSP);
    
        // PSC1
        PSC1_LPSC_enable(0, LPSC_EDMA_CC1);
        PSC1_LPSC_enable(0, LPSC_USB20);
        PSC1_LPSC_enable(0, LPSC_USB11);
        CFGCHIP2 = 0x09F2;  //Enable USB clock, PHY_PLLON, glue logic mux(USB2 ref clk input)
        PSC1_LPSC_enable(0, LPSC_GPIO);
        PSC1_LPSC_enable(0, LPSC_UHPI);
        PSC1_LPSC_enable(0, LPSC_EMAC);
    //    PSC1_LPSC_enable(0, LPSC_DDR);
        PSC1_LPSC_enable(0, LPSC_MCASP0);
        PSC1_LPSC_force(LPSC_SATA);
        PSC1_LPSC_enable(0, LPSC_SATA);
        PSC1_LPSC_enable(0, LPSC_VPIF);
        PSC1_LPSC_enable(0, LPSC_SPI1);
        PSC1_LPSC_enable(0, LPSC_I2C1);
        PSC1_LPSC_enable(0, LPSC_UART1);
        PSC1_LPSC_enable(0, LPSC_UART2);
        PSC1_LPSC_enable(0, LPSC_MCBSP0);
        PSC1_LPSC_enable(0, LPSC_MCBSP1);
        PSC1_LPSC_enable(0, LPSC_LCDC);
        PSC1_LPSC_enable(0, LPSC_EPWM);
        PSC1_LPSC_enable(0, LPSC_MMCSD1);
        PSC1_LPSC_enable(0, LPSC_UPP);
        PSC1_LPSC_enable(0, LPSC_ECAP);
        PSC1_LPSC_enable(0, LPSC_EDMA_TC2);
        PSC1_LPSC_enable(0, LPSC_SCR_F0);
        PSC1_LPSC_enable(0, LPSC_SCR_F1);
        PSC1_LPSC_enable(0, LPSC_SCR_F2);
        PSC1_LPSC_enable(0, LPSC_SCR_F6);
        PSC1_LPSC_enable(0, LPSC_SCR_F7);
        PSC1_LPSC_enable(0, LPSC_SCR_F8);
        PSC1_LPSC_enable(0, LPSC_BR_F7);
        PSC1_LPSC_enable(0, LPSC_SHARED_RAM);
    
       // GEL_TextOut("\tPSC Enable Complete.\n","Output",1,1,1);
      //  GEL_TextOut("\t---------------------------------------------\n","Output",1,1,1);
    }
    
    void EMIFA_NAND_PINMUX() {
        PSC0_LPSC_enable(0, LPSC_EMIFA);
        PINMUX7        = (PINMUX7 & ~0x00FF0FF0) | 0x00110110;
        PINMUX9        = 0x11111111;
        PINMUX12       = (PINMUX12 & ~0x0FF00000) | 0x01100000;
        EMIF25_ACFG2  &= ~0x1; // 8-bit
        EMIF25_NANDFCR = (EMIF25_NANDFCR & ~0x30) | 0x12;
    
        // Set OE Low
        PINMUX6         = (PINMUX6 & ~0x000000F0) | 0x00000080;
        GPIO_BANK23_DIR = (GPIO_BANK23_DIR & ~(1 << 6));
        GPIO_BANK23_CLR = (1 << 6);
    
     //   GEL_TextOut("\tEMIFA Pins Configured for NAND.\n","Output",1,1,1);
     //   GEL_TextOut("\t---------------------------------------------\n","Output",1,1,1);
    }
    
    void EMIFA_NOR_PINMUX() {
        PSC0_LPSC_enable(0, LPSC_EMIFA);
        PINMUX5       = (PINMUX5 & ~0xFF000000) | 0x11000000;
        PINMUX6       = (PINMUX6 & ~0x0F00000F) | 0x01000001;
        PINMUX7       = (PINMUX7 & ~0x00FF000F) | 0x00110001;
        PINMUX8       = 0x11111111;
        PINMUX9       = 0x11111111;
        PINMUX10      = 0x11111111;
        PINMUX11      = 0x11111111;
        PINMUX12      = 0x11111111;
        EMIF25_ACFG2 |= 0x1; // 16-bit
    
      //  GEL_TextOut("\tEMIFA Pins Configured for NOR.\n","Output",1,1,1);
       // GEL_TextOut("\t---------------------------------------------\n","Output",1,1,1);
    }
    
    void SPI1_PINMUX() {
        PSC1_LPSC_enable(0, LPSC_SPI1);
        PINMUX5 = (PINMUX5 & ~0x00FF0FF0) | 0x00110110;
    
       // GEL_TextOut("\tSPI1 Pins Configured.\n","Output",1,1,1);
       // GEL_TextOut("\t---------------------------------------------\n","Output",1,1,1);
    }
    
    /**************************************************************************************************************************************************
       Device_PLL0 init:
    
       CLKMODE -  0---->On Chip Oscilator  1---->External Oscilator
       PLL0_SYSCLK1 - Not used on Freon subchip, fixed divider (/1) - allow to change div1
       PLL0_SYSCLK2 - Used on Freon subchip, but it has a fixed divider ratio to SYSCLK1(/2) - should be used for sc ASYNC3 domain
                      to simplify clock management for peripherals during the ROM boot loader CFGCHIP3[ASYNC3_CLKSRC] - configure with div1
       PLL0_SYSCLK3 - Variable Divider, not used on Freon subchip, but ASYNC1 (EMIFA) on matrix - treat same as in Primus (configure)
       PLL0_SYSCLK4 - Used on Freon subchip, but it has a fixed ratio to div1 (/4) - configure with div1
       PLL0_SYSCLK5 - Variable divider, not used on Freon subchip - do nothing
       PLL0_SYSCLK6 - Not used on Freon subchip, fixed ratio to div1 (/1) - configure with div1
       PLL0_SYSCLK7 - Variable divider, is used on Freon subchip (Test, RMII, possibly USB 1.1) - treat the same as on Primus (configure)
       PLL0_SYSCLK8 - Variable divider, not used on Freon subchip - treat same as in Primus (do nothing)
       PLL0_SYSCLK9 - Variable divider, used on Freon subchip (test) - treat same as in Primus (do nothing)
       DIV4p5CLOCK  - Not used on Freon, can be used in in EMIFA on matrix - treat same as in Primus - configure in EMIF setups, not here
    ******************************************************************************************************************************************************/
    void device_PLL0(unsigned int CLKMODE, unsigned int PLLM, unsigned int POSTDIV,unsigned int PLLDIV1, unsigned int PLLDIV2, unsigned int PLLDIV3, unsigned int PLLDIV7 ) {
    
       unsigned int i=0;
    
       /* Clear PLL lock bit */
       CFGCHIP0 &= ~(0x00000010);
    
       /* Set PLLENSRC '0',bit 5, PLL Enable(PLLEN) selection is controlled through MMR */
       PLL0_PLLCTL &= ~(0x00000020);
    
       /* PLLCTL.EXTCLKSRC bit 9 should be left at 0 for Freon */
       PLL0_PLLCTL &= ~(0x00000200);
    
       /* Set PLLEN=0 to put in bypass mode*/
       PLL0_PLLCTL &= ~(0x00000001);
    
       /*wait for 4 cycles to allow PLLEN mux switches properly to bypass clock*/
       for(i=0; i<PLLEN_MUX_SWITCH; i++) {;}
    
       /* Select the Clock Mode bit 8 as External Clock or On Chip Oscilator*/
       PLL0_PLLCTL &= 0xFFFFFEFF;
       PLL0_PLLCTL |= (CLKMODE << 8);
    
       /*Clear PLLRST bit to reset the PLL */
       PLL0_PLLCTL &= ~(0x00000008);
    
       /* Disable the PLL output*/
       PLL0_PLLCTL |= (0x00000010);
    
       /* PLL initialization sequence
       Power up the PLL by setting PWRDN bit set to 0 */
       PLL0_PLLCTL &= ~(0x00000002);
    
       /* Enable the PLL output*/
       PLL0_PLLCTL &= ~(0x00000010);
    
       /*PLL stabilisation time- take out this step , not required here when PLL in bypassmode*/
       for(i=0; i<PLL_STABILIZATION_TIME; i++) {;}
    
       /*Program the required multiplier value in PLLM*/
       PLL0_PLLM    = PLLM; /* Make PLLMULTIPLEIR as bootpacket*/
    
       /* Prediv setup -Not required */
       //  PLL0_PREDIV = 0x8000 | PREDIV; /* Make POSTDIV as bootpacket*/
    
       /*If desired to scale all the SYSCLK frequencies of a given PLLC, program the POSTDIV ratio*/
       PLL0_POSTDIV = 0x8000 | POSTDIV; /* Make POSTDIV as bootpacket*/
    
       /*Check for the GOSTAT bit in PLLSTAT to clear to 0 to indicate that no GO operation is currently in progress*/
       while(PLL0_PLLSTAT & 0x1==1){}
    
       /*Program the RATIO field in PLLDIVx with the desired divide factors. In addition, make sure in this step you leave the PLLDIVx.DxEN bits set so clocks are still enabled (default).*/
       PLL0_PLLDIV1 = 0x8000 | PLLDIV1;   /* Make PLLDIV1 as bootpacket, do it for other PLLDIVx to if required*/
       PLL0_PLLDIV2 = 0x8000 | PLLDIV2;
       PLL0_PLLDIV4 = 0x8000 | (((PLLDIV1+1)*4)-1);
       PLL0_PLLDIV6 = 0x8000 | PLLDIV1;
       PLL0_PLLDIV3 = 0x8000 | PLLDIV3;   /* Make PLLDIV3 as bootpacket, do it for other PLLDIVx to if required*/
       PLL0_PLLDIV7 = 0x8000 | PLLDIV7;   /* Make PLLDIV7 as bootpacket, do it for other PLLDIVx to if required*/
    
    
       /*Set the GOSET bit in PLLCMD to 1 to initiate a new divider transition.*/
       PLL0_PLLCMD |= 0x1;
    
       /*Wait for the GOSTAT bit in PLLSTAT to clear to 0 (completion of phase alignment).*/
       while(PLL0_PLLSTAT & 0x1==1) { }
    
       /*Wait for PLL to reset properly. See PLL spec for PLL reset time - This step is not required here -step11*/
       for(i=0; i<PLL_RESET_TIME_CNT; i++) {;}   /*128 MXI Cycles*/
    
       /*Set the PLLRST bit in PLLCTL to 1 to bring the PLL out of reset*/
       PLL0_PLLCTL |= 0x8;
    
       /*Wait for PLL to lock. See PLL spec for PLL lock time*/
       for(i=0; i<PLL_LOCK_TIME_CNT; i++) {;} /*Make PLL_LOCK_TIME_CNT as boot Packet*/
    
       /*Set the PLLEN bit in PLLCTL to 1 to remove the PLL from bypass mode*/
       PLL0_PLLCTL |=  0x1;
    
       /* SET PLL lock bit*/
       CFGCHIP0 |= (0x1 << 4) & 0x00000010;
    }
    
    
    /**********************************************************************************
    DDR PLL1 init:
    
    ***********************************************************************************/
    
    void device_PLL1(unsigned int PLLM,unsigned int POSTDIV,unsigned int PLLDIV1, unsigned int PLLDIV2, unsigned int PLLDIV3 ) {
    
       unsigned int i=0;
    
       /* Clear PLL lock bit */
       CFGCHIP3 &= ~(0x00000020);
    
       /* Set PLLENSRC '0',bit 5, PLL Enable(PLLEN) selection is controlled through MMR */
       PLL1_PLLCTL &= ~(0x00000020);
    
       /* PLLCTL.EXTCLKSRC bit 9 should be left at 0 for Freon */
       PLL1_PLLCTL &= ~(0x00000200);
    
       /* Set PLLEN=0 to put in bypass mode*/
       PLL1_PLLCTL &= ~(0x00000001);
    
       /*wait for 4 cycles to allow PLLEN mux switches properly to bypass clock*/
       for(i=0; i<PLLEN_MUX_SWITCH; i++) {;}
    
       /* Select the Clock Mode bit 8 as External Clock or On Chip Oscilator*/
       /* PLL1_PLLCTL &= 0xFFFFFEFF;
       PLL1_PLLCTL |= (CLKMODE << 8); */
    
       /*Clear PLLRST bit to reset the PLL */
       PLL1_PLLCTL &= ~(0x00000008);
    
       /* Disable the PLL output*/
       PLL1_PLLCTL |= (0x00000010);
    
       /* PLL initialization sequence
       Power up the PLL by setting PWRDN bit set to 0 */
       PLL1_PLLCTL &= ~(0x00000002);
    
       /* Enable the PLL output*/
       PLL1_PLLCTL &= ~(0x00000010);
    
       /*PLL stabilisation time- take out this step , not required here when PLL in bypassmode*/
       for(i=0; i<PLL_STABILIZATION_TIME; i++) {;}
    
       /*Program the required multiplier value in PLLM*/
       PLL1_PLLM    = PLLM; /* Make PLLMULTIPLEIR as bootpacket*/
    
       /*If desired to scale all the SYSCLK frequencies of a given PLLC, program the POSTDIV ratio*/
       PLL1_POSTDIV = 0x8000 | POSTDIV; /* Make POSTDIV as bootpacket*/
    
       /*Check for the GOSTAT bit in PLLSTAT to clear to 0 to indicate that no GO operation is currently in progress*/
       while(PLL1_PLLSTAT & 0x1==1){}
    
       /*Program the RATIO field in PLLDIVx with the desired divide factors. In addition, make sure in this step you leave the PLLDIVx.DxEN bits set so clocks are still enabled (default).*/
       PLL1_PLLDIV1 = 0x8000 | PLLDIV1;   /* Make PLLDIV1 as bootpacket, do it for other PLLDIVx to if required*/
       PLL1_PLLDIV2 = 0x8000 | PLLDIV2;   /* Make PLLDIV2 as bootpacket, do it for other PLLDIVx to if required*/
       PLL1_PLLDIV3 = 0x8000 | PLLDIV3;   /* Make PLLDIV3 as bootpacket, do it for other PLLDIVx to if required*/
    
       /*Set the GOSET bit in PLLCMD to 1 to initiate a new divider transition.*/
       PLL1_PLLCMD |= 0x1;
    
       /*Wait for the GOSTAT bit in PLLSTAT to clear to 0 (completion of phase alignment).*/
       while(PLL1_PLLSTAT & 0x1==1) { }
    
       /*Wait for PLL to reset properly. See PLL spec for PLL reset time - */
       for(i=0; i<PLL_RESET_TIME_CNT; i++) {;}   /*128 MXI Cycles*/
    
       /*Set the PLLRST bit in PLLCTL to 1 to bring the PLL out of reset*/
       PLL1_PLLCTL |= 0x8;
    
       /*Wait for PLL to lock. See PLL spec for PLL lock time*/
       for(i=0; i<PLL_LOCK_TIME_CNT; i++) {;} /*Make PLL_LOCK_TIME_CNT as boot Packet*/
    
       /*Set the PLLEN bit in PLLCTL to 1 to remove the PLL from bypass mode*/
       PLL1_PLLCTL |=  0x1;
    
       /* SET PLL lock bit*/
       CFGCHIP3 |= (0x1 << 5) & 0x00000020;
    
    }
    
    /**********************************************************************************
    Device Kick Unlock:
        Kick0 register + data (unlock)
        Kick1 register + data (unlock)
    ***********************************************************************************/
    void DEVICE_KickUnlock() {
       KICK0R = 0x83e70b13;  // Kick0 register + data (unlock)
       KICK1R = 0x95a4f1e0;  // Kick1 register + data (unlock)
     }
    
    
    /**********************************************************************************
      PSC Common functions :
    
    ***********************************************************************************/
    /*Force module state without handshaking */
    void PSC1_LPSC_force(unsigned int LPSC_num) {
        *(unsigned int*) (PSC1_MDCTL+4*LPSC_num) = (*(unsigned int*) (PSC1_MDCTL+4*LPSC_num) | 0x80000000);
    }
    
    /*SyncReset Function for PSC1*/
    void PSC1_LPSC_SyncReset(unsigned int PD, unsigned int LPSC_num) {
        if( (*(unsigned int*)(PSC1_MDSTAT+4 * LPSC_num) & 0x1F) != 0x1 ) {
          *(unsigned int*) (PSC1_MDCTL+4*LPSC_num) = (*(unsigned int*) (PSC1_MDCTL+4*LPSC_num) & 0xFFFFFFE0) | 0x0001;
          PSC1_PTCMD = 0x1<<PD;
    
          /*Wait for power state transition to finish*/
          while( (PSC1_PTSTAT & (0x1<<PD) ) !=0) ;
    
          while( (*(unsigned int*)(PSC1_MDSTAT+4 * LPSC_num) & 0x1F) !=0x1);
        }
    }
    
    /*Enable Function for PSC1*/
    void PSC1_LPSC_enable(unsigned int PD, unsigned int LPSC_num) {
        if( (*(unsigned int*)(PSC1_MDSTAT+4 * LPSC_num) & 0x1F) != 0x3 ) {
          *(unsigned int*) (PSC1_MDCTL+4*LPSC_num) = (*(unsigned int*) (PSC1_MDCTL+4*LPSC_num) & 0xFFFFFFE0) | 0x0003;
          PSC1_PTCMD = 0x1<<PD;
    
          /*Wait for power state transition to finish*/
          while( (PSC1_PTSTAT & (0x1<<PD) ) !=0) ;
    
          while( (*(unsigned int*)(PSC1_MDSTAT+4 * LPSC_num) & 0x1F) !=0x3);
        }
    }
    
    /*LPSC Enable Function for ARM or DSP*/
    void PSC0_LPSC_enableCore(unsigned int PD, unsigned int LPSC_num) {
        if( (*(unsigned int*)(PSC0_MDSTAT+4 * LPSC_num) & 0x11F) != 0x103 ) {
          *(unsigned int*) (PSC0_MDCTL+4*LPSC_num) = (*(unsigned int*) (PSC0_MDCTL+4*LPSC_num) & 0xFFFFFEE0) | 0x0103;
          PSC0_PTCMD = 0x1<<PD;
    
          /*Wait for power state transition to finish*/
          while( (PSC0_PTSTAT & (0x1<<PD) ) !=0) ;
    
          while( (*(unsigned int*)(PSC0_MDSTAT+4 * LPSC_num) & 0x11F) !=0x103);
        }
    }
    
    /*SyncReset Function for PSC0*/
    void PSC0_LPSC_SyncReset(unsigned int PD, unsigned int LPSC_num) {
        if( (*(unsigned int*)(PSC0_MDSTAT+4 * LPSC_num) & 0x1F) != 0x1 ) {
          *(unsigned int*) (PSC0_MDCTL+4*LPSC_num) = (*(unsigned int*) (PSC0_MDCTL+4*LPSC_num) & 0xFFFFFFE0) | 0x0001;
          PSC0_PTCMD = 0x1<<PD;
    
          /*Wait for power state transition to finish*/
          while( (PSC0_PTSTAT & (0x1<<PD) ) !=0) ;
    
          while( (*(unsigned int*)(PSC0_MDSTAT+4 * LPSC_num) & 0x1F) !=0x1);
        }
    }
    
    /*Enable Function for PSC0*/
    void PSC0_LPSC_enable(unsigned int PD, unsigned int LPSC_num) {
        if( (*(unsigned int*)(PSC0_MDSTAT+4 * LPSC_num) & 0x1F) != 0x3 ) {
          *(unsigned int*) (PSC0_MDCTL+4*LPSC_num) = (*(unsigned int*) (PSC0_MDCTL+4*LPSC_num) & 0xFFFFFFE0) | 0x0003;
          PSC0_PTCMD = 0x1<<PD;
    
          /*Wait for power state transition to finish*/
          while( (PSC0_PTSTAT & (0x1<<PD) ) !=0) ;
    
          while( (*(unsigned int*)(PSC0_MDSTAT+4 * LPSC_num) & 0x1F) !=0x3);
        }
    }
    
    
    /**********************************************************************************
      mDDR Configuration routine:
        1. mDDR Enable
        2. VTP calibration
        3. Configure DDR
        4. Set to self-refresh, enable mclkstop and DDR Sync Reset
        5. Enable DDR and disable self-refresh
    
      int freq is MHz
    
    ***********************************************************************************/
    
    void DEVICE_mDDRConfig(unsigned int freq)
    {
        /*Enable the Clock to EMIF3A SDRAM*/
        PSC1_LPSC_enable(PD0, LPSC_DDR);
    
        /*If VTP claiberation enabled , then skip the VTP calibration*/
        if((VTPIO_CTL & 0x00000040))
        {
           // Begin VTP Calibration
           VTPIO_CTL |= (0x00004000);     // Set IOPWRDN bit to enable input buffer powerdown enable mode
           VTPIO_CTL &= ~(0x00000040);  // Clear POWERDN bit (enable VTP)
    
           // Pulse (low) CLRZ to initiate VTP IO Calibration
           VTPIO_CTL |= (0x00002000);       // Set CLRZ bit
           VTPIO_CTL &= ~(0x00002000);    // Clear CLRZ bit (CLRZ should be low for at least 2ns)
           VTPIO_CTL |= 0x00002000;       // Set CLRZ bit
    
           // Polling READY bit to see when VTP calibration is done
           while(!((VTPIO_CTL & 0x00008000)>>15)) {}
    
           VTPIO_CTL |= 0x00000080;        // Set LOCK bit for static mode
           VTPIO_CTL |= 0x00000100;     // Set PWRSAVE bit to save power
           // End VTP Calibration
        }
    
        EMIF3A_SDCR |= 0x00800000; // Set BOOTUNLOCK
    
        // **********************************************************************************************
        // Setting based on 512Mb mDDR MT46H32M16LFBF-6 on EVM
        // Config DDR timings
        DDRCTL      = (0x0               << 8)   |  // Reserved
                      (0x1               << 7)   |  // EXT_STRBEN
                      (0x1               << 6)   |  // PWRDNEN
                      (0x0               << 3)   |  // Reserved
                      (0x4               << 0);     // RL
    
        EMIF3A_SDCR = (EMIF3A_SDCR & 0xF0000000) |  // Reserved
                      (0x1               << 27)  |  // DDR2TERM1
                      (0x0               << 26)  |  // IBANK_POS
                      (0x1               << 25)  |  // MSDRAMEN
                      (0x0               << 24)  |  // DDRDRIVE1
                      (0x0               << 23)  |  // BOOTUNLOCK
                      (0x0               << 22)  |  // DDR2DDQS
                      (0x0               << 21)  |  // DDR2TERM0
                      (0x0               << 20)  |  // DDR2EN
                      (0x0               << 19)  |  // DDRDLL_DIS
                      (0x0               << 18)  |  // DDRDRIVE0
                      (0x1               << 17)  |  // DDREN
                      (0x1               << 16)  |  // SDRAMEN
                      (0x1               << 15)  |  // TIMUNLOCK
                      (0x1               << 14)  |  // NM
                      (0x0               << 12)  |  // Reserved
                      (0x3               << 9)   |  // CL
                      (0x0               << 7)   |  // Reserved
                      (0x2               << 4)   |  // IBANK
                      (0x0               << 3)   |  // Reserved
                      (0x2               << 0);     // PAGESIZE
    
        // Subtracting 0.5 instead of 1 so that the int is rounded up after truncating a real value
        EMIF3A_SDTIMR1 = (((unsigned int) ((97.5 * freq / 1000) - 0.5)) << 25) |  // tRFC
                         (((unsigned int) ((18.0 * freq / 1000) - 0.5)) << 22) |  // tRP
                         (((unsigned int) ((18.0 * freq / 1000) - 0.5)) << 19) |  // tRCD
                         (((unsigned int) ((15.0 * freq / 1000) - 0.5)) << 16) |  // tWR
                         (((unsigned int) ((42.0 * freq / 1000) - 0.5)) << 11) |  // tRAS
                         (((unsigned int) ((60.0 * freq / 1000) - 0.5)) << 6)  |  // tRC
                         (((unsigned int) ((12.0 * freq / 1000) - 0.5)) << 3)  |  // tRRD
                         (EMIF3A_SDTIMR1 & 0x4)                                |  // Reserved
                         (((unsigned int) ((2.0 * freq / 1000) - 0.5))  << 0);    // tWTR
    
        // Subtracting 0.5 instead of 1 so that the int is rounded up after truncating a real value
        // tRASMAX is rounded down so subtracting 1
        // CAS/CL = 3
        EMIF3A_SDTIMR2 = (EMIF3A_SDTIMR2 & 0x80000000)                           |  // Reserved
                         (((unsigned int) ((70000 * freq / 1000) - 1))   << 27)  |  // tRASMAX
                         (0x0                                            << 25)  |  // tXP
                         (0x0                                            << 23)  |  // tODT (Not supported)
                         (((unsigned int) ((120.0 * freq / 1000) - 0.5)) << 16)  |  // tXSNR
                         ((200 - 1)                                      << 8)   |  // tXSRD (200 Cycles)
                         ((1 - 1)                                        << 5)   |  // tRTP (1 Cycle)
                         (0x0                                            << 0);     // tCKE
    
    
        EMIF3A_SDCR    &= ~0x00008000; // Clear TIMUNLOCK
    
        EMIF3A_SDCR2   = 0x00000000; // IBANK_POS set to 0 so this register does not apply
        EMIF3A_SDRCR   = (0x1                                          << 31)  |  // LPMODEN
                         (0x1                                          << 30)  |  // MCLKSTOPEN
                         (0x0                                          << 24)  |  // Reserved
                         (0x0                                          << 23)  |  // SR_PD
                         (0x0                                          << 16)  |  // Reserved
                         (((unsigned int) ((7.8 * freq) + 0.5))        << 0);     // RR
    
        /*SyncReset the Clock to EMIF3A SDRAM*/
        PSC1_LPSC_SyncReset(PD0, LPSC_DDR);
    
        /*Enable the Clock to EMIF3A SDRAM*/
        PSC1_LPSC_enable(PD0, LPSC_DDR);
    
        EMIF3A_SDRCR &= ~0xC0000000;  // disable self-refresh
    }
    
    void OnTargetConnect( )
    {
        Clear_Memory_Map();
        Setup_Memory_Map();
    
        /* You can choose to run this if you only have the experimenter kit        */
        /* It will not turn PSC on for the peripherals on the user interface board */
        /* But it does not hurt if you choose to run PSC_All_On_Full_EVM() even if */
        /* you only have the experimenter kit                                      */
        /* PSC_All_On_Experimenter(); */
    
        PSC_All_On_Full_EVM();
    
        Core_300MHz_mDDR_132MHz();
    
        Wake_DSP();
    }
    

    hi Rahul:

    Thanks for your reply

     The input crystal clock frequency is 24MHz,I don't modified the GEL file about the mDDR settings section. I using UART2


       I wrote an application that use serial port interrupt mode to send and receive data,serial port baud rate is set to 115200,I'll send a byte of data when I received a byte of data,it works fine whether in the simulation or boot from flash,but if I receiving more data and then the more data to send out,I failed when I boot from flash,for exeample:if I send "0x31 0x32 0x33 0x34 0x35"from PC to OMAPL138 through the serial port,PC received "x031 0x33 0x35".so I think that is my clock setting has a problem.I try to add "Core_300MHz_mDDR_132MHz();" function that copy from gel,but always appear I had told you that mistake.

     Attachment is my cfg file for AISgen、I using gel.c fiel and gel.h file modify from OMAPL138_ARM.gel