Nios® V/II Embedded Design Suite (EDS)
Support for Embedded Development Tools, Processors (SoCs and Nios® V/II processor), Embedded Development Suites (EDSs), Boot and Configuration, Operating Systems, C and C++
12648 Discussions

Problem with getting IRQ from PIO (Really simple i guess)

Altera_Forum
Honored Contributor II
1,437 Views

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

0 Kudos
2 Replies
Altera_Forum
Honored Contributor II
369 Views

you not only need to enable interrupts on the PIO core, but on the NIOS side as well. 

 

you can enable and disable interrupts using alt_irq_enable and alt_irq_disable. 

 

try adding this after you register your ISR.  

 

alt_irq_enable(PIO_0_IRQ);
0 Kudos
Altera_Forum
Honored Contributor II
369 Views

Thanks a lot!! It works

0 Kudos
Reply