Chapter 5 Power Supply / CPU
5- 15

1) Scan program

-. The scan program is executed regularly in every scan from 0 step to last step.
-. When interrupts has occurred, CPU pauses scan program and executes corresponding interrupt program first.
-. When this interrupt program finished, scan program is to resume.

2) Interrupt program

-. When an interrupt occurs, the CPU module will stop the current operation and execute the corresponding interrupt routine
first. After finish the interrupt routine, the CPU resume the sequence program from the stopped step.
-. MASTER-K102S series provides 3 types of interrupt.
The TDI (Time driven interrupt) occurs with the constant period
The PDI (Process driven interrupt) occurs with the status of external input.
The HSCDI(High speed counter driven interrupt) occur with comparison task signal from high speed counter.
(Standard type only)
5.4.3 Interrupt Programs

1) Usage of interrupt program

(1) Before to use interrupt function in sequence program, the parameter setting should be done properly. 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.
(2) 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.
(3) When multiple interrupt factors occur simultaneously, interrupt routines are executed according to the priority given to
the each interrupt. 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.
Following figure show how CPU handles multiple interrupts
Pro
g
ram starts
Interrupt 2 occurs
Stop main program and execute interrupt routine 2
Interrupt 1 occurs
(
hi
g
her priorit
y)
Stop routine 2 and run routine 1
Finish routine 1 and return to routine2
Scan 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