Compiler/TMS320C6713B: Interface to 16-bit SDRAM

Part Number: TMS320C6713B

Tool/software: TI C/C++ Compiler

Hi,


I am trying to interface tms320c6713 with external SDRAM in 16-bit synchronous mode. I have configured CE2 as following

*(unsigned int*)EMIF_CE2 = 0x00000090         //EMIF_CE2 is the address of CE2 Register.
//Other registers are too set appropriately based on datasheet and PLL settings.

Now if i want to write to sdram, first 100 locations, should i do like this:

#define SDRAM     0xA00000000      //CE2 zone

unsigned short i;

for (i =0; i<100; i++) {
    *(unsigned short *)(SDRAM +i)  =  0x55;
}

1) Is this the right way to write to SDRAM?? How does it set ROWs and COLs addresses??

2) When i read back from SDRAM, i gives me 0x55 for all the zone not the first 100 locations.

  • Guru 81305 points
    Aimal,

    Your tags include the C6713 DSP Starter Kit. Is this the board you are using, or a different TI board, or your own custom board?

    Assuming you are connecting via CCS v3.3 (tags) using JTAG, there is usually a GEL script that runs which initializes the board. This would include initializing the SDRAM interface on the EMIF. The EMIF SDRAM logic translates the internally generated address into ROWs and COLs.

    Which fields are you trying to set with your *EMIF_CE2=0x0090; statement? I like to put comments next to hex/binary constants that indicate the various fields and what the values mean.

    Your for-loop does a fine job of writing to SDRAM. I would recommend defining 'i' as 'unsigned int' since the C67x core uses 32-bit registers natively and actually has to do more work to limit the size of temporary variables to 16 bits. The compiler is usually smart enough to recognize that 'short' is not really needed, but you can control that optimization directly by using 'int'. The assignment is done correctly, assuming CE2 starts at 0xA0000000.

    Filling all the zone (what do you mean by zone?) is not the result of the for-loop or the assignment statement. Try writing 1 word and see what you get. Try it at a higher address. Try writing 0x55+i.

    Regards,
    RandyP

    Search for answers, Ask a question, click  Verify  when complete, Help others, Learn more.

  • In reply to RandyP:

    RandyP,

    1) I am using a custom board based on TMS320c6713... just experimenting.

    2) I know the GEL file it is just initializing emif for the 16MB ram on dsk.. It doeznt matter i used the just script or i initialize them in main program. i even mentioned in my post:

    //Other registers are too set appropriately based on datasheet and PLL settings.

    so initializing them in GEL file wont do any good... how will i burn GEL into ROM than. so i initialized them in main program.

    3) I am configuring MTYPE file to 16-bit SDRAM. i don't think so other fields are important in SDRAM configuration. are they? neither they are used.

    4) how the address is translated into row and columns?? is it like

    SDRAM array
    _______________
    | 1 | 2 | 3 |
    -----------------------
    | 4 | 5 | 6 |
    -----------------------
    | 7 | 8 | 9 |
    -----------------------

    To:

    _____
    1
    _____
    2
    _____
    3
    --------
    ...
    .
    _____
    9
    --------

    5) *(unsigned int * ) BASE_ADDRESS_OF_RAM_CE2 : Will this read two Cells, as DSP reads 32-bit during read write while the RAM that is attached is 16-bit SDRAM.

    Regards,
  • In reply to aimal khan:

    Aimal,

    1. To validate your design please use gel file and check whether the SDRAM interface is working fine on your custom board.
    2. You may need to verify all the SDRAM configurations and SDRAM timing parameters are correct based on your design.
    3. For logical address mapping details, please refer Figure 3-7. Logical Address-to-Page Register Mapping for 32-Bit Logical Address in below user guide.
    www.ti.com/.../spru266e.pdf

    Regards,
    Senthil

    ----------------------------------------------------------------------------------------------------------------

    Please click the "Verify Answer" button on this post if it answers your question.

  • In reply to SenthilKumar Srinivasan:

    1) Does it make any difference if i configure and check my sdram in main function (as i am doing) instead of GEL file???
    2) I have configured all the registers based on sdram datasheet.
    3) I have read spru266e, still thank as i didn't look at figure 3-7.
  • Guru 81305 points

    In reply to aimal khan:

    Aimal,

    aimal khan
    1) Does it make any difference if i configure and check my sdram in main function (as i am doing) instead of GEL file???

    Eventually, you will have to do the initialization in your program code. For debug purposes, the GEL file is the easiest way to get it done. The GEL file has been tested by TI, so all you have to do is change the parameters for your specific SDRAM device, if any need to be changed.

    aimal khan
    2) I have configured all the registers based on sdram datasheet.

    You have made this statement in a comment, also, but this does not let us help you since you have something set wrong and you are not showing what you have done. If you would use/modify the GEL, then we at least know what you are starting from.

    aimal khan
    3) I have read spru266e, still thank as i didn't look at figure 3-7.

    Did you look at section 3.4.4? You need to read and understand and apply all of section 3.4.

    Did you design your custom board using different connections that what are shown in section 3.4? Or did you follow the DSK schematic, or so on?

    You either have a register configuration error or a board design error. We cannot tell which it is without your help. I have made suggestions of tests to try, and the results from those test can help us figure out what is wrong. If your board is designed wrong, we can try to help you figure out if that is the case. So please follow some of the advice and suggestions so we can help you proceed.

    Regards,
    RandyP

    Search for answers, Ask a question, click  Verify  when complete, Help others, Learn more.

  • In reply to RandyP:

    Hi RandyP,

    I got your point. One more thing... what is the correct way to access the 16-bit SDRAM???

    x = *(unsigned int *) 0xADDRESS;

    or

    x = *(unsigned short *) 0xADDRESS;

    as indicated in table 3-4 in spru266e (www.ti.com/.../spru266e.pdf), the row address goes to bit 25. so by doing unsigned short, the address will be truncated to 16bit???

    strangely when i use the second method, it partially works, but the first one doesn't work at all. so whats the correct way of accessing 16-bit sync sdram???

    Regards,
  • Guru 81305 points

    In reply to aimal khan:

    Aimal,

    Both could are correct, but it depends on the declaration of 'x'. This is a C question, not a hardware question.

    The width of the memory device on the EMIF is not related to the data value returned for either assignment statement.

    The EMIF Reference Guide has a lot of good information on how it translates between a physical device and the internal processor's instruction access. For the types of questions you are asking, I think you would benefit from reading it cover-to-cover for the information it holds.

    Regards,
    RandyP

    Search for answers, Ask a question, click  Verify  when complete, Help others, Learn more.