2 control block task example – Rockwell Automation 57C419 5V-24V DC Input Module User Manual

Page 23

Advertising
background image

4Ć7

4.4.2

Control Block Task Example

The following is an example of a Control Block task that handles an

interrupt from input B19.
Note that the `timeout' parameter in the BASIC statement EVENT is

usually disabled since interrupts from this module do not generally

ocur on a timed basis. The same consideration requires care in using

timeĆbased statements in loops used to read inputs from the module.

The `timeout' parameter is not disabled in the following example

because the interrupt is expected to happen in a specified time

period.

1000

COMMON ISCR%

\!Interrupt Status/Control Register

1010

COMMON LATCH EDGE B19@

\!Latch edge, input B19

1020

COMMON LATCH STATUS B19@

\!Latch status, input B19

1030

COMMON LATCH ENABLE B19@

\!Interrupt enable, input B19

1040

COMMON LATCH RESET B19@

\!Latch reset, input B19

1050

LOCAL B19 CNT%

\!Count of interrupts

2000

!

2001

!

Define the edge transition that will generate an interrupt.

2002

!

2010

LATCH EDGE B19@ = FALSE

\!Off to on

3000

!

3001

!

The following statement connects the name HW EVENT to the

3002

!

Interrupt defined in ISCR%. The event name should be

3003

!

as meaningful as possible. The watchdog timeout has been

3004

!

set to 1800 clock ticks (9.9 sec.). 1 tick equals

3005

!

.0055 seconds. If the time between

3006

!

interrupts exceeds this value, a severe error will be declared

3007

!

and the system will be stopped.

3008

!

3009

!

3010

EVENT NAME=HW EVENT, LATCH STATUS=ISCR%, & TIMEOUT=1800

4000

!

4001

!

The following statement resets the latch status bit

4002

!

4010

LATCH RESET B19@ = FALSE

5000

!

5001

!

The following statement enables interrupts

5002

!

5010

INTRP ENABLE B19@ = TRUE

5200

!

5300

!

complete the remainder of task initilization

5500

!

6000

!

6001

!

The next statement synchronizes the task with the external

6002

!

event via the interrupt. Task execution will be suspended

6003

!

until the interrupt occurs. When the interrupt occurs, if this

6004

!

task is the highest priority task waiting to execute, it will

6005

!

become active. If it is not the highest priority task, it will

6006

!

remain suspended until all higher priority tasks have executed.

6007

!

at which point it will become active.

6008

!

6010

CALL SCAN LOOP( TICKS=1200, EVENT=HW EVENT)

7000

!

7001

!

The next statements determine which bit generated the interrupt

7002

!

by examining the latch status bit. If an interrupt is

7003

!

found, it is reset. The interrupt service routine is

7004

!

then executed.

7005

!

7500

!

Advertising