
Concepts - 5
Software and Hardware Interrupts
CAMBASIC supports multiple hardware and software interrupts. These interrupts causes the program to branch to an
interrupt service routine which ac ts exactly like a GOSUB. The syntax of a typical routine is:
10 ON KEYPAD$ GOSUB 50
NOTE: Not all products support all the interrupts. See your hardware 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 hardware interr upts.
See your CPU card user’s m anual for more inform ation. When a hardware interrupt occurs, a flag is set. If the
corresponding ON ITR statement has been previously executed, CAMBASIC will sense the flag and cause program
execution to br anch. Branching occurs a fter the completion of the curr ent stateme nt. T hus, the hardw are inter rupt is
converted to a softwa re interrupt.
At the hardware level, the interrupts are prioritized. H owever, the software response to the interrupts have equal priority.
Any interrupt can preem pt any other interrupt.
Software Interrupts
CAM BASIC has other interru pts which ar e purely softwar e interrupts. For example, you can cause program execution to
branch on a perio dic basis using the ON T ICK statem ent.
All software inter rupts have equal pr iority. Any software inter rupt can interrupt another software interrupt, but not a
hardware 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 status interr upts – ON INP
8 Input line interrupts – ON BIT
2 Serial input interru pts – ON COM$
8 Counter interrupts – ON COUNT
1 Keypad interrupt – ON KEYPAD$
3 Periodic interr upts – ON TICK
Assembly Language Interface
You may call an assembly or a compiled 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 assembly code program to EE PROM along with your BASIC program. We suggest that you save your
BASIC program first, then load your assembly code in the free area on the EEPROM, above BASIC.
SAVING AND LOADING PROGRAMS
Saving and loading programs to and from nonvolatile memory is as easy as typing “SAVE” and “LOAD”. You can
download programs through a modem hundreds of miles from the computer.
Commentaires sur ces manuels