Forum Discussion

Altera_Forum's avatar
Altera_Forum
Icon for Honored Contributor rankHonored Contributor
19 years ago

Base addresses and system.h #define

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

2 Replies

  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    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
  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    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 ---