- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I want to use the switch of one bit to touch off the signal of IRQ, this foot location is named cs, foot location connect at sw0 of board of 2c35, but button does not work....what is the problem? How can I do ?
# include "system.h"# include "alt_types.h"# include "altera_avalon_pio_regs.h"# include "sys/alt_irq.h"# include # include volatile int edge_capture; static void send_interrupts(void* context, alt_u32 id) { volatile int *edge_capture_ptr = (volatile int*) context; *edge_capture_ptr = IORD_ALTERA_AVALON_PIO_EDGE_CAP(CS_BASE); IOWR_ALTERA_AVALON_PIO_EDGE_CAP(CS_BASE, 0); } static void init_button_pio() { void* edge_capture_ptr = (void*) &edge_capture; IOWR_ALTERA_AVALON_PIO_IRQ_MASK(CS_BASE, 1); IOWR_ALTERA_AVALON_PIO_EDGE_CAP(CS_BASE, 0); alt_irq_register( CS_IRQ, edge_capture_ptr, send_interrupts); } int main () { init_button_pio(); printf("system is waiting\n"); edge_capture = 0; switch (edge_capture) { case 1: printf("button pressed\n"); break; } IOWR_ALTERA_AVALON_PIO_IRQ_MASK(CS_BASE, 0); }Link Copied
2 Replies
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Within main() don't you want to wrap the case statement with a loop? Otherwise this program will run to completion.
Also be sure that the PIO supports the type of interrupt you want. To check this go into the PIO component and verify the settings (such as the edge detection for example). What you are trying to do is documented here in case you haven't seen it: http://www.altera.com/literature/hb/nios2/n2sw_nii52006.pdf (http://www.altera.com/literature/hb/nios2/n2sw_nii52006.pdf)- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
--- Quote Start --- originally posted by badomen@Apr 16 2006, 01:05 PM within main() don't you want to wrap the case statement with a loop? otherwise this program will run to completion.
also be sure that the pio supports the type of interrupt you want. to check this go into the pio component and verify the settings (such as the edge detection for example).
what you are trying to do is documented here in case you haven't seen it: http://www.altera.com/literature/hb/nios2/n2sw_nii52006.pdf (http://www.altera.com/literature/hb/nios2/n2sw_nii52006.pdf)
<div align='right'><{post_snapback}> (index.php?act=findpost&pid=14411)
--- quote end ---
--- Quote End --- Thank you very much.

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