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++

URGENT: IOWR problem

Altera_Forum
Honored Contributor II
1,741 Views

hello, i have a problem writing data into sdram on de2 board. when i generate 10 numbers (0-9) and write into sdram, it works fine. if i generate 100 numbers (0-99), it has a problem. here is my code: 

# include <stdio.h># include <stdlib.h> # include <unistd.h># include "altera_avalon_pio_regs.h"# include "system.h"# include "alt_types.h" 

 

int main() 

int i, x; 

printf("##### Performance Analysis# ####\n\n"); 

 

for(x = 0;x < 100; x++){ 

IOWR(SDRAM_BASE, x, x); 

 

printf("Data in MEM1\n"); 

for(i = 0; i < 100; i++){ 

printf("%X\n",IORD(SDRAM_BASE, i)); 

 

return 0; 

 

if i generate 100 numbers, at the console, it only prints out: 

##### performance analysis# #### 

then, after that all is blank. 

 

it works fine if only 10 numbers are used. 

please assist me! thanks!
0 Kudos
7 Replies
Altera_Forum
Honored Contributor II
344 Views

What memory is your code running from? If your code is also in SDRAM starting at address zero, then your test code would be overwriting itself. Testing from just 0 - 9 may still work as it might only be overwriting the reset vector location or some other small portion of memory no longer required by your code to continue proper execution.

0 Kudos
Altera_Forum
Honored Contributor II
344 Views

yes, my code is in SDRAM too... how do i know if my code is starting at address zero too? besides, how to fix it? how do i know my code ends at which address? sorry, i am new to this things. thanks!

0 Kudos
Altera_Forum
Honored Contributor II
344 Views

Why do you want to write to the SDRAM using IOWR macros, instead of using static variables or allocated memory?

0 Kudos
Altera_Forum
Honored Contributor II
344 Views

As Daixiwen said, there's normally no reason to use IOWR/IORD to access SDRAM. Anyway, if you really want to use IOWR you must be sure you are writing to a free ram area; you can do something like this: 

int sdram_array; for(x = 0;x < 100; x++){ IOWR(SDRAM_BASE, &sdram_array, x); /* this is equivalent to sdram_array = x */ } 

 

Cris
0 Kudos
Altera_Forum
Honored Contributor II
344 Views

Daixiwen: Thanks for the info. I am new, so i am not sure there is some other ways to write to SDRAM? Can you please provide me with more info or maybe tutorials? thanks! 

 

Cris72: Thanks for the info! I plan to use flash memory but I dont know the setting in SOPC, not sure of the verilog code for the signal connection and i dont know how to access the flash memory? is it possible that you help me out with some basic info? thanks!
0 Kudos
Altera_Forum
Honored Contributor II
344 Views

 

--- Quote Start ---  

I plan to use flash memory but I dont know the setting in SOPC, not sure of the verilog code for the signal connection and i dont know how to access the flash memory? is it possible that you help me out with some basic info? thanks! 

--- Quote End ---  

 

I can anwer you on specific issues but I can't write here all the information you require, since it seems you are starting from scratch. 

You'd better take a reference design using flash memory and learn from it, as anyone else here has probably done. On Altera website you'll find plenty of documentation and samples. 

You can also search the forum for useful hints. 

 

Regards
0 Kudos
Altera_Forum
Honored Contributor II
344 Views

thanks for the reply

0 Kudos
Reply