Nios® V/II Embedded Design Suite (EDS)
Support for Embedded Development Tools, Processors (SoCs and Nios® V/II processor), Embedded Development Suites (EDSs), Boot and Configuration, Operating Systems, C and C++

about IRQ problem...help!

Altera_Forum
Honored Contributor II
1,214 Views

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

}
0 Kudos
2 Replies
Altera_Forum
Honored Contributor II
503 Views

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)
0 Kudos
Altera_Forum
Honored Contributor II
503 Views

 

--- 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.
0 Kudos
Reply