Altera_Forum
Honored Contributor
20 years agoabout IRQ problem...help!
I want to use the switch of one bit to touch off the signal of IRQ, this foot location is named cs, foot location connect at sw0 of board of 2c35, but button does not work....what is the problem? How can I do ?
# include "system.h"# include "alt_types.h"# include "altera_avalon_pio_regs.h"# include "sys/alt_irq.h"# include # include volatile int edge_capture; static void send_interrupts(void* context, alt_u32 id) { volatile int *edge_capture_ptr = (volatile int*) context; *edge_capture_ptr = IORD_ALTERA_AVALON_PIO_EDGE_CAP(CS_BASE); IOWR_ALTERA_AVALON_PIO_EDGE_CAP(CS_BASE, 0); } static void init_button_pio() { void* edge_capture_ptr = (void*) &edge_capture; IOWR_ALTERA_AVALON_PIO_IRQ_MASK(CS_BASE, 1); IOWR_ALTERA_AVALON_PIO_EDGE_CAP(CS_BASE, 0); alt_irq_register( CS_IRQ, edge_capture_ptr, send_interrupts); } int main () { init_button_pio(); printf("system is waiting\n"); edge_capture = 0; switch (edge_capture) { case 1: printf("button pressed\n"); break; } IOWR_ALTERA_AVALON_PIO_IRQ_MASK(CS_BASE, 0); }