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.

CCS: example_emif_sdram.c Description for TMDXRM57LHDK

Tool/software: Code Composer Studio

Hi,

Where does the access to the sdram happen(with which function etc.)? I only see a functionality of a blinking LED. Is this the only example for the sdram?

Thank You. BR

Marcel

  • Hi Marcel,

    The blinky function is present in the SDRAM. When the function is being called, it is executed from the SDRAM.

    The following code in the example does writes to the SDRAM. It basically copies the instructions from Flash to SDRAM.

    for(i=0;i<size;i++)
    {
    ((char *)&BlinkyStartAddr)[i] =((char *)&BlinkyLoadStart)[i];
    }

    Later it calls the blinky function from the SDRAM.

    This example basically shows how to set up the EMIF, how to write to the SDRAM location and how to execute a piece of code from it.

    Thanks and Regards,
    Veena
  • Hi Veena,

    Thank you for your explanation. But I see no reference between the blinky function and this:

    for(i=0;i<size;i++)
    {
    ((char *)&BlinkyStartAddr)[i] =((char *)&BlinkyLoadStart)[i];
    }

    Does it have something to do with this:

    .blinky_section : RUN = SDRAM, LOAD = FLASH0 | FLASH1
                          LOAD_START(BlinkyLoadStart), LOAD_END(BlinkyLoadEnd), LOAD_SIZE(BlinkySize),
                          RUN_START(BlinkyStartAddr ), RUN_END(BlinkyEndAddr )

  • Hi Marcel,

    The following line in the linker command means the code present in the .blinkysection (this is were the blinky function is present) is loaded into FLASH but would be run from SDRAM.
    LOAD_START will give you the start address of the function in the flash and RUN_START will give you the start address of the function in the running memory which is SDRAM. LOAD_SIZE provides the size of the section

    .blinky_section : RUN = SDRAM, LOAD = FLASH0 | FLASH1
    LOAD_START(BlinkyLoadStart), LOAD_END(BlinkyLoadEnd), LOAD_SIZE(BlinkySize),
    RUN_START(BlinkyStartAddr ), RUN_END(BlinkyEndAddr )

    Once the image is loaded in the device, the blinky function will be loaded only in Flash (at addr = BlinkyLoadStart). It will not be automatically loaded on the SDRAM. It should be manually copied to the SDRAM at addr = BlinkyStartAddr. This is done by the following code
    for(i=0;i<size;i++)
    {
    ((char *)&BlinkyStartAddr)[i] =((char *)&BlinkyLoadStart)[i];
    }

    After this any calls to the blinky function will be run from SDRAM, and not through flash.


    This may not be a real usecase scenario. You can use a similar approach for running code from TCMRAM or L2 RAM. This example just provides some sample code for how to modify the linker command file for running code outside flash, how to use DATA_SECTION pragmas along with SDRAM usage.

    Thanks and Regards,
    Veena
  • Hi,

    Ok now I got it. Thank you. I tried this example because I want to use the Interface for read/write speed, this was the only example for SDRAM I found. Do you know samples for read and write routines for sdram? Or do you know a manual for this.  Thank you Veena for your patience.

    BR

    Marcel

  • Marcel,

    Once the SDRAM is initialised, you can access the SDRAM like any other RAM.

    To read or write to an address you can use the following statements:

    *PTR = 1 or uint32_t a = *PTR

    PTR is a macro defined in the EMIF to indicate the start of SDRAM address.

    Much more recommended way is to define variables or arrays in the SDRAM location (using linker command files and DATA_SECTION pragmas). Sample code below:

    #pragma DATA_SECTION(sdram_Buf, ".sdram_section")
    uint32_t sdram_Buf[10];

    In the linker command file under SECTIONS  add

    .sdram_section: {} > SDRAM

    Thanks and Regards,

    Veena