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

Base addresses and system.h #define

Altera_Forum
Honored Contributor II
1,421 Views

I have an SOPC system with some custom components and 2 Altera PIO components. I am trying to write to a PIO using this function, for example: 

 

IOWR(PIO_0_BASE, 3, 0x0); // Clear edge capture register 

 

However, I get a compile error saying that PIO_0_BASE is undeclared, even though i am doing a# include "system.h" at the top of my code. Isn't that the preferred way to access components in the system? 

 

My code will work if I copy this file from system.h into my code: 

# define PIO_0_BASE 0x00010800 

 

But that defeats the purpose of having all the registers defined in one place! 

I was under the impression (from reading the niow SW dev manual) that you don't normally have to explicity# include system.h. anyway. 

 

Any ideas on what I&#39;m doing wrong? I&#39;m relatively new to C AND the Nios so this may be a C newbie error or a Nios newbie error. http://forum.niosforum.com/work2/style_emoticons/<#EMO_DIR#>/smile.gif
0 Kudos
2 Replies
Altera_Forum
Honored Contributor II
391 Views

Look at the software templates/examples. Any that need base addresses, always# include "system.h". 

 

What&#39;s more, for the PIO, you&#39;ll probably want to be including altera_avalon_pio_regs.h. 

 

Cheers, 

 

- slacker
0 Kudos
Altera_Forum
Honored Contributor II
391 Views

Thanks, slacker. 

 

Including system.h AND altera_avalon_pio_regs.h worked. 

 

 

--- Quote Start ---  

originally posted by slacker@Mar 22 2007, 11:03 AM 

look at the software templates/examples.  any that need base addresses, always# include "system.h". 

 

what&#39;s more, for the pio, you&#39;ll probably want to be including altera_avalon_pio_regs.h. 

 

cheers, 

 

- slacker 

<div align='right'><{post_snapback}> (index.php?act=findpost&pid=22429) 

--- quote end ---  

 

--- Quote End ---  

0 Kudos
Reply