DATA .SECTION 'DATA'
ms10_counter db ?
work_mode db ?
main_sw db ?
up_sw db ?
down_sw db ?
measure_counter db ?
ms500_counter db ?
temp_counter db ?
updown_counter db ?
temp_set db ?
tp1 db ?
tp2 db ?
p1p20 db ?
p1p21 db ?
p1p22 db ?
p1p23 db ?
p1p24 db ?
p1p25 db ?
p1p26 db ?
p1p27 db ?
p1p28 db ?
p1p29 db ?
tempture1 db ?
tempture2 db ?
tempture3 db ?
tempture4 db ?
tempture5 db ?
tempture6 db ?
tempture7 db ?
tempture8 db ?
tempture9 db ?
tempture10 db ?
meas_counter db ?
averagetemp db ?
frequency db ?
min db ?
sec db ?
flag db ?
i db ?
maxtemp db ?
mintemp db ?
temp2 db ?
temp3 db ?
count db ?
x0f8 db ?
tempset_image db ?
acc_image db ?
status_image db ?
synsignal db ?
temp1 db ?
clrlcd: COM1_OUT
COM2_OUT
mov a,pb
and a,0c3h
mov pb,a
mov a ,pa
and a,0f0h
mov pa,a
jmp mainloop
TEST: snz flag.ms10over
jmp TEST
clr flag.ms10over
snz flag.ms500equal ;500ms delay havn'e yet
jmp pp4
clr flag.ms500equal ;equal to 500ms
inc temp_set
;inc temp_set ;flash 1s display num add 1
mov a,temp_set
sub a ,10
snz status.2 ;equal 10 ?
jmp kk28
kk26: clr temp_set ; 0-9 display over ,turn to stop mode
mov a ,STOP_MODE
mov work_mode,a
LED_OFF
mov a,pb
and a,0c3h
mov pb,a
mov a ,pa
and a,0f0h
mov pa,a
COM1_OUT
COM2_OUT
COM1_L
COM2_L
set flag.keypress
jmp mainloop ;goto loop
pp4: snz flag.ms500large ;larger than 500ms,on display
jmp pp5
LED_ON
call lcd_display
jmp kk28
pp5: LED_OFF ;less than 500ms,off dispaly
COM1_OUT
COM2_OUT
COM1_L
COM2_L
mov a,pb
and a,0c3h
mov pb,a
mov a ,pa
and a,0f0h
mov pa,a
jmp mainloop
KK28: mov a ,main_sw
xor a ,x0f8
sz status.2
jmp kk26
mov a ,up_sw
xor a ,x0f8
sz status.2
jmp kk26
mov a,down_sw
xor a ,x0f8
sz status.2
jmp kk26
call lcd_display
jmp mainloop
lcd_display: COM1_OUT
COM2_OUT
mov a, pb
and a, 0c3h
mov pb,a
sz ms10_counter.0
jmp disp_com1
jmp disp_com2
disp_com1:
COM2_IN
mov a, temp_set
mov tblp,a
tabrdl temp1
mov a,pb
or a,30h
mov pb,a
mov a,temp1
and a,0fh
mov temp2,a
mov a,pa
and a,0f0h
or a,temp2
mov pa,a
COM1_OUT
COM1_L
ret
disp_com2 : mov a, temp_set
add a ,10
mov tblp,a
tabrdl temp1
COM1_IN
mov a,temp1
and a,30h
mov temp2,a
mov a ,pb
or a,temp2
mov pb,a
mov a,temp1
and a, 0fh
mov temp2, a
mov a,pa
and a,0f0h
or a ,temp2
mov pa,a
COM2_OUT
COM2_L
ret
frequency_detect:
mov a ,00h
mov intc,a
mov tmr,a ;clear interrupt
mov a,94h
mov tmrc,a
sz zero_pos ;low,wait for high
jmp kk4
kk1: snz zero_pos ;high?
jmp kk1 ;low ,go circle
mov a ,10h ; start to count
mov tmrc,a
kk2: sz zero_pos ;low ?
jmp kk2 ;high,go circle
kk3: snz zero_pos ;low?
jmp kk3 ;low,wait for high
mov a ,tmr ;high,read tmr
sub a ,hz_50
sz status.0 ;less
jmp kk5
clr flag.hz50
mov a ,30h
mov tmr,a
jmp kk6
kk5: set flag.hz50
mov a ,06h
mov tmr,a
kk6: mov a ,93h
mov tmrc,a
mov a,05h
mov tmrc,a
ret
kk4: sz zero_pos
jmp kk4
jmp kk1
zz1: sz ms10_counter.0
jmp zz8
sz work_mode
jmp zz8
sz key_up
jmp zz8
sz key_down
jmp zz8
sdz updown_counter
jmp zz10
mov a,TEST_MODE
mov work_mode,a
mov a ,150
mov updown_counter,a
mov a ,100
mov ms500_counter,a
clr temp_set
jmp zz15
zz8: snz work_mode.1
jmp zz15
zz14: sdz ms500_counter
jmp zz15
mov a ,100
mov ms500_counter,a
set flag.ms500large
clr flag.ms500equal
zz15: mov a ,50
sub a, ms500_counter
sz status.2
jmp zz16
sz status.0
jmp zz17
clr flag.ms500equal ;lager than 500ms
set flag.ms500large
jmp zz10
zz16: set flag.ms500equal ;equal 500ms
jmp zz10
zz17: ; clr flag.ms500equal
clr flag.ms500large ;less than 500ms
zz10: clr status.0
;rlc main_sw
rlc main_sw ;read key
clr status.0
rlc up_sw
clr status.0
rlc down_sw
snz key_main
jmp zz11
set main_sw.0
zz11: snz key_up
jmp zz12
set up_sw.0
zz12: snz key_down
jmp zz13
set down_sw.0
zz13: set flag.ms10over
turnback: mov a,status_image ;recover acc,status
mov status,a
mov a, acc_image
reti
cleanlcd: COM1_OUT
COM2_OUT
mov a,pb
and a,0c3h
mov pb,a
mov a ,pa
and a,0f0h
mov pa,a
jmp turnback
ORG 300h
lcd_com1 : dc 0eh,08h,0ch,0ch,0ah,06h,06h,0ch,0eh,0eh
lcd_com2 : dc 3ah,28h,36h,3ch,2ch,3ch,3eh,28h,3eh,3ch
fre_50hz : dc 139,109,88,72,61,53,47,42,38,35,33
fre_60hz : dc 89,64,46,33,23,17,11,7,4,2,0
end