Forum Discussion
Altera_Forum
Honored Contributor
15 years agoPIO ports are memory mapped.
For a PIO input you check the bits corresponding to the input you want to test. For a PIO output you change the bits. Nios tools provide some macros to easily work with PIOs. Say PIO_BASE is base address (assigned in sopc builder) of a 16 wide PIO output port; this will set high outputs 2,5,6,7,8,12 of a 16 IOWR_ALTERA_AVALON_PIO_DATA(PIO_BASE, 0x10F2); Similar for an input port. This will test if input 6 is high: if (IORD_ALTERA_AVALON_PIO_DATA(PIO_BASE) & 0x0040) ....