Forum Discussion

Altera_Forum's avatar
Altera_Forum
Icon for Honored Contributor rankHonored Contributor
15 years ago

Problem 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

2 Replies

  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    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);