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

IOWR/IORD problem, what does IORD return?

Altera_Forum
Honored Contributor II
2,052 Views

Nios2 is new to me and I'm developing a custom component on it. 

 

I have my Avalon regester interface ready. 

 

I can IOWR a integer into the regester to perform the function, but fail to IORD from the same reg. (IORD the same reg give me 0). The reg is 32 bit wide, is there anything to do with the address? 

 

It's not one of the delay problem, because i wrote a while{} loop to read it, but still, can't get what I just IOWR.  

 

It could be silly, but please answer it in detail, since i'm really new here.
0 Kudos
3 Replies
Altera_Forum
Honored Contributor II
914 Views

That should have worked. You might want to copy and paste the code fragments. Are you sure you have the readdata signal in your component wired up correctly?

0 Kudos
Altera_Forum
Honored Contributor II
914 Views

Is this a custom SOPC Component using VHDL/verilog?.  

 

Did you provide the capability of reading this register?  

 

This could also be a HW timing issue with reads and/or writes. If this is a brand new Component I would recommend simulating the component or using Signal Tap to watch the appropriate registers, control signals, and data buses.
0 Kudos
Altera_Forum
Honored Contributor II
914 Views

I am also getting the same issue, using IOWR_32DIRECT doesn't produce error and printfs after that call work, but as soon as I call IORD_32DIRECT, the printfs afterwards do not show. Does anyone know any possible reasons as to why my code is hanging up at IORD_32DIRECT? 

 

(The usleep(20000)s are a way to "flush" the stdout buffers because I was having this issue: https://www.altera.com/support/support-resources/knowledge-base/solutions/rd07292005_415.html)  

 

#include <alt_types.h>#include <io.h># include <string.h># include "system.h" # include "sys/alt_dma.h" # include "sys/alt_flash.h"# include "sys/alt_flash_dev.h"# include "sys/alt_flash_dev.h"# include "sys/alt_stdio.h"//for alt_putbufflush()# include <stdio.h> int main() { //===============Set Address=============== //int *THE_ADDRESS; //THE_ADDRESS = (int)ADDRESS_SPAN_EXTENDER_0_WINDOWED_SLAVE_BASE; int THE_ADDRESS; THE_ADDRESS = (int)SINKSOURCE_0_BASE; //===============Write=============== printf("Reading from Address: %08x \n", THE_ADDRESS); usleep(200000); printf("THE_ADDRESS: %08x \n", THE_ADDRESS); usleep(200000); int write_val = 0xffff; IOWR_32DIRECT(THE_ADDRESS,0, write_val); usleep(200000); printf("Wrote %08x to %08x \n", write_val, THE_ADDRESS); usleep(200000); //===============Read=============== usleep(200000); int val = IORD_32DIRECT(SINKSOURCE_0_BASE, 0); //PROGRAM STOPS HERE!!!!!!!!!!!!!!!!!!!!!!!!!!!!! usleep(200000); printf("Value at %08x: %08x \n", SINKSOURCE_0_BASE, val); usleep(200000); return 0; }
0 Kudos
Reply