Forum Discussion
Altera_Forum
Honored Contributor
15 years agoProgramming IO ports in NIOS II
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....
4 Replies
- Altera_Forum
Honored Contributor
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! - Altera_Forum
Honored Contributor
- Altera_Forum
Honored Contributor
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) .... - Altera_Forum
Honored Contributor
This was indeed very helpful.Now im able to program my nios IOs.Thankyou.