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

IRQ not detected from C program.

Altera_Forum
Honored Contributor II
1,215 Views

Hello 

 

I wrote a simple program to start learning IRQ programming. 

I created a simple SOPC custom component (called simper_irq). This is the HDL: 

 

pastebin.com/9fyfZQtL 

 

Also, I created a simple program in C. This is the source: 

 

pastebin.com/bmChv4vh 

 

The value of flag should increase (at least once). However, it's the same all the time. 

 

I can't see where I'm wrong. 

 

Could anybody help me? 

 

Thanks a lot.
0 Kudos
5 Replies
Altera_Forum
Honored Contributor II
491 Views

I can't see the attachments

0 Kudos
Altera_Forum
Honored Contributor II
491 Views

Here we go again. 

 

There's no attachements. These are the links: 

 

http://pastebin.com/9fyfzqtl 

 

http://pastebin.com/bmchv4vh 

 

 

Thanks.
0 Kudos
Altera_Forum
Honored Contributor II
491 Views

I'm not an expert of custom sopc component. 

Have you associated the irq_port signal to the avalon irq line? I think this should be in the _hw.tcl file. 

Other remark: in the HDL you assign irq a high level but never clear it. I think this is not correct. 

The C code is correct, provided SIMPLER_IRQ_0_IRQ really refers to your component irq. Again: in the isr you must reset the irq otherwise it will retrigger perpetually
0 Kudos
Altera_Forum
Honored Contributor II
491 Views

have you include the irq header? 

 

 

--- Quote Start ---  

#include <sys/alt_irq.h> 

--- Quote End ---  

0 Kudos
Altera_Forum
Honored Contributor II
491 Views

You shouldn't cast your function pointer to the interrupt handler and it should be with the correct prototype: 

void simpler_interrupts(void *context, alt_u32 id); 

As flyinghigh says, you should also include the alt_irq.h file to get the correct declaration for the register function. 

Check also the code returned by alt_irq_register()
0 Kudos
Reply