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.

printf() after IORD always -1

Altera_Forum
Honored Contributor II
803 Views

Hi, 

I wrote a very simple Verilog module. This module is an Avalon slave on Nios II. It has 2 registers that can be read and write. I implemented it on a SoPC with where I created: 

-the Nios II 

-the jtag 

-the SDRAM 

-my Verilog module. 

I instantied this SoPC on a Top level module also with a PLL to give the right clock to SDRAM. I'm using a DE0 Nano board. 

Then I wrote also a simple C program: 

 

#include "system.h"# include "stdio.h"# include "io.h" # define REG_BASE (*(volatile unsigned int*) REGISTRI_0_BASE) int main(){ long int a,b; a=IORD(REG_BASE, 0); printf("%ld",a); IOWR(REG_BASE, 0, 12); IOWR(REG_BASE, 1, 1); a=IORD(REG_BASE, 0); printf("%ld",a); b=IORD(REG_BASE, 1); printf("%ld",b); while(1){ }; } 

 

This program give this output: 

-1 -1 -1 

But i expected 

0 12 1 

Do you know why? Do you need my verilog code? 

Thank you
0 Kudos
1 Reply
Altera_Forum
Honored Contributor II
79 Views

The verilog would probably help. Thanks!

Reply