Altera_Forum
Honored Contributor
8 years agoIncorrect read data from sdram in NIOS using IORD_16Direct
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...