⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 mouse_timer2.asl

📁 一款智能老鼠的玩具源代码
💻 ASL
字号:
+                     1 ;****************************************************************;
+                     2 ; Timer2 Service Routine
+                     3 ;
+                     4 ; function:
+                     5 ; Timer2 Interrupt Frequency: 300Hz
+                     6 ;
+                     7 ; Written by: Mr.ZhangJinBo
+                     8 ; Date: 2004-02-16
+                     9 ;****************************************************************;
+                    10 
+                    11 ;================================================================;
+                    12 ;Constant Area
+                    13 ;================================================================;
+                    14 ;//04-03-17// revise for reducing the ir detect interval time
0008                 15 c_ir_groups_intvl	equ	#8	;the interval of ir groups =18/(300Hz)=60ms
+                    16 ;end revise //04-03-17//
+                    17 ;c_eyes_twinkle_intvl	equ	#120	;the interval of eyes twinkle =120/(300Hz)=0.4s
+                    18 ;c_key_scan_intvl	equ	#18     ;the interval of key scan =18/(300Hz)=60ms
+                    19 ;c_sound_play_intvl_h	equ	#05h	;the interval of sound play =5*16*16/(300Hz)=4.27s
0005                 20 c_broadcast_tmr_h	equ	#5	;timer for mouse entry the cheese broadcast range
0015                 21 c_broadcast_intvl	equ	#21       ;transmit one times each 72ms
0015                 22 c_normal_tx_intvl       equ	#21	;normal transmit ir one times each 36ms(12)
+                    23 ;================================================================;
+                    24 ;Data Area
+                    25 ;================================================================;
+B 00 01

+                    26        .area    timer2_var(data)
+                    27 
0000                 28 temp_a_2::		.ds	1
0001                 29 temp_op1_2::		.ds	1
0002                 30 temp_dp_2::		.ds	1
+                    31 ;cnt_ir_groups_intvl::	.ds	1
+                    32 ;cnt_eyes_twinkle_intvl::.ds	1
+                    33 ;cnt_key_scan_intvl::	.ds	1
+                    34 ;cnt_sound_play_intvl::	.ds	2
0003                 35 cnt_rnd_num_ini::	.ds     2	;random number initial value counter
0005                 36 cnt_broadcast_tmr::	.ds	2	;broadcast sign valid time 
0007                 37 cnt_broadcast_intvl::	.ds	1       ;slow tx ir about 72ms
0008                 38 cnt_normal_tx_intvl::	.ds	1  	;normal tx ir about 36ms
0009                 39 cnt_point_free::	.ds	1 	;point counter,it will increase 1 each timer2 isr,a free timer
+                    40 
+                    41 ;================================================================;
+                    42 ;Code Area
+                    43 ;================================================================;
+B 00 02

