#include "c:\miniIDE\hcs12.inc" org $1000 cnt ds.b 1 org $1500 lds #$1500 movb #$FF,DDRB clr cnt forever movb cnt,PORTB ldy #10000 jsr delayby50us inc cnt bra forever delayby50us bset TSCR1,TFFCA ; enable timer fast flag clear movb #04,MCCTL ; enable modulus down counter with 1:1 as prescaler movw #1200,MCCNT ; load the value to be down counted brclr MCFLG,MCZF,* bclr MCCTL,$04 ; disable modulus down counter dbne y,delayby50us rts delayby1ms bset TSCR1,TFFCA ; enable timer fast flag clear movb #$07,MCCTL ; enable modulus down counter with 1:16 as prescaler movw #1500,MCCNT ; load the value to be down counted brclr MCFLG,MCZF,* bclr MCCTL,$04 ; disable modulus down counter dbne y,delayby1ms rts delayby10ms bset TSCR1,TFFCA ; enable timer fast flag clear movb #$07,MCCTL ; enable modulus down counter with 1:16 as prescaler movw #15000,MCCNT ; load the value to be down counted brclr MCFLG,MCZF,* bclr MCCTL,$04 ; disable modulus down counter dbne y,delayby10ms rts delayby100ms pshx pshb bset TSCR1,TFFCA ; enable timer fast flag clear ldab #10 tfr y,x ; make a copy of Y in X loopo tfr x,y loopi movb #$07,MCCTL ; enable modulus down counter with 1:16 as prescaler movw #15000,MCCNT brclr MCFLG,MCZF,* bclr MCCTL,$04 dbne y,loopi dbne b,loopo pulb pulx rts end