Altera_Forum
Honored Contributor
16 years agoEasy nios design with buttons
Hello,
I am a newbie with Quartus II and Nios II and I have been trying to do an easy nios design in order to light on a led when pressing a button. I am working on the Altera Cyclone III EP3C25F324 board. I think the problem comes from my code in nios II that I put below. I don't really know when to write "IOWR_ALTERA_AVALON_PIO_DATA(...);" maybe the problem comes from here. Plus, when I try to write some "printf", there is an error : collect2: ld returned 1 exit status make: *** [button_led.elf] Error 1 Here is my program : #include "system.h"# include "altera_avalon_pio_regs.h"# include "alt_types.h"# include "stdio.h"# include "stdlib.h" int alt_main (void) { alt_u8 led = 0x2; alt_u8 button = 0x2; IOWR_ALTERA_AVALON_PIO_DATA(LED_PIO_BASE, led); IOWR_ALTERA_AVALON_PIO_DATA(BUTTON_PIO_BASE, button); while (1) { switch (button) { case 0x1 : led=0x1; break; case 0x2 : led=0x2; break; case 0x4 : led=0x4; break; case 0x8 : led=0x8; break; } } Do someone can help me? Thank you very much, Myriam