#include "c:\miniide\hcs12.inc" org $1000 count ds.b 1 ; OC0 match count oc0cnt ds.b 1 org $2000 ; start of program lds #$2000 ; set up stack pointer movb #$FF,ddrb ; configure port B for output clr count movb count,portb movb #$90,tscr1 ; enable tcnt and fast timer flag clear movb #$06,tscr2 ; set TCNT prescaler to 128, enable timer reset bset tios,OC0 ; enable OC7 ldd tcnt ; start an OC0 operation addd #60000 ; " std tc0 ; " movb #$01,tflg1 ; clear C0F flag bset tie,C0I ; enable OC0 match interrupt movb #25,oc0cnt cli ; enable maskable interrupt forever nop tst oc0cnt beq reset_it bra forever reset_it movb #25,oc0cnt ; quarter second expired, inc count ; increment oc0 count movb count,portb ; update LED displays bra forever oc0_ISR ldd tc0 ; start a new OC0 operation and addd #60000 ; also clear the OC0 flag std tc0 ; " dec oc0cnt movb #$FF,portb rti org $3E6E fdb oc0_ISR end