I have an example (it works fine):
# include "test_II.h"# define switches_base 0x00101030# define leds_base 0x00101000# define push_base 0x00101020
// *** Maneja la interrupcion ****
static void push_isr(void* context, alt_u32 id){
volatile int *function=(volatile int*) context;
*function=IORD_ALTERA_AVALON_PIO_EDGE_CAP(push_base);
IOWR_ALTERA_AVALON_PIO_EDGE_CAP(push_base,0);
IOWR_ALTERA_AVALON_PIO_IRQ_MASK(push_base,0xF);
}
//*************************************
int main(void)
{ volatile int function=0;
alt_u32 switches;
// Activas la interrupcion.
IOWR_ALTERA_AVALON_PIO_IRQ_MASK(push_base,0xF);
alt_irq_register(PUSH_IRQ,(void*)&function, push_isr);
while(1){
switch(function){
case 0x1:
switches= IORD_ALTERA_AVALON_PIO_DATA(switches_base);
IOWR_ALTERA_AVALON_PIO_DATA(leds_base,switches);
function=0;
break;
default:
break;
}
}
return 0;
}
Maybe it could help you...