Nios® V/II Embedded Design Suite (EDS)
Support for Embedded Development Tools, Processors (SoCs and Nios® V/II processor), Embedded Development Suites (EDSs), Boot and Configuration, Operating Systems, C and C++
Announcements
FPGA community forums and blogs on community.intel.com are migrating to the new Altera Community and are read-only. For urgent support needs during this transition, please visit the FPGA Design Resources page or contact an Altera Authorized Distributor.

write & read SDRAM chip

Altera_Forum
Honored Contributor II
1,645 Views

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
0 Kudos
3 Replies
Altera_Forum
Honored Contributor II
444 Views

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
0 Kudos
Altera_Forum
Honored Contributor II
444 Views

 

--- 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
0 Kudos
Altera_Forum
Honored Contributor II
444 Views

 

--- 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
0 Kudos
Reply