Community
cancel
Showing results for 
Search instead for 
Did you mean: 
Altera_Forum
Honored Contributor I
975 Views

Multiple ISR's for one Interrupt?

I'm working on a design where I need ISR's for timers that are set to 1 sec. 1/2 sec and 1/4 sec intervals. I could just create a separate timer for each function, but this seems wasteful. I had the thought of creating an interval timer that creates an interrupt at 1/4 of a second and then using counters in my c code to keep track of timing. None of these ISR's need to be running at the same time. Can I register one, and then when I'm done with it register a different isr to the same IRQ?

0 Kudos
3 Replies
Altera_Forum
Honored Contributor I
39 Views

Nios II code right? If so, I'm not 100% sure if things are designed to work this way, but it should be easy enough to try, right? You may want to surround the next call to alt_irq_register() with calls to alt_irq_disable() and alt_irq_enable(). 

 

I'll look at this further to see if there would be any more concerns about doing this, but these are my initial thoughts.
Altera_Forum
Honored Contributor I
39 Views

Maybe you can do something similar as is implemented with the Altera DMA controller. Look at the code of the driver which uses a callback function. With every new interrupt you assign a new callback.

Altera_Forum
Honored Contributor I
39 Views

Yes, nios II code. basically I'm making a game that has a 60 second time limit. If the time runs out the red leds on the dev board flash on and off at half second intervals. If the player wins the green leds flash on and off at quarter second intervals. In my main c code I am running a state machine for the game flow. I figured I could just register a different isr for the appropriate states. I won't have a chance to try until later so I figured I'd see if anyone else has tried it before. I'll definitely report back my results once I try it out. Thanks for the response. 

 

 

--- Quote Start ---  

Nios II code right? If so, I'm not 100% sure if things are designed to work this way, but it should be easy enough to try, right? You may want to surround the next call to alt_irq_register() with calls to alt_irq_disable() and alt_irq_enable(). 

 

I'll look at this further to see if there would be any more concerns about doing this, but these are my initial thoughts. 

--- Quote End ---  

Reply