?? nt02.asm
字號:
;///////////////////////////////////////////////////////;
;///////////////////////////////////////////////////////;
;//////// ////////;
;//////// MODEL : kt1124 ////////;
;//////// ////////;
;//////// MICOM : R65C02 ////////;
;//////// ////////;
;//////// PROGRAMER : ZHONG GUANG CHAO ////////;
;//////// ////////;
;//////// DATE : 2005-12-9 ////////;
;///////////////////////////////////////////////////////;
;///////////////////////////////////////////////////////;
;=======================================================;
.PL 100
.PW 120
.LIST ON
.SYMBOLS
.CHIP R65C02
include nt02ram.asm
;=======================================================;
;========= Reset: =========;
;=======================================================;
; Tt18P08D: please set as "ORG $2000H" ;
; Tt18P06D: please set as "ORG $2800H" ;
; Tt18P04D: please set as "ORG $3000H" ;
;-------------------------------------------------------;
ORG $2000h
reset:
ldx #0fh
txs ; Set stack point = FFh
sei ; disable all interrupt
jsr delay_1ms ; delay for osc
jsr delay_1ms ; delay for osc
;---------------------------------------------
;!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
;----------------------------------------------test program
; zhong guang chao add for test program 2006-1-10
jsr delay_1ms
;PB--------------------------------------
lda #00h
sta PBR ;
lda #ffh ;
sta PBPH ;
;----------------------------------------
jsr delay_1ms
lda #00h
sta T0C
sta T1C
nop
nop
nop
lda PB
and #01h ;check pb0 if low then enter test program
beq test_program1
jmp test_program_back
jmp test_program_back
test_program1:
jmp test_program
test_program_back:
;---------------------------------------------
;!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
;-----------port initialization
;PA---------------------------------------------
lda #0fh
sta PAIO ;set PA7~4 output,PA3~0 input
lda #ffh
sta PACN ;coms level output
lda #04h
sta PAPH ;set pa2 pull up
lda #00h
sta PA ;clear pa
;PB---------------------------------------------
lda #ffh
sta PBR ;enable wake up from HALT and STOP mode
sta PBPH ;set pb3~0 pull up
;PC---------------------------------------------
lda #00h
sta PCIO ;set output mode
lda #ffh
sta PCCN ;set cmos level
lda #00h
sta PC ; clear
;-----------------------------------------------
;--timer0
lda #1 ; settting t0c 60us intrrupt
sta T0BF ; 60/31=2
lda #10100000b ; F32k=32768hz 1/32768=31us
sta T0C ;
;--timer1
lda #00h
sta T1C
;--rtc &base time
lda #00001000b ; select 32.768khz ,RTC1=0 RTC0=1 --->2Hz/0.5sec
sta UCCLK ;
lda #00100010b ; Enable RTCEN,enable watch dog
sta TMRC
lda #00001001b ; Enable RTC,T0C int
sta INTEN
jsr ram_clear
jsr ram_default_set
;timer------------------------------------------
cli ; enable interrupt
;-----------------------------------------------
;=======================================================;
;========= Main: ==========;
;=======================================================;
main:
lda timeflag
and #t5msf
beq main1
;----5 msec subroutine start
jsr time_manager
;----5 msec subroutine end
lda timeflag
and #t10msf
beq main1
;----10 msec subroutine start
jsr key_scan
;----10 msec subroutine end
lda timeflag
and #t20msf
beq main1
;-----20 msec subroutine start
nop
;-----20 msec subroutine end
lda timeflag
and #t40msf
beq main1
;----40 msec subroutine start
jsr key_function
;----40 msec subroutine end
lda timeflag
and #t80msf
beq main1
;-----80 msec subroutine start
nop
nop
;-----80 msec subroutine end
lda timeflag
and #t160msf
beq main1
;------160 msec subroutine start
nop
nop
nop
;-------160 msec subroutine end
lda timeflag
and #t320msf
beq main1
;------320 msec subroutine start
;------320 msec subroutine end
lda timeflag
and #t640msf
beq main1
;------640 msec subroutine start
jsr rt_check_adj
;------640 msec subroutine end
main1:
jsr auto_power_on_off
jsr remote_action
jsr really_action
jsr clear_dog
jsr lcd_backlight
jsr buzzer_action
jsr lcd_display
jsr clear_dog
;///////////////////////////////////////////////;
; ;
; UPS server ;
; ;
;///////////////////////////////////////////////;
supper_ups:
lda #10010010b ; select AD channel --PA.1
sta rADCC
nop
nop
lda #11010010b ; start AD convert
sta rADCC
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
lda rADCH
sta temp ; back up AD convert result
lda rADCC
and #40h
bne ad_faill ; AD convert faill
lda #00h
sta rADCC ; stop AD convert
lda temp
cmp #0 ; check if PA.1< 0.1v then enter HALT mode
bcs supper_ups_exit
nop
sta HALT ; enter ups mode
nop
nop
nop
nop
jsr power_k
supper_ups_exit:
jmp main
ad_faill:
lda #00h
sta rADCC ; stop AD convert
jmp main
;///////////////////////////////////////////////;
; ;
; user ram clear ;
; ;
;///////////////////////////////////////////////;
ram_clear:
stz keyflag
stz timeflag
stz newkey
stz oldkey
stz keycount
stz keyval
stz key_buzzer_t
stz t100msec
stz t800msec
stz t5msec
stz clk_hour
stz clk_min
stz clk_sec
stz on_hour
stz on_min
stz off_hour
stz off_min
stz com_hour
stz com_min
stz dispflag
stz powerflag
stz actionmode
stz speedmode
stz t_setting_m
stz clock_setting_m
stz tem_cal_h
stz tem_cal_l
stz temperature_h
stz temperature_l
stz clock_setting_t
stz back_light_t
stz room_tem_check
stz really_act_3min
stz really_act_20sec
stz temp
stz key_ad_h
stz key_ad_l
stz r_table_l
stz r_table_h
stz r_bit_count
stz remote_t
stz remode
stz r_data0
stz r_data1
stz r_data2
stz r_data3
stz remote_f
stz che_ups_t
stz temp_check_h
stz temp_check_l
stz tem_cal_f
stz auto_mode
stz h_motor_t
stz old_temp
rts
;///////////////////////////////////////////////;
; ;
; ram defalut setting ;
; ;
;///////////////////////////////////////////////;
ram_default_set:
;-----------------------------------------------; setting lcd display ram
lda #ffh
sta disset
jsr dis_ram_setting
lda #11000000b ; set LCD on
sta LCDC
lda #2
sta back_light_t ; lcd all segment turn on 1.6sec
lda #demo_dis_f
ora powerflag
sta powerflag ; turn on demo display 1.6sec
jsr buzzer_on
;-----------------------------------------------
stz actionmode ; speed mode
stz speedmode ; speed level= low
lda #26
sta t_setting_m ; temperature defalut 26℃
;-----------------------------------------------
lda PA
and #tem_rang_set
beq temp_range_ret
lda #t_set_rang_f ;if =1 col range 10~40 ℃,hot range 10~40 ℃
ora powerflag ;temperature setting rang flag if =0 col range 26~40 ℃,hot range 10~40 ℃
sta powerflag
temp_range_ret:
rts
;///////////////////////////////////////////////;
; ;
; check power on and power off time ;
; ;
;///////////////////////////////////////////////;
;-------
power_on_off_timer:
lda clock_setting_m
cmp #00h
beq power_on_off_timer_ret
lda on_hour ;if check auto power on time = auoto power off time ,
clc ;then increa auto power off time 1 min
adc on_min
cmp #00h
beq power_on_off_timer_ret
lda off_hour
clc
adc off_min
cmp #00h
beq power_on_off_timer_ret
lda on_hour
cmp off_hour
bne power_on_off_timer_ret
lda off_min
cmp on_min
bne power_on_off_timer_ret
cmp #59
beq power_on_off_timer0
inc off_min
rts
power_on_off_timer0:
stz off_min
lda off_hour
cmp #23
beq power_on_off_timer1
inc off_hour
rts
power_on_off_timer1: ; when setting auto power on time=23:59
stz off_hour ; and auto power off time= 23:59, then disable auto power off function
power_on_off_timer_ret:
rt_check_adj_ret0:
rts
;///////////////////////////////////////////////;
; ;
; really temperature check and adj ;
; ;
;///////////////////////////////////////////////;
;-----------
rt_check_adj:
lda clock_setting_m
and #tem_cal_set
bne rt_check_adj_ret0
lda powerflag
and #power_on_f
beq rt_check_adj_ret0 ; when power off then stop temperature check
lda #10000001b ; select AD convert channel
sta rADCC
nop
lda #11000001b ; start A/D convert
sta rADCC
nop
nop
nop
nop
nop
nop
nop
nop
nop
lda rADCH
sta key_ad_h
lda rADCL
and #11110000b
sta key_ad_l
lda #00h
sta rADCC ; stop A/D convert
ldx #4 ; Shift right 4 times
fix_value:
lsr key_ad_h
ror key_ad_l
dex
bne fix_value
;-----------------------------------------------
check_tem_v_h: ; check temperature value availability
ldx #0
lda rt_ad_tab,x ; if A/D value 03h,2Eh=<AD<=0Ch,40h then value is availability
cmp key_ad_h ; high bit check
bcc rt_too_min ; > max
beq check_tem_v_h_0 ; =
jmp check_tem_v_l ; <
check_tem_v_h_0:
inx
lda rt_ad_tab,x ;
cmp key_ad_l ; low bit check
bcc rt_too_min ;>
jmp tem_avai ;<=
check_tem_v_l:
ldx #180 ; tale length
lda rt_ad_tab,x ;
cmp key_ad_h ; high bit check
beq check_tem_v_l_0
bcc tem_avai ; > min
bcs rt_too_max ; < min no availability
jmp tem_avai
check_tem_v_l_0:
inx ;
lda rt_ad_tab,x ;
cmp key_ad_l ; low check
beq tem_avai
bcs rt_too_max ;
jmp tem_avai
rt_too_max:
ldx #180 ; tale length
jmp too_com
rt_too_min:
ldx #00h
too_com:
lda rt_ad_tab,x ;
sta key_ad_h
inx
lda rt_ad_tab,x ;
sta key_ad_l
jmp tem_avai
;------------------------------------------------
tem_avai:
ldx #00h
high_cmp:
lda rt_ad_tab,x
cmp key_ad_h ; compare high
beq low_cmp
inx
inx
inx
cpx #177 ; 3*60-3
bcs rt_too_max
jmp high_cmp
low_cmp:
inx
lda rt_ad_tab,x
cmp key_ad_l ; compare low
bcs low_cmp_inc
beq low_cmp_finish ; value is integer
sta r_table_l
dex
dex
lda rt_ad_tab,x
sta temperature_h
dex
lda rt_ad_tab,x
sta r_table_h
lda r_table_l
inx
inx
inx
cmp r_table_h
bcs need_cmp
lda r_table_h
sec
sbc r_table_l
sta temperature_l
jmp div_10
need_cmp:
lda #ffh
sec
sbc r_table_l
clc
adc r_table_h
sta temperature_l
jmp div_10
low_cmp_inc:
lda rt_ad_tab,x
sta r_table_h
dex
lda rt_ad_tab,x
cmp key_ad_h
beq low_cmp_inc_0
dex
lda rt_ad_tab,x
sta temperature_h
jmp need_cmp
low_cmp_inc_0:
inx
inx
lda rt_ad_tab,x
sta temperature_h ; the first back up high temperature value
inx
jmp low_cmp
low_cmp_finish:
inx
lda rt_ad_tab,x
sta temperature_h
stz temperature_l
rts
div_10:
stz temp
lda temperature_l
div_10_1:
sec
sbc #10
bcc div_10_3
inc temp
cmp #10
bcs div_10_1
cmp #5
bcc div_10_3
div_10_2:
inc temp
div_10_3:
stz temperature_l
lda r_table_h
sec
sbc key_ad_l
div_10_3_0:
sec
sbc temp
bcc div_10_4
inc temperature_l
cmp temp
bcs div_10_3_0
div_10_4:
lda temperature_l
cmp #9
bcs div_10_5
jmp adj_cal_value
div_10_5:
lda #9
sta temperature_l
adj_cal_value:
lda temperature_h
sta temp_check_h
lda temperature_l
sta temp_check_l
lda tem_cal_h
clc
adc tem_cal_l
cmp #00h
beq adj_cal_val_ret ; no calibration value
lda tem_cal_f
and #tem_cal_h_f
beq adj_cal_val_1 ; cal data on low side
adj_cal_val_0: ; cal data on high side
lda temperature_h ; adj cal data on high side
clc
adc tem_cal_h
cmp #60
bcs adj_cal_val_0_0
sta temperature_h
jmp adj_cal_val_0_1
adj_cal_val_0_0:
lda #60
sta temperature_h
stz temperature_l
rts
adj_cal_val_0_1:
lda temperature_l
clc
adc tem_cal_l
sta temperature_l
cmp #9
beq adj_cal_val_ret
bcs adj_cal_val_0_2
rts
adj_cal_val_0_2:
inc temperature_h
cmp #60
bcs adj_cal_val_0_0
rts
adj_cal_val_1:
lda temperature_l ; adj cal data on low side
cmp tem_cal_l ;
bcs adj_cal_val_1_0 ; temperature_l > tem_cal_l
dec temperature_h ; temperature_l < tem_cal_l
lda temperature_l
clc
adc #10
adj_cal_val_1_0:
sec
sbc tem_cal_l
sta temperature_l
adj_cal_val_1_1:
lda temperature_h
cmp tem_cal_h
bcs adj_cal_val_1_2
stz temperature_l
stz temperature_h
rts
adj_cal_val_1_2:
sec
sbc tem_cal_h
sta temperature_h
adj_cal_val_ret:
rts
;///////////////////////////////////////////////;
; ;
; really action ;
; ;
;///////////////////////////////////////////////;
;------------------------------------------------
really_action:
; o=speed ,1=cold,2=hot;3=sleep
lda powerflag
and #power_on_f
beq p_on_op_action1 ; when power off then disable all action
p_on_op_action:
lda h_motor_t ; power on the first setting high motor 2sec
cmp #00h
beq p_on_op_action0
lda PA
and #hot_sw_n
and #cold_sw_n
ora #motor_h
sta PA
lda PC
and #motor_m_n
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -