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

Incorrect read data from sdram in NIOS using IORD_16Direct

Altera_Forum
Honored Contributor II
1,291 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
385 Views

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

0 Kudos
Altera_Forum
Honored Contributor II
385 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)
0 Kudos
Reply