Forum Discussion

Altera_Forum's avatar
Altera_Forum
Icon for Honored Contributor rankHonored Contributor
19 years ago

write & read SDRAM chip

hi all

I try to read and write the external 8M SDRAM chip.

At the Nios II IDE, my system library and "Linker Script" with program memory(.text), Read-only data memory(.rodata), Read/Write data memory (.rwdata), Heap memory, Stack memory all setting another RAM chip "sram_0".

My program is below:

# include <stdio.h># include <alt_types.h># include <io.h># include <system.h># include <string.h># include "system.h"

int main(void)

{

unsigned int value = 0;

unsigned int pattern = 0x10;

unsigned int i, memory_size;

memory_size = 0x800;

//SDRAM actual size is 0x7FFFFF

for(i = 0; i< memory_size; i=i+0x10)

{

IOWR_16DIRECT((SDRAM_0_BASE), i, pattern);

value = IORD_16DIRECT((SDRAM_0_BASE), i);

printf("%d,%d\n", i,value);

}

return 0;

}

but in the Console with result is only display 6 data:

0,16

16,16

32,16

48,16

64,16

80,16

Could anyone tell me where it is fault ?

At the SOPC Builder->More Settings->Exception Address & Memodule my setting is sdram_0. is this need change to sram_0 or not ? http://forum.niosforum.com/work2/style_emoticons/<#EMO_DIR#>/blink.gif

3 Replies

  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    You&#39;ve answered it, yourself. You&#39;re writing over the code at your Exception Address (starting at offset 0x20) in your SDRAM.

    Cheers,

    - slacker
  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    --- Quote Start ---

    originally posted by slacker@Jun 2 2006, 12:02 AM

    you&#39;ve answered it, yourself. you&#39;re writing over the code at your exception address (starting at offset 0x20) in your sdram.

    cheers,

    - slacker

    <div align='right'><{post_snapback}> (index.php?act=findpost&pid=15784)

    --- quote end ---

    --- Quote End ---

    hi slacker

    The problem has already been solved

    thanks for your reply
  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    --- Quote Start ---

    originally posted by suway1219+jun 2 2006, 02:00 am--><div class='quotetop'>quote (suway1219 @ jun 2 2006, 02:00 am)</div>

    --- quote start ---

    <!--quotebegin-slacker@Jun 2 2006, 12:02 AM

    you&#39;ve answered it, yourself. you&#39;re writing over the code at your exception address (starting at offset 0x20) in your sdram.

    cheers,

    - slacker

    <div align='right'><{post_snapback}> (index.php?act=findpost&pid=15784)

    --- quote end ---

    --- Quote End ---

    hi slacker

    The problem has already been solved

    thanks for your reply

    <div align='right'><{post_snapback}> (index.php?act=findpost&pid=15785)</div>

    [/b]

    --- Quote End ---

    Hi,suway1219

    I will write and read data from SDRAM. so, can you give a complete example?

    thx again.

    Regards

    Faye