Forum Discussion

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

Problem : Program stays in the ISR routine....

Hi,

I want to generate a simple Push Button ISR routine...

But my code didn't work...

The interrupt occurs but the program still in the ISR routine...

Here the declaration of the init_button_pio()


    static void init_button_pio()
    {
        /* Recast the edge_capture pointer to match the
        alt_irq_register() function prototype. */
        void* edge_capture_ptr = (void*) &edge_capture;
        /* Disable button interrupts. */
        IOWR_ALTERA_AVALON_PIO_IRQ_MASK(button_BASE, 0x0);
        /* Reset the edge capture register. */
        IOWR_ALTERA_AVALON_PIO_EDGE_CAP(button_BASE, 0x1);
        
        /* Register the ISR. */
        alt_irq_register( button_IRQ, edge_capture_ptr, handle_button_interrupts );
       
        /* Enable button interrupts. */
        IOWR_ALTERA_AVALON_PIO_IRQ_MASK(button_BASE, 0x1);
    }

And, here the ISR routine :


    static void handle_button_interrupts(void* context, alt_u32 id)
    {
        /* cast the context pointer to an integer pointer. */
        volatile int* edge_capture_ptr = (volatile int*) context;
        /*
        * Read the edge capture register on the button PIO.
        * Store value.
        */
        *edge_capture_ptr = IORD_ALTERA_AVALON_PIO_EDGE_CAP(button_BASE);
        
        /* Write to the edge capture register to reset it. */
        IOWR_ALTERA_AVALON_PIO_EDGE_CAP(button_BASE, 0x0);
        /* MY CODE*/
        IOWR_ALTERA_AVALON_PIO_DATA(leds_BASE, ledCount ++);
        
         
        /* reset interrupt capability for the Button PIO. */
        IOWR_ALTERA_AVALON_PIO_IRQ_MASK(button_BASE, 0x1);
    }

I don't understand why my code is staying in the ISR, I reset the edge capture register...

Thank you for your help.

2 Replies

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

    Hello,

    I've responded to your post on the NIOS forum with one suggestion, but also you could try using the great suggestion made by thepancake on the R.I.P. thread i.e. search the cached results from the NIOS forum using Google. e.g. I tried:

    iowr_altera_avalon_pio_edge_cap site:niosforum.com

    in a Google search and found pages of threads that should be interesting (make sure you look at the cached pages because the actual pages have largely been lost).

    I don't know how long these cached pages will remain available.

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

    Thank you !

    The most useful information was not about my problem but this way to get the post viewed with the cache searched !!

    Thank you