Forum Discussion

Altera_Forum's avatar
Altera_Forum
Icon for Honored Contributor rankHonored Contributor
15 years ago

IRQ not detected from C program.

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.

5 Replies

  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    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
  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    have you include the irq header?

    --- Quote Start ---

    #include <sys/alt_irq.h>

    --- Quote End ---

  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

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