Software and hardware interrupts – Remote Processing CAMBASIC User Manual

Page 11

Advertising
background image

Concepts - 5

Software and Hardware Interrupts

CAM BASIC supports multiple hardware and software interrupts. These interrupts causes the program to branch to an
interrupt ser vice routine which ac ts exactly like a GOSU B. Th e syntax of a typical routine is:

10 ON KEYPAD$ GOSUB 50

NOTE:

Not all products support all the interrupts. See your hardw are manual for m ore information.

Hardware Interrup ts
CAM BASIC suppor ts up to three hardw are interr upts. N ot all hardwar e products implem ent these hardwa re interr upts.
See your CP U card user’s m anual for more inform ation. When a har dware interrupt occur s, a flag is set. If the
corresponding ON ITR statement has been previously executed, CA MBASIC will sense the flag and cause program
execution to br anch. Branching occurs a fter the co mpletion of the curr ent stateme nt. T hus, the hardw are inter rupt is
conver ted to a softwa re inter rupt.

At the hardware level, the interrupts are prioritized. H owever, the software response to the interrupts have equal priority.
Any inter rupt can p reem pt any other interru pt.

Software Interrupts
CAM BASIC has other interru pts which ar e purely s oftwar e interr upts. For example , yo u can cause progr am exe cution to
branch on a perio dic basis using the ON T ICK statem ent.

All softwa re inter rupts hav e equal pr iority. Any softw are inter rupt can in terru pt another softwar e interr upt, but not a
hardw are inter rupt.

In the case of several nearly simultaneous interrupts, the following sequence will occur. Suppose the first interrupt service
routine starts to execute only to be interrupted by a second interrupt. If another interrupt occurs before the second routine
finishes, then the third interrupt routine will execute to completion. Then the second interrupt service routine will finish,
followed by the first.

The software interrupts include:

8

Port sta tus interr upts

– O N I N P

8

Input line inter rupts

– ON BIT

2

Serial inpu t interru pts

– O N C OM $

8

Counter interru pts

– O N C O U N T

1

Keypad interrupt

– O N K E Y P AD $

3

Per iodic interr upts

– O N T I C K

Assembly Language Interface
You may call an assembly or a com piled language using the CAMBASIC C ALL statement. The compiled “ C” or
assembly language is object code which executes directly. This code is generated by your linker on your PC . The
resultant Intel hex format data is downloaded by PC SmartLINK into the system RAM.

You may save your assem bly code program to EE PROM along with your BASIC progr am. We suggest that you save your
B A SI C p ro g r am f ir s t, t h en lo a d y o ur a ss e m bl y c o de in th e fr e e ar e a on th e E EP R O M , a b ov e BA S IC .

S A V IN G A N D LO A D IN G P R O GR A M S

Saving and loading programs to and from nonvolatile memory is as easy as typing “SAVE” and “LOA D” . You can
download programs through a modem hundreds of miles from the computer.

Advertising