Forum Discussion

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

NIOS II Interrupt Registration

Hello,

My question is with regard to using NIOS II Interrupts on a Cyclone IV E board.

The NIOS II was designed using the QSYS module within quartus and a VIC was added in order to allow for external hardware interrupts. I then register the interrupt in C-code using the enhanced API. The function then returns a success (0 on success) yet the program does not hand over functionality to the ISR.

Here's my registration function:

   int check = alt_ic_isr_register(ENCODER_INPUT_A_IRQ_INTERRUPT_CONTROLLER_ID , // Encoder A ID from System.h
		               ENCODER_INPUT_A_IRQ,                            // Encoder A macro from System.h
		               nios_isr,                                       // Programmer defined Interrupt service routine (seeabove)
		               base,                                           // Optional, unused, only concerned about a single hardware interrupt
		               NULL);                                          // Flag -- Reserved

and my ISR looks like this:

void nios_isr(void* context) {
	count++;
}

Any suggestions? (Note: base is declared as null.)

2 Replies

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

    Are you sure the interrupt is actually triggered? The IRQ signal must stay high until the CPU sees it and runs the ISR. Then it should be the ISR that writes something to the component to say it can deassert the IRQ signal again.

    Is your count variable defined as volatile? You should do that to prevent the compiler from running some optimisations that could hide the update done by the isr routine.
  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    Just a question: Is the interrupt signal hanging? You may need to clear the irq source before you leave the isr.