Altera_Forum
Honored Contributor
15 years agoProblem with getting IRQ from PIO (Really simple i guess)
int context=0;
volatile int edge_capture;
int main()
{
IOWR_ALTERA_AVALON_PIO_IRQ_MASK(PIO_0_BASE,0xF);
alt_irq_register(PIO_0_IRQ,(void*)&edge_capture, handle_pio);
while(5);
return 0;
}
static void handle_pio(void* context, alt_u32 id){
IOWR_ALTERA_AVALON_PIO_IRQ_MASK(PIO_0_BASE, 0);
/* Cast context to edge_capture's type. It is important that this be
* declared volatile to avoid unwanted compiler optimization.
*/
volatile int* edge_capture_ptr = (volatile int*) context;
/* Store the value in the Button's edge capture register in *context. */
*edge_capture_ptr = IORD_ALTERA_AVALON_PIO_EDGE_CAP(PIO_0_BASE);
IOWR_ALTERA_AVALON_PIO_EDGE_CAP(PIO_0_BASE,0);
IOWR_ALTERA_AVALON_PIO_IRQ_MASK(PIO_0_BASE,0xF);
}
Why the interrupt never happens? It's a simple PIO (1bit)that i set to 1 in my verilog code (configured to generate a rising edge irq on my SOPC).. Thanks