UTMC APPLICATION NOTE _______________________________________________________________ UT69R000 Interrupt Architecture The following outlines an instruction sequence that protects un-interruptible code segments from external interrupts. Figure 1 depicts a main program that accesses two service routines and numerous interrupt service routines. During execution of the main program and service routine # 2 all interrupts are un-masked and enabled. Execution of service routine #1 requires masking and disabling of external interrupts to prevent interruption. Figure 1. Program Code Block Diagram Service Routine #2 Main Body of Program Service Routine #1 Interrupt Service Routine(s) The UT69R000 requires execution of following sequences of instructions prior to calling a routine that requires protection from interrupts. MOV RD, 0000 OTR RD, MK ; clear mask register NOP NOP CALL RD, SRV_RTNE2; branch to protected service routine Immediately following the call instruction (i.e., branch to protected service routine), execute OTR R0, DSBL instruction to disable interrupts. The combination of masking and disabling prevents any latent interrupt vectors from within the protected service routine. After execution of the protected service routine, restore the mask register (OTR RD,MK), pop return value in RD (POP 1/96 Page 1 of 2 RD, RS), enable interrupts (OTR RD, ENBL), and execute a branch back to main program (CALL RD, RS). MOV RD, XXXX16 OTR RD, MK ; re-store mask register POP RD, RS ; establish return value OTR RD, ENBL ; enable interrupts CALL RD, MAIN; branch to protected service routine 1/96 Page 2 of 2