📄 t2_tx_intvl.asm
字号:
;****************************************************************;
; Timer2 Service Routine
;
; function:
; Timer2 Interrupt Frequency: 300Hz
;
; Written by: Mr.ZhangJinBo
; Date: 2004-02-16
;****************************************************************;
;================================================================;
;Constant Area
;================================================================;
;//04-03-17// revise for reducing the ir detect interval time
c_ir_groups_intvl equ #8 ;the interval of ir groups =18/(300Hz)=60ms
;end revise //04-03-17//
;c_eyes_twinkle_intvl equ #120 ;the interval of eyes twinkle =120/(300Hz)=0.4s
;c_key_scan_intvl equ #18 ;the interval of key scan =18/(300Hz)=60ms
;c_sound_play_intvl_h equ #05h ;the interval of sound play =5*16*16/(300Hz)=4.27s
c_broadcast_tmr_h equ #4 ;timer for mouse entry the cheese broadcast range
c_broadcast_intvl equ #21 ;transmit one times each 72ms
c_normal_tx_intvl equ #21 ;normal transmit ir one times each 36ms(12)
;================================================================;
;Data Area
;================================================================;
.area timer2_var(data)
temp_a_2:: .ds 1
temp_op1_2:: .ds 1
temp_dp_2:: .ds 1
;cnt_ir_groups_intvl:: .ds 1
;cnt_eyes_twinkle_intvl::.ds 1
;cnt_key_scan_intvl:: .ds 1
;cnt_sound_play_intvl:: .ds 2
cnt_rnd_num_ini:: .ds 2 ;random number initial value counter
cnt_broadcast_tmr:: .ds 2 ;broadcast sign valid time
cnt_broadcast_intvl:: .ds 1 ;slow tx ir about 72ms
cnt_normal_tx_intvl:: .ds 1 ;normal tx ir about 36ms
cnt_point_free:: .ds 1 ;point counter,it will increase 1 each timer2 isr,a free timer
;================================================================;
;Code Area
;================================================================;
.area timer2_isr(code)
t2_isr::
sta temp_a_2
lda r_op1
sta temp_op1_2
lda r_dp
sta temp_dp_2
lda cnt_point_free ;free increase,it will be clear in cal_point subroutie.
inca ;for calculating the point,about 400ms,point will decrease 1 for 0-999
sta cnt_point_free ;
call p_transmit_ir
t2_isr_end:
lda temp_dp_2
sta r_dp
lda temp_op1_2
sta r_op1
lda temp_a_2
reti ;/*04-02-19*/
;----------------------------------------------------------------;
; Counter Subroutine
; function:count for key-scanning, IR-transmitting,
;
;----------------------------------------------------------------;
p_transmit_ir::
lda flg_rcv_broadcast
cmpe #1
brnz p_normal_ir_tx ;isn't slow speed tx,go to normal tx ir
lda cnt_broadcast_tmr ;will slow speed tx,last for 4s
inca
sta cnt_broadcast_tmr
lda #0
addc cnt_broadcast_tmr+1
sta cnt_broadcast_tmr+1
cmpe #c_broadcast_tmr_h ;>4s,will restore normal transmit
brc p_broadcast_tmr_end
lda status_ir_transmit
ora #0 ;status_ir_transmit=0?
brz p_tx_ir_slow ;/=0,ir is transmitting,skip
ret ;the last transmiter is procedure.
p_tx_ir_slow:
lda cnt_broadcast_intvl ;=0,interval timer increase 1/300s
inca
sta cnt_broadcast_intvl
cmpe #c_broadcast_intvl ;>=interval,will start transmit
brc p_tx_ir ;<interval,stop transmit
ret
p_tx_ir:
lda #1
sta status_ir_transmit
lda #0
sta flg_rcv_barrier ;clear barrier flag at the front,theflag shall be processed
sta cnt_broadcast_intvl ;in rules.asm
sta cnt_normal_tx_intvl
sta cnt_ir_transmit
lda flg_ir_transmit_high ;1 stop 38k
lda r_prtc ;when prtc.0 is low, 38k carrier pulse pass-by.
anda #11111110b ;c_prtc0_0
sta r_prtc
ret
p_broadcast_tmr_end:
lda #0
sta flg_rcv_broadcast ;about 4s delay end
lda #2
sta flg_touched_key ;touched key flag is wrong,shall decrease 50 points(nose key function)
lda #1
sta status_ir_transmit ;ready to transmit ir
ret
p_normal_ir_tx:
lda status_ir_transmit
cmpe #0
brnz p_normal_ir_tx_skip ;is transmitting,skip
lda cnt_normal_tx_intvl
inca
sta cnt_normal_tx_intvl
cmpe #c_normal_tx_intvl ;>36ms
brc p_tx_ir
p_normal_ir_tx_skip:
ret
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -