When servicing an interrupt on real devices, GIE in INTCON is cleared to stop further interrupts from being serviced simultaneously, however in gpsim it remains set. This is true both when looking at the register view in the GUI and if reading the register within the interrupt service routine.
Furthermore, the instruction RETFIE is supposed to set the GIE flag but that also does not occur meaning that if INTCON is written inside the interrupt service routine with GIE cleared it remains clear on return and no further interrupts are serviced.
Additionally, if clearing and re-setting GIE before RETFIE is executed, no new interrupt is taken even though a real CPU will take an interrupt at any time the interrupt flags (including GIE) allow it. This means that if the interrupt service routine is exited with RETURN instead to leave interrupts disabled, it won't be possible to later re-enable interrupts by setting GIE.
It appears that gpsim uses and another (internal) flag is used to keep track of handling interrupts instead of using GIE directly which is the cause of these non-conforming behaviors.
This behavior exist for 0.31.0. I have not tested any other versions.
Behavior seems to be generic at least for the 14 bit processors. I don't know if other families are also affected.
The attached example code show these issues for PIC12F683. By single stepping the program, it can be seen that GIE (bit 7 of INTCON) is not updated when the interrupt service routine is entered, toggling it won't retrigger the interrupt, and after returning GIE is left clear and the TMR0 interrupt not serviced again the next time T0IF is set.
Anonymous
This was supposed to be a bug, not a feature request. I can't see any way of moving it myself. Can someone with more privileges move it or should I make a new ticket?
Ticket moved from /p/gpsim/feature-requests/69/
Fixed in_interrupt flag replaced with GIE in INTCON. Affected all processors.