Forum Discussion
Altera_Forum
Honored Contributor
14 years agoTry just displaying a binary count on the LEDs, this should increment once per button push. The usleep call should take care of debounce.
# include "unistd.h" //provides usleep function unsigned int gCount //global counter static void handle_button_interrupts(void* context, alt_u32 id) { gCount++; IOWR_ALTERA_AVALON_PIO_DATA(LED_PIO_BASE, (gCount & 0x0F)); usleep(1000); //wait for 1 ms before clearing the button IOWR_ALTERA_AVALON_PIO_EDGE_CAP(BUTTON_PIO_BASE, 0); } in init_button_pio() add the line "gCount = 0;" This should show a binary count on the LEDs that increments each time the interrupt occurs.