I am using IOWR_32DIRECT to write contents in the on-chip ram and using IORD_32DIRECT to read from the same address where I performed write operation. Upto few memory location the write and read data...
I had created a simple design that consists of clock, OCR, Nios II, jtag uart and data in/out component. The OCR address is range from 0x40000 (Base) to 0x657ff (End). The corresponding decimal for 0x40000 (Base) and 0x657ff (End) are 262144 and 415743 respectively.
I had created a code which loops to IOWR_32DIRECT and IORD_32DIRECT the data for each OCR address. The first data is 262144 which being incremented by 1 for each loop until 415743. In the terminal, I'm getting decimal 415743 for address 0x657ff means the data are matching with each address respectively. Attached the project file below for your reference.
Code:
# include <stdio.h>
# include "system.h"
# include "io.h"
#define BASE_ADDRESS ONCHIP_MEM_BASE
#define END_ADDRESS 0x657FF
int main() {
int i = 262144;
unsigned int addr;
for (addr = BASE_ADDRESS; addr <= END_ADDRESS; addr++) {
Hi, Thank you for your reply. I will have a look into the solution that you provided. I have a doubt. The following is how I try to perform write and read.
for (addr = 0; addr <= END_ADDRESS; addr += 4) {
IOWR_32DIRECT(BASE_ADDRESS, addr, i);
}
for (addr = 0; addr <= END_ADDRESS; addr += 4) {
value = IORD_32DIRECT(BASE_ADDRESS, addr); printf("Address: 0x%x, Value: %d\n", addr, value);
}
What is the key difference between the your code and the above one. Why is it failing to provide same result here.? Can you provide any insight / idea on this?