Page 46 of 62
SBasic User's Manual SBasic Version 2.7 Page 46
Printed: December 5, 1999
In the above example, control leaves the ISR immediately if N contains
the value $66. If not, then N is changed to $10 and control leaves
the ISR through the normal END statement.
In rare cases, you may need to combine a line label with the INTERRUPT
statement. This can happen in some variations of the 68hc11 MCU. The
'a1 variation, for example, often contains a form of the BUFFALO
monitor in on-chip ROM. BUFFALO takes full control of the interrupt
vectors, so SBasic cannot modify any of the vectors.
Instead, BUFFALO expects your program to use specific addresses in on-
chip RAM as jump vectors to reach your ISR code.
To get around this obstacle, you must combine a line label with use of
the ADDR function.
Example:
interrupt ' note that no address is used!
rtiisr:
if u 0 ' if u is not yet 0
u = u - 1 ' decrement u
endif
pokeb tflg2, $40 ' rearm interrupt
end
main:
pokeb $eb, $7e ' write a jump instruction
poke $ec, addr(rtiisr) ' write addr of ISR
Here, the code in MAIN modifies the RAM addresses used by BUFFALO. It
stores a JMP instruction ($7e) followed by the address of the jump
target.
When the RTI interrupt occurs, BUFFALO will jump to address $eb. The
code left there by MAIN will in turn pass control to the ISR at
RTIISR, where the actual interrupt processing occurs.
Note that the above example does not require an argument to the
INTERRUPT statement. This means SBasic will not create an entry in
the target's vector area. The above code, following the label MAIN,
must be used to provide the target processor with access to the ISR.
If necessary, you can use the /i option on SB's command line to
surpress generation of all interrupt vectors, including the reset
vector. You can use this option if the target MCU already contains
firmware for activating your program following reset. Examples of
such a situation include a 68HC11A1 with BUFFALO already in ROM, and
the 68HC912B32 with its on-chip bootloader.