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

Programming IO ports in NIOS II

Altera_Forum
Honored Contributor II
1,314 Views

Hi, Im new to nios ii software programming.I need to implement a hardware on an fpga.But as there are no sufficient pins availabile on the board,i thought of using a nios 2 processor to give external inputs to the fpga.As im new to nios ii im not able to program the PIOs of the nios ii properly.Can anyone help me by giving some sample codes for this....

0 Kudos
4 Replies
Altera_Forum
Honored Contributor II
388 Views

Adding extra nios cpu won't magically generate extra IO pins! 

 

Your best hope is to add external logic to multiplex/demultiplex the information, these days that would typically be done in a small fpga!
0 Kudos
Altera_Forum
Honored Contributor II
388 Views

Thankyou for your suggestion.actually im a student and is interested in learning nios ii.so i thought of using it. 

I know that the pio core provides upto 32 IO ports.But how can i access each one of them.im familiar with 8051 programming.can u help me with this.
0 Kudos
Altera_Forum
Honored Contributor II
388 Views

PIO 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) ....
0 Kudos
Altera_Forum
Honored Contributor II
388 Views

This was indeed very helpful.Now im able to program my nios IOs.Thankyou.

0 Kudos
Reply