- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
why cann't it recive interrupt,when the key is pressed, the led shows nothing
# include "system.h"# include "altera_avalon_pio_regs.h"# include "alt_types.h"# include "D:\document\nios\low_cost\h\alt_irq.h"# include <stdio.h># include <unistd.h> volatile int edge_capture; static void handle_button_interrupts(void* context, alt_u32 id) { volatile int* edge_capture_ptr = (volatile int*) context; *edge_capture_ptr = IORD_ALTERA_AVALON_PIO_EDGE_CAP(BUTTON_PIO_BASE); IOWR_ALTERA_AVALON_PIO_EDGE_CAP(BUTTON_PIO_BASE, 0); } static void init_button_pio() { void* edge_capture_ptr = (void*) &edge_capture; /* Enable all 4 button interrupts. */ IOWR_ALTERA_AVALON_PIO_IRQ_MASK(BUTTON_PIO_BASE, 0xf); /* Reset the edge capture register. */ IOWR_ALTERA_AVALON_PIO_EDGE_CAP(BUTTON_PIO_BASE, 0x0); /* Register the interrupt handler. */ alt_irq_register( BUTTON_PIO_IRQ, edge_capture_ptr, handle_button_interrupts ); } int main (void) { IOWR_ALTERA_AVALON_PIO_DATA(LED_PIO_BASE, 0); # ifdef BUTTON_PIO_BASE init_button_pio();# endif // while( 1 ) { if (edge_capture != 0) { IOWR_ALTERA_AVALON_PIO_DATA(LED_PIO_BASE, 0xf); } } return 0; }Link Copied
5 Replies
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
help me
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Which design (Quartus) are you using?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
If you take a look at a Nios reference design like standard or full, there are interupt buttons as well. Then if you look at the board diagnostic software example you'll see how the buttons are handled.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
1. I use quartus
// 2. I refred to the software example,but the button can not handled. // 3. is my program error ????- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I have the same problem
my system consists of button_pio led_pio onchip_ram the capture register can catch the rising edge and capture's value can change but the interrup funtionstatic void handle_button_interrupts(void* context, alt_u32 id) can not respone i need help thank!!!!!!
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