+                    44        .area    timer2_isr(code)
+                    45 
0000                 46 t2_isr::
0000 FD 00           47 	sta	temp_a_2
0002 F0 22           48 	lda	r_op1
0004 FD 01           49 	sta	temp_op1_2
0006 F0 21           50 	lda	r_dp
0008 FD 02           51 	sta	temp_dp_2
+                    52 
000A F1 09           53 	lda 	cnt_point_free	;free increase,it will be clear in cal_point subroutie.
000C 1F              54 	inca			;for calculating the point,about 400ms,point will decrease 1 for 0-999
000D FD 09           55 	sta	cnt_point_free  ;
+                    56 
000F 20 00 1D        57 	call	p_transmit_ir
+                    58 
0012                 59 t2_isr_end:	
0012 F1 02           60 	lda	temp_dp_2
0014 FC 21           61 	sta	r_dp
0016 F1 01           62 	lda	temp_op1_2
0018 FC 22           63 	sta	r_op1
001A F1 00           64 	lda	temp_a_2
001C 25              65 	reti			;/*04-02-19*/
+                    66 
+                    67 ;----------------------------------------------------------------;
+                    68 ; Counter Subroutine
+                    69 ; function:count for key-scanning, IR-transmitting,
+                    70 ;             
+                    71 ;----------------------------------------------------------------;
001D                 72 p_transmit_ir::
+                    73 
001D F1 00           74 	lda	flg_rcv_broadcast
001F A7 01           75 	cmpe	#1
0021 07 00 65        76 	brnz	p_normal_ir_tx               ;isn't slow speed tx,go to normal tx ir
0024 F1 05           77         lda	cnt_broadcast_tmr    	     ;will slow speed tx,last for 4s
0026 1F              78         inca
0027 FD 05           79         sta	cnt_broadcast_tmr
0029 F3 00           80         lda	#0
002B 99 06           81         addc	cnt_broadcast_tmr+1
002D FD 06           82         sta	cnt_broadcast_tmr+1
002F A7 05           83         cmpe	#c_broadcast_tmr_h           ;>4s,will restore normal transmit
0031 04 00 5C        84         brc	p_broadcast_tmr_end
0034 F1 00           85         lda	status_ir_transmit
0036 DB 00           86         ora	#0			     ;status_ir_transmit=0?
0038 06 00 3C        87         brz	p_tx_ir_slow		     ;/=0,ir is transmitting,skip
003B 24              88         ret                                  ;the last transmiter is procedure.
003C                 89 p_tx_ir_slow:
003C F1 07           90         lda	cnt_broadcast_intvl          ;=0,interval timer increase 1/300s
003E 1F              91         inca
003F FD 07           92         sta	cnt_broadcast_intvl
0041 A7 15           93         cmpe	#c_broadcast_intvl	  ;>=interval,will start transmit
0043 04 00 47        94         brc	p_tx_ir                 ;<interval,stop transmit
0046 24              95 	ret
0047                 96 p_tx_ir:
0047 F3 01           97         lda	#1
0049 FD 00           98         sta	status_ir_transmit
004B F3 00           99         lda	#0
004D FD 07          100         sta	cnt_broadcast_intvl
004F FD 08          101         sta	cnt_normal_tx_intvl
0051 FD 00          102 	sta	cnt_ir_transmit
0053 F1 00          103 	lda 	flg_ir_transmit_high	;1 stop 38k
0055 F0 31          104        	lda	r_prtc			;when prtc.0 is low, 38k carrier pulse pass-by.
0057 CB FE          105 	anda	#11111110b	;c_prtc0_0
0059 FC 31          106 	sta	r_prtc	
005B 24             107 	ret
005C                108 p_broadcast_tmr_end:
005C F3 00          109 	lda	#0
005E FD 00          110 	sta	flg_rcv_broadcast               ;about 4s delay end
0060 F3 01          111 	lda	#1
0062 FD 00          112 	sta	status_ir_transmit		;ready to transmit ir
0064 24             113 	ret
0065                114 p_normal_ir_tx:
0065 F1 00          115 	lda	status_ir_transmit
0067 A7 00          116 	cmpe	#0
0069 07 00 76       117 	brnz	p_normal_ir_tx_skip		;is transmitting,skip
006C F1 08          118 	lda	cnt_normal_tx_intvl
006E 1F             119 	inca
006F FD 08          120 	sta	cnt_normal_tx_intvl
0071 A7 15          121 	cmpe	#c_normal_tx_intvl	;>36ms
0073 04 00 47       122 	brc	p_tx_ir
0076                123 p_normal_ir_tx_skip:
0076 24             124 	ret
+                   125 
+
+Symbol Table
+
+    c_broadcast_intvl               =  0015 
+    c_broadcast_tmr_h               =  0005 
+    c_ir_groups_intvl               =  0008 
+    c_normal_tx_intvl               =  0015 
+  1 cnt_broadcast_intvl                0007 GR
+  1 cnt_broadcast_tmr                  0005 GR
+    cnt_ir_transmit                    **** GX
+  1 cnt_normal_tx_intvl                0008 GR
+  1 cnt_point_free                     0009 GR
+  1 cnt_rnd_num_ini                    0003 GR
+    flg_ir_transmit_high               **** GX
+    flg_rcv_broadcast                  **** GX
+  2 p_broadcast_tmr_end                005C R
+  2 p_normal_ir_tx                     0065 R
+  2 p_normal_ir_tx_skip                0076 R
+  2 p_transmit_ir                      001D GR
+  2 p_tx_ir                            0047 R
+  2 p_tx_ir_slow                       003C R
+    status_ir_transmit                 **** GX
+  2 t2_isr                             0000 GR
+  2 t2_isr_end                         0012 R
+  1 temp_a_2                           0000 GR
+  1 temp_dp_2                          0002 GR
+  1 temp_op1_2                         0001 GR
+
+
+Area Table
+
+   0 .                                  size    0   flags 0
+   1 timer2_var                         size    A   flags 2
+   2 timer2_isr                         size   77   flags 1

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -