Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.
When interrupt is started all other interrupts are disabled automatically by clearing GIE flag, but controller is setting corresponding flag if any interrupt event is coming. At the end of interrupt, RETFIE instruction is returning from interrupt with GIE setting (allow interrupt). If any other interrupt event is comming during interrupt, it will be executed after this interrupt.
typically when you write an interrupt service routine (ISR) the very first thing you do when entering the ISR loop is to dissable all interrupts. then you service the interrupt (fix the reason why it was called in the first place). then before exiting the ISR you enable all interrupts again.
however, if you do NOT disable all interrupts then i suppose it would be possible to call an interrupt while within an interrupt. keep in mind that the program counter only has an 8 level stack.
here is a test. set PIC chip to interrupt on some counter value... then when interrupt occurs, have the code say:
ISR: * do not disable interrups
the code gets stuck in an endless loop. while it is looping around cause an "interrupt on change" to the PIC chip. inside that ISR have an LED turn ON.
As Mr. Cool said, it can be done. Usually, after servicing an interrupt you run a retfie command that sets back the GIE bit. No one can stop you from re-enabling the interrupt before fully servicing the previous interrupt, so can be re-interrupted.
BUT, it is very risky and several things should be considered. It is very important to first acknowledge the interrupt and then set the GIE bit. Because if you don't clear the xxxIF bit, re-setting the GIE will keep firing again and again the same interrupt endlessly and poof, you're stuck...
Next have in mind that the same code at the beginning of the interrupt will be re-executed. For example, usually you save W and STATUS when entering the int and restore it on exit. If using a static save method e.g. a single memory position for each register, if you re-interrupt you will loose the initial W and STATUS values.
And of course there is always the 8-level deep stack
I guess that it would be best to use polling inside the interrupt, but only you can decide that.