- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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.
Link Copied
1 Reply
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi there,
Is your button input de-bounced? If not it could generate a series of consecutive interrupt requests so that as soon as you leave the ISR it re-enters again. If you run your code, rather than step through it, what happens? I'd guess that it would change the state of your LEDs, but in a somewhat erratic fashion. If your button inputs are debounced to provide a single clean edge, there should be no problem. Cheers
Reply
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page