Hi,
I have an interrupt problem for which I'm trying to find a solution.
I need a fastLoop() function that has to be called each 1 mS and a slowLoop() function that has to be called each 10 mS. The slowLoop can run for more than 1 mS and thus must be interruptable bij the fastLoop. Both loops need to be interrupt based.The FIQ is already in use so I can only use the IRQ level interrupt for this. I hope I do not need to go into the compete re-entrant IRQ solution.
I may have a solution, but I'm not sure if it will work. This is the idea:
An IRQ is generated each 1 mS and the irqRoutine() interrupt function is called.This irqRoutine() does the following:
- First the fastLoop() function is called so it can do its work.
- After the fastLoop() function a counter is incremented.
- When this counter reaches 10 the counter wil be reset and the slowLoop() function is called.
- Return from IRQ
The slowLoop() function will do the following:
- Save the current IRQ interrupt masks
- Enable only the irqRoutine() IRQ mask
- Re-enable the processor IRQ interrupts
- Doing the slowLoop stuff
- Disable the processor IRQ interrupts
- Restoring the IRQ interrupt maks
This way a new irqRoutine() interrupt can interrupt the previous one as soon as it is doing the slowLoop stuff. I can make it such that the new irqRoutine() wil never call the slowLoop() if the previous slowLoop() is not finished yet. So the irqRoutine is only interrupted by one new irqRoutine().
Will this work?
Or do I need to do more than just enabling a new irqRoutine() inside the irqRoutine()?