Forum Discussion
Altera_Forum
Honored Contributor
16 years agoPIO set and clear bits
Hi! I am using a Nios II in my Cyclone II FPGA. I configured the Nios with a 18bit output-PIO. When i use the macro IOWR_ALTERA_AVALON_PIO_DATA() i can easily turn my leds on and off. Looking ...
Altera_Forum
Honored Contributor
16 years agoOk, now the "Enable individual bit setting/clearing" option in the sopc builder is checked for my pio (it must be the right pio because i only have one).
I regenerated the BSP in the "Nios II 9.1 Software Build Tools for Eclipse". Afterwards i did a full rebuild. Result: The macros IOWR_ALTERA_AVALON_PIO_SET_BITS() and IOWR_ALTERA_AVALON_PIO_CLEAR_BITS() still do not work. From the debug messages i can see that they must have been called ("Msg = set_bits", "Msg = clear_bits"). Is there any possibility to check if the pio now really has the set/clear registers? My source code: # include "sys/alt_stdio.h"# include "sys/alt_sys_wrappers.h"# include "system.h"# include "altera_avalon_pio_regs.h"# include "Msg.h"# include "Str.h"# include "io.h" static char c; static int n; int main() { alt_putstr("\n\nNios ii speaking...\n"); /* Event loop never exits. */ while (1) { n = read(0,&c,1); // read one char from stdin/0 if( n == 1 ) { Msg_DataIn(c); } if( Msg_Available() ) { alt_printf("The message is: %s\n",Msg()); if( Str_Equal(Msg(),"set_bits") ) { alt_putstr("Msg = set_bits\n"); IOWR_ALTERA_AVALON_PIO_SET_BITS(PIO_0_BASE, 0x0003FFFF); } if( Str_Equal(Msg(),"clear_bits") ) { alt_putstr("Msg = clear_bits\n"); IOWR_ALTERA_AVALON_PIO_CLEAR_BITS(PIO_0_BASE, 0x0003FFFF); } if( Str_Equal(Msg(),"on") ) { alt_putstr("Msg = on\n"); IOWR_ALTERA_AVALON_PIO_DATA(PIO_0_BASE, 0x0003FFFF); } if( Str_Equal(Msg(),"off") ) { alt_putstr("Msg = off\n"); IOWR_ALTERA_AVALON_PIO_DATA(PIO_0_BASE, 0x00000000); } Msg_Clear(); // alt_putchar(c); // write(1,&c,1); // write one char to stdout/1 } } return 0; }