
Chapter 2. Functions
2-20
2.6
Special functions of MASTER-K series
2.6.1
Interrupt functions
(Applicable for K200S / K300S / K1000S )
When an interrupt occurs, the CPU module will stop the current operation and execute the
corresponding interrupt routine. After finish the interrupt routine, the CPU resume the sequence
program from the stopped step.
MASTER- K series provides 2 types of interrupt. The TDI (Time driven interrupt) occurs with the
constant period, and PDI (Process driven interrupt) occurs with the status of external input.
Before to use interrupt function in sequence program, the parameter setting should be done
properly. (See 2.4.6 for parameter setting) Then the corresponding interrupt routine should be
written after END instruction. (Refer chapter 4 for details) If interrupt routines are not matched with
parameter settings, an error occurs and the operation of CPU will be stopped.
To execute an interrupt routine, use the EI instruction to enable the corresponding interrupt. The
interrupt routine is not executed if an interrupt factor occurs before execution of an EI instruction.
Once an interrupt is enabled with EI instruction, it keeps the enabled status until DI instruction is
executed to disable the interrupt. When a CPU is turned to RUN mode, all interrupts are disabled
by default.
When multiple interrupt factors occur simultaneously, interrupt routines are executed according to
the priority given to the each interrupts. If an interrupt factor that has higher priority occurs while
other interrupt that has lower priority are executing, the interrupt routine of lower priority will be
stopped and the interrupt of higher priority will be executed first. The following figure shows how a
CPU handle multiple interrupts.
<Figure 2. 5 The execution order of multiple interrupts>
Program starts
Interrupt 2 occurs
Stop main program and execute interrupt
routine 2
Interrupt 1 occurs (higher priority)
Stop routine 2 and run routine 1
Finish routine 1 and return to routine2
Main Program
Interrupt routine 1
Interrupt routine 2
1
3
5
6
7
2
4
Finish routine 2 and return to main program
1
2
3
4
5
6
7