Assembly code for TOF Interrupt
;Program to flash LEDs connected to PORTB every time TCNT overflows
PORTB = 0x1004
TFLG2 = 0x1025
TMSK2 = 0x1024
.area CODE (ABS)
.org 0x00D0
jmp tof_isr ;jump to ISR on TOF int
.org 0x0100
lds #0x01ff ;load stack pointer
ldaa #0x55 ;initialize LEDs
staa PORTB
ldaa #0x80 ;clear TOF flag
staa TFLG2
ldaa #0x80 ;enable TOF int
staa TMSK2
cli ;enable ints
here: bra here ;do nothing
tof_isr: com PORTB ;flash LEDs
ldaa #0x80 ;clear TOF flag
staa TFLG2
rti ;return to main prog
C code for TOF Interrupt
/* Program to flash LEDs connected to PORTB every time TCNT overflows */
#include <hc11.h>
void tof_isr(void);
main() /* C automatically loads stack pointer */
{
PORTB = 0x55; /* Initialize LEDs */
TOF_JMP = JMP_OP_CODE; /* jmp tof_isr */
TOF_VEC = tof_isr;
TFLG2 = 0x80; /* Clear TOF flag */
TMSK2 = TMSK2 | 0x80; /* Enable TOF int */
enable(); /* Enable ints */
while(1) {} /* Do nothing */
}
/* Exit tof_isr with an RTI instruction */
#pragma interrupt_handler tof_isr
void tof_isr(void)
{
PORTB = ~PORTB;
TFLG2 = 0x80;
}