Specifications
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 acts 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 more information.
Hardware Interrupts
CAMBASIC supports up to three hardware interrupts. Not all hardware products implement these hardware interrupts. See
your CPU card user’s manual for more information. 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 branch.
Branching occurs after the completion of the current statement. Thus, the hardware interrupt is converted to a software
interrupt.
At the hardware level, the interrupts are prioritized. However, the software response to the interrupts have equal priority.
Any interrupt can preempt any other interrupt.
Software Interrupts
CAMBASIC has other interrupts which are purely software interrupts. For example, you can cause program execution to
branch on a periodic basis using the ON TICK statement.
All software interrupts have equal priority. Any software interrupt can interrupt another software interrupt, but not a
hardware interrupt.
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 interrupts – ON INP
8 Input line interrupts – ON BIT
2 Serial input interrupts – ON COM$
8 Counter interrupts – ON COUNT
1 Keypad interrupt – ON KEYPAD$
3 Periodic interrupts – ON TICK
Assembly Language Interface
You may call an assembly or a compiled language using the CAMBASIC CALL 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 EEPROM 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.