; ; ミニタイマー ; name aaa $include(tlcs47.h) ;*********************************************************************** ; RAM領域定義 00h 〜 0Fh / 90h 〜 FFh dseg rel ddd org 0 ; zero page ram Count: res 3 ; minute down counter State: res 1 ; 0:stop, 1:run, 2:time out beep org 90h HLsav: res 2 ; <> org 0f4h ; timer counter 1 TC1: res 3 org 0f8h ; timer counter 2 TC2: res 3 org 0fch ; rom data pointer DTC: res 3 org 0ffh ; stack pointer SPW: res 1 ;*********************************************************************** ; プログラムコード cseg rel ccc org 00h init: ld a,#0ch ; init SP st a,SPW out #1100b,%P01 ; init ports out #0000b,%P09 cmpr State,#1 ; スタート/ストップ ? testp zf bs m_stop test cf bs sleep clr %P07,1 ; 設定時間読み込み ld hl,#Count in %P00,a subr a,#-1 st a,@hl+ in %P04,a subr a,#-1 st a,@hl+ in %P08,a subr a,#-1 st a,@hl+ set %P07,1 st #1,State ; カウント開始 out #0011b,%P01 ; SW on call beep counter: ; カウントダウンループ ld hl,#Count dec @hl bs wait60 st #9,@hl+ dec @hl bs wait60 st #9,@hl+ dec @hl bs wait60 bs timeout wait60: ld hl,#TC1 ; 60秒待ち st #nll(-1465),@hl+ st #nlh(-1465),@hl+ st #nhl(-1465),@hl+ dec l w60l: call click ld a,@hl cmpr a,#0 bs w60l bs counter timeout:; タイムアウト st #2,State out #1100b,%P01 ; SW off out #1100b,%P02 ; O.S. on ld hl,#-150 ; 10秒鳴らす tmol: call beep inc l bs tmol add h,#1 bs tmol out #1111b,%P02 ; O.S. off bs sleep m_stop: ; カウント停止 call beep call beep call beep sleep: ; 待機モードに入る st #0,State ld a,#0101b ; enter hold mode, wait for reset! out a,%P10 ; click: ; 計時クリック音 ld a,TC1 and a,#7 cmpr a,#1 bs clcr ld a,#0 out #0111b,%P02 out #1011b,%P02 clcp: out #1111b,%P02 out #1111b,%P02 out #1111b,%P02 inc a bs clcp out #0111b,%P02 out #1011b,%P02 out #1111b,%P02 clcw: ld a,TC1 and a,#7 cmpr a,#1 testp zf bs clcw clcr: ret beep: ; 単発ビープ xch hl,HLsav ld a,#1000b ; set timer 1, 391Hz out a,%P1C ld hl,#TC1 ; 1/30秒鳴らす st #-13,@hl+ ld a,@hl bpl1: set %P02,3 clr %P02,2 nop nop cmpr a,@hl set %P02,2 clr %P02,3 testp zf bs bpl1 set %P02,3 ld hl,#TC1 ; 1/30秒休む st #-13,@hl+ ld a,@hl bpl2: cmpr a,@hl testp zf bs bpl2 ld a,#1001b ; set timer 1, 24.41Hz out a,%P1C xch hl,HLsav ret end