Nios® II Embedded Design Suite (EDS)
Support for Embedded Development Tools, Processors (SoCs and Nios® II processor), Embedded Development Suites (EDSs), Boot and Configuration, Operating Systems, C and C++
Announcements
Intel Support hours are Monday-Fridays, 8am-5pm PST, except Holidays. Thanks to our community members who provide support during our down time or before we get to your questions. We appreciate you!

Need Forum Guidance? Click here
Search our FPGA Knowledge Articles here.

having trouble with interrupt

Altera_Forum
Honored Contributor II
766 Views

Hello everyone ,  

 

I'm try for a very long time to do a simple interrupt with nios ii. 

this is my problem: 

i have button in sratix ii dev kit and all i want to do in nios is just to turn on led (with interrupt) when the button is pressed. 

i defined rising_edge and all the others in sopc and i checked that the button is connected to the sopc module in quartus. 

everything passed the compile but when i run the debug the program ignore my clicks on the button and do nothing. 

 

this is my program: 

 

the program ignore my clicks and doesn't get to here :\ 

void led_interrupt() 

//turn on led// 

//Delay// 

 

void main() 

alt_irq_registerr(button_IRQ, led_interrupt ); 

//turn off led// 

while(1); // waiting for interrupt; 

 

 

 

I hope somebody can help me. 

 

sorry for my bad english:) 

 

thanks you(:
0 Kudos
3 Replies
Altera_Forum
Honored Contributor II
81 Views

Add these before alt_irq_register: 

IOWR_ALTERA_AVALON_PIO_IRQ_MASK(button_IRQ, <irq_bit_mask>); // enable irq 

IOWR_ALTERA_AVALON_PIO_EDGE_CAP(button_IRQ, <irq_bit_mask>); // clear irq  

 

You also need to clear the edge capture bit in irq handler function, otherwise the irq will keep on retriggering. 

 

Also make sure of these points: 

- in qsys/sopc button pio must be defined with interrupt capability enabled 

- the button pio is correctly routed to fpga pin and pio is working: begin with polling the pio in while loop to test this point.
Altera_Forum
Honored Contributor II
81 Views

Hi, 

 

Could you elaborate on the definition of "irq_bit_mask"? 

 

In SOPC builder, my PIO IRQ (width = 1 bit) is on IRQ line 9. 

 

Does this mean my "irq_bit_mask" is bit 9?
Altera_Forum
Honored Contributor II
81 Views

IOWR_ALTERA_AVALON_PIO_IRQ_MASK(button_base_address,1); // enable irq 

IOWR_ALTERA_AVALON_PIO_EDGE_CAP(button_base_address, 1); // clear irq  

Infact you are using PIO bit 0, then mask = 1. 

For clarity: if you had a 8 bit wide PIO and you connected the button to pio_input[6], then you'd had irq_bit_mask=0x40 

 

IRQ line nr is involved only in alt_irq_register() call.
Reply