Nios® II Embedded Design Suite (EDS)
Support for Embedded Development Tools, Processors (SoCs and Nios® II processor), Embedded Development Suites (EDSs), Boot and Configuration, Operating Systems, C and C++
Announcements
Intel Support hours are Monday-Fridays, 8am-5pm PST, except Holidays. Thanks to our community members who provide support during our down time or before we get to your questions. We appreciate you!

Need Forum Guidance? Click here
Search our FPGA Knowledge Articles here.
12436 Discussions

Incorrect read data from sdram in NIOS using IORD_16Direct

Altera_Forum
Honored Contributor II
1,065 Views

Hello, i have a problem with reading data from sdram in nios using IORD_16direct. There is my code of sending data to sdram. 

 

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

int chromosome[30] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29 }; 

 

 

int randomFirstPoint = onGetRandom(0, 29); 

int randomSecondPoint = onGetRandom(0, 29); 

 

 

int buff = chromosome[randomFirstPoint]; 

chromosome[randomFirstPoint] = chromosome[randomSecondPoint]; 

chromosome[randomSecondPoint] = buff; 

 

 

for (j = 0; j < 30; j++) { 

IOWR_16DIRECT(DRAM_BASE + count, 0, chromosome[j]); 

count++; 

 

and there is my code of redaing from sdram 

 

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

int value = IORD_16DIRECT(DRAM_BASE + i, 0); 

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

 

output is  

 

read value = 1 

read value = 0 -- incorrect value instead of this would be 2 

read value = 3 

read value = 16128 -- incorrect value instead of this would be 4 

read value = 5 

read value = 0 -- incorrect value instead of this would be 6 

read value = 7 

read value = 16128 -- incorrect value instead of this would be 8 

read value = 9 

read value = 0 -- incorrect value instead of this would be 10 

and so on...
0 Kudos
2 Replies
Altera_Forum
Honored Contributor II
159 Views

I don't undestand what it is a forum if nobody can't help me?

Altera_Forum
Honored Contributor II
159 Views

Hi Nurbek, 

 

Debug the code using following steps. 

1.Print the write and read address and verify. 

2.Or instead of for loop can try something much simpler(write to two address and read from the two without loop) if u succeed try with loop.  

 

Best Regards, 

Anand Raj Shankar 

(This message was posted on behalf of Intel Corporation)
Reply