4 using interrupts in application tasks, 1 basic task example – Rockwell Automation 57C419 5V-24V DC Input Module User Manual
Page 21

4Ć5
4.4
Using Interrupts in Application Tasks
Interrupts are used to synchronize software tasks with the occurrence
of a hardware event. The input module has four inputs that can be
programmed to generate an interrupt. The module allows you to
synchronize realĆworld events with application tasks to a minimum of
1.2 msec., depending on the priority level of the task receiving the
interrupt.
In order to use interrupts on the input module, it is necessary to
assign symbolic names to the interrupt control bits and the interrupt
status and control register (2). In AutoMax Version 2.1 and earlier, this
is accomplished with IODEF statements in the configuration task. See
Appendix E for an example. In AutoMax Version 3.0 and later,
symbolic names are assigned using the Programming Executive.
Note that interrupts cannot be used with input modules located in
remote racks.
Only one task may act as a receiver for the interrupt generated by an
input module. That task should declare the symbolic names assigned
to the interrupt control register and bits on the input module as
COMMON.
4.4.1
BASIC Task Example
The following is an example of a BASIC task that handles interrupts
from inputs B17, B18 and B20.
Note that the `timeout' parameter in the EVENT statement is disabled
since interrupts from this module do not generally occur on a timed
basis. The same consideration requires care in using timeĆbased
statements in loops used to read inputs from the module.
1000
COMMONISCR%
\!Interrupt Status/Control Register
1001
COMMONLATCH EDGE B17@
\!Latch edge, input B17
1002
COMMONLATCH EDGE B18@
\!Latch edge, input B18
1003
COMMONLATCH EDGE B20@
\!Latch edge, input B20
1005
!
1010
COMMONLATCH STATUS B17@
\!Latch status, input B17
1011
COMMONLATCH STATUS B18@
\!Latch status, input B18
1012
COMMONLATCH STATUS B20@
\!Latch status, input B20
1015
!
1020
COMMONINTRP ENABLE B17@
\!Interrupt enable, input B17
1021
COMMONINTRP ENABLE B18@
\!Interrupt enable, input B18
1022
COMMONINTRP ENABLE B20@
\!Interrupt enable, input B20
1025
!
1030
COMMONLATCH RESET B17@
\!Latch reset, input B17
1031
COMMONLATCH RESET B18@
\!Latch reset, input B18
1032
COMMONLATCH RESET B20@
\!Latch reset, input B20
1050
!
1060
LOCAL B17 CNT%
\!Interrupt counter, input B17
1070
LOCAL B18 CNT%
\!Interrupt counter, input B18
1080
LOCAL B20 CNT%
\!Interrupt counter, input B20
2000
!
2001
!
Define the edge transition that will generate an interrupt
2002
!
2010
LATCH EDGE B17@ = FALSE
\!Off to on
2011
LATCH EDGE B18@ = FALSE
\!Off to on
2012
LATCH EDGE B20@ = TRUE
\!On to off
3000
!
3001
!
The following statement connects the name HW EVENT to the
3002
!
Interrupt defined in ISCR%. The event name chosen should