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++
12747 Discussions

why cann't it recive interrupt

Altera_Forum
Honored Contributor II
1,770 Views

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; 

}
0 Kudos
5 Replies
Altera_Forum
Honored Contributor II
538 Views

help me

0 Kudos
Altera_Forum
Honored Contributor II
538 Views

Which design (Quartus) are you using?

0 Kudos
Altera_Forum
Honored Contributor II
538 Views

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&#39;ll see how the buttons are handled.

0 Kudos
Altera_Forum
Honored Contributor II
538 Views

1. I use quartus 

// 

2. I refred to the software example,but the button can not handled. 

// 

3. is my program error ????
0 Kudos
Altera_Forum
Honored Contributor II
538 Views

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&#39;s value can change but the interrup funtionstatic void handle_button_interrupts(void* context, alt_u32 id) can not respone 

i need help  

thank!!!!!!
0 Kudos
Reply