beautypg.com

4 operations after interrupt acceptance – NEC PD17062 User Manual

Page 116

background image

116

µ

PD17062

11.4 OPERATIONS AFTER INTERRUPT ACCEPTANCE

When an interrupt is accepted, the following processing sequence is executed:

(1) The interrupt enable flip-flop or interrupt request flag corresponding to the accepted interrupt is reset.

In other words, a write protected state is set.

(2) The stack pointer value is decreased by 1.

(3) The contents of the program counter are saved in the address stack register indicated by the stack pointer.

The contents of the program counter become the program memory address after the contents at interrupt

acceptance. For a branch instruction, the contents become the branch destination address. For a

subroutine call instruction, the contents become the called address. If a skip instruction satisfies the skip

conditions, an interrupt is accepted after the next instruction is executed as the NOP instruction.

Therefore, the contents of the program counter become the skipped address.

(4) The lower two bits of the bank register (BANK: address 79H) and the index enable flag (IXE: bit b

0

of

address 7FH) are saved in the interrupt stack.

(5) The contents of the vector address generator corresponding to the accepted interrupt are transferred to

the program counter. In other words, processing is branched to the interrupt processing routine.

The processing in (1) to (5) above is executed during one special instruction cycle (2

µ

s, or 12

µ

s when the

IDC is operating) without normal instruction execution.

This instruction cycle is called the interrupt cycle. The processing from interrupt acceptance to branching

to the corresponding vector address requires one instruction cycle.

11.5 RETURNING CONTROL FROM INTERRUPT PROCESSING ROUTINE

To return control from the interrupt processing routine to the processing executed at interrupt acceptance,

use the exclusive RETI instruction. When the RETI instruction is executed, the following processing sequence

is executed.

(1) The contents of the address stack register indicated by the stack pointer are restored in the program

counter.

(2) The contents of the interrupt stack are restored in the lower two bits of the bank register or bit b

0

of the

index enable flag.

(3) The stack pointer value is increased by 1.

The processing in (1) to (3) above is executed during one instruction cycle of the RETI instruction. The only

difference between the RETI instruction and subroutine return instruction RET or RETSK is in the restoration

of the contents of the bank register or index enable flag in (2) above.