Interrupts chapter 13 – Remote Processing RPC-2350 User Manual

Page 57

Advertising
background image

INTERRUPTS

CHAPTER 13

13-2

jumper s from W7 if using e xternal inte rrup ts. IN T1 is
tied to a 10K ohm pull up resistor.

The O N IT R n GO SUB line/label tasking statem ent is
used to initialize interrupts 0 and 1.

INT 0 and INT 1 are level sensitive. As long as the line
is low, an interrupt is generated. This can be a blessing
and curse, depending upon the application. Make sure
you turn off or reset your external hardw are interrupt
source before executing a RET URN IT R n.

Hardware service routines require a RETUR N ITR n at
the end of the subroutine. This will re-enable the
particular interrupt. If, for some reason you do not want
t he in te r r up t a g ai n, y o u c a n j us t R E T U R N . S om e
applications may actually require a delayed RETURN
ITR. This is true if you are monitoring a slow moving
pulse at the counter. When an interrupt is generated, the
low signal output may not go away by the time the
interrupt is finished. You can simply set a flag to let the
main routine know later to re-enable the interrupt when
the condition is gone. See CNTR2. BAS for an example.

Later you can exe cute RE TUR N ITR n to re-en able it.

The C LOC K1. BAS rou tine shows ho w interr upt 0 is
used.

INT1 is available at J10-2. It is active low, level
sensitive, and is used in conjunction with the counter
carr y or bor row o utput or an externa l signal applied to
J10.

NOTE: Interr upts are fr equently tur ned off wh ile

CAM BASIC runs certain time critical code.
Times when interr upts are turned off include
graphic display writing (when sparkle is on),
brief periods when servicing comm unication
interrupts, and wr iting to Flash. Norm ally a
pulse 10 micro-Seconds wide can cause an
interrupt. Howeve r, if you are saving to flash
or to the graphics screen, the pulse should be
100 micro-Seconds to ensure capture.

NOTE: Interrupt 0 and 1 are level sensitive. As long

as the line is low, another interrupt will be
called as soon as RETURN ITR is executed.
Make sure you clear the sour ce of the interrupt
before executing RETURN ITR.

SOFTWARE INTERRUPTS

Software inter rupts are all other “O N” types. T hese
interrupts look for an interrupt condition in software.
The ON BIT, ON INP, ON KEYPAD$, ON COUNT,
and ON TICK r outines either scan or count first then
determine if an interrupt should be declared. A ll of the
above routines oper ate on a 5 mS interv al. T hat is,
every 5 m S lines are scanned, counters checked , and so
on.

Commands that look at digital I/O lines, such as ON
BIT, requir e a stable input co ndition for a t least 5 ms in
order to be recognized.

All of the subroutines use a simple RETURN to continue
e x ec u ti on f ro m w he r e it w as in te r r up te d fr o m .

See the examples in the CAMBASIC manual for more
information on using these tasking statements.

COMMANDS

The follow ing comm ands are used for in terru pts in
C A M B A SI C .

Command

Function

ON BIT

Interrupt on line change

O N C OM $

Interr upt on seria l data

O N C O U N T

Interrupt when count
reached

O N I N P

Interrupt on bit m ask

ON ITR

Hardw are interrupt

O N K E Y P AD $

Interrupt on key press

O N T I C K

Per iodic interr upts

RETURN ITR

Return from hardware
interr upt.

Advertising