单片机开发资料光盘-双龙-686M.zip

源代码在线查看: trace_light.s

软件大小: 574027 K
上传用户: rllfllef
关键词: 686 zip 单片机 光盘
下载地址: 免注册下载 普通下载 VIP

相关代码

					.module trace_light.c
					.area text(rom, con, rel)
					.dbfile e:/ICC/include/sl3010.c
					.dbfunc e port_init _port_init fV
					.even
				_port_init::
					.dbline -1
					.dbline 81
				; //追光机器人
				; 
				; #include 
				; #include 
				; #include   //调用sl3010小车的子函数库
				; 
				; #define light_delay 100
				; 
				; unsigned char cds;
				; 
				; void trace_light()
				; {
				;  port_init();         //PA,PB,PC,PD 初始化
				;  
				;  work_status = 0x70;  //置对应的工作状态标志
				;  
				;  mic_startup();       //等待声控启动
				;  
				;  while(1)
				;     {
				; 	 sw_touch();          //检测轻触开关
				; 	
				; 	 cds = PINC & 0x06; //0b0000,0110
				; 
				; 	 if(cds == 0x00)    //左右两侧都感测到光
				; 	   {//直行
				; 	    forward();
				; 		delay_ms(light_delay);  //延时
				; 	   } 
				; 	 if(cds == 0x02)    //0b0000,0010___pc2(右侧)感测到光
				; 	   {//慢速右转
				; 	    turn_right_s();
				; 		delay_ms(light_delay);  //延时
				; 	   }
				; 	 if(cds == 0x04)    //0b0000,0100___pc1(左侧)感测到光
				; 	   {//慢速左转
				; 	    turn_left_s();
				; 		delay_ms(light_delay);  //延时
				; 	   }
				; 	 if(cds == 0x06)
				; 	   {//停止动作
				; 	    PORTA = 0x55;   //延时后停止动作,等待光照重新动作
				; 		delay_ms(light_delay*2);
				; 		stop();
				; 	   }
				; 	}
				; }
				; 
				; void main()
				; {
				;  trace_light();
				; }
				; }
				; }
				; }
				; }
				; }
				; }
				; }
				; }
				; }
				; }
				; }
				; }
				; }
				; }
				; }
				; }
				; }
				; }
				; }
				; }
				; }
				; }
				; }
				; }
				; }
				; }
				; }
				; }
				; }
					.dbline 82
				; }
					ldi R24,255
					out 0x1a,R24
					.dbline 82
					out 0x1b,R24
					.dbline 83
				; }
					ldi R24,128
					out 0x17,R24
					.dbline 83
					ldi R24,255
					out 0x18,R24
					.dbline 84
				; }
					ldi R24,1
					out 0x14,R24
					.dbline 84
					ldi R24,255
					out 0x15,R24
					.dbline 85
				; }
					ldi R24,240
					out 0x11,R24
					.dbline 85
					ldi R24,255
					out 0x12,R24
					.dbline -2
					.dbline 86
				; }
				L1:
					.dbline 0 ; func end
					ret
					.dbend
					.dbfunc e delay_us _delay_us fV
				;           time -> R16,R17
					.even
				_delay_us::
					.dbline -1
					.dbline 89
				; }
				; }
				; }
				L3:
					.dbline 91
				; }
				; }
					.dbline 92
				; }
					subi R16,1
					sbci R17,0
					.dbline 93
				; }
				L4:
					.dbline 94
				; }
					ldi R24,1
					ldi R25,0
					cp R24,R16
					cpc R25,R17
					brlt L3
					.dbline -2
					.dbline 95
				; }
				L2:
					.dbline 0 ; func end
					ret
					.dbsym r time 16 I
					.dbend
					.dbfunc e delay_ms _delay_ms fV
				;           time -> R20,R21
					.even
				_delay_ms::
					rcall push_gset1
					mov R20,R16
					mov R21,R17
					.dbline -1
					.dbline 98
				; }
				; }
				; }
					rjmp L8
				L7:
					.dbline 100
					.dbline 101
					ldi R16,1000
					ldi R17,3
					rcall _delay_us
					.dbline 102
					subi R20,1
					sbci R21,0
					.dbline 103
				L8:
					.dbline 99
				; }
					cpi R20,0
					cpc R20,R21
					brne L7
				X0:
					.dbline -2
					.dbline 104
				; }
				; }
				; }
				; }
				; }
				L6:
					rcall pop_gset1
					.dbline 0 ; func end
					ret
					.dbsym r time 20 i
					.dbend
					.dbfunc e turn_right _turn_right fV
					.even
				_turn_right::
					.dbline -1
					.dbline 107
				; }
				; }
				; }
					.dbline 108
				; }
					ldi R24,96
					out 0x12,R24
					.dbline 109
				; }
					ldi R24,204
					out 0x1b,R24
					.dbline -2
					.dbline 110
				; }
				L10:
					.dbline 0 ; func end
					ret
					.dbend
					.dbfunc e turn_left _turn_left fV
					.even
				_turn_left::
					.dbline -1
					.dbline 113
				; }
				; }
				; }
					.dbline 114
				; }
					ldi R24,144
					out 0x12,R24
					.dbline 115
				; }
					ldi R24,51
					out 0x1b,R24
					.dbline -2
					.dbline 116
				; }
				L11:
					.dbline 0 ; func end
					ret
					.dbend
					.dbfunc e turn_right_s _turn_right_s fV
					.even
				_turn_right_s::
					.dbline -1
					.dbline 118
				; }
				; }
					.dbline 119
				; }
					ldi R24,32
					out 0x12,R24
					.dbline 120
				; }
					ldi R24,207
					out 0x1b,R24
					.dbline -2
					.dbline 121
				; }
				L12:
					.dbline 0 ; func end
					ret
					.dbend
					.dbfunc e turn_left_s _turn_left_s fV
					.even
				_turn_left_s::
					.dbline -1
					.dbline 124
				; }
				; }
				; }
					.dbline 125
				; }
					ldi R24,128
					out 0x12,R24
					.dbline 126
				; }
					ldi R24,243
					out 0x1b,R24
					.dbline -2
					.dbline 127
				; }
				L13:
					.dbline 0 ; func end
					ret
					.dbend
					.dbfunc e backward _backward fV
					.even
				_backward::
					.dbline -1
					.dbline 130
				; }
				; }
				; }
					.dbline 131
				; }
					ldi R24,80
					out 0x12,R24
					.dbline 132
				; }
					ldi R24,60
					out 0x1b,R24
					.dbline -2
					.dbline 133
				; }
				L14:
					.dbline 0 ; func end
					ret
					.dbend
					.dbfunc e forward _forward fV
					.even
				_forward::
					.dbline -1
					.dbline 136
				; }
				; }
				; }
					.dbline 137
				; }
					ldi R24,160
					out 0x12,R24
					.dbline 138
				; }
					ldi R24,195
					out 0x1b,R24
					.dbline -2
					.dbline 139
				; }
				L15:
					.dbline 0 ; func end
					ret
					.dbend
					.dbfunc e stop _stop fV
					.even
				_stop::
					.dbline -1
					.dbline 142
				; }
				; }
				; }
					.dbline 143
				; }
					ldi R24,255
					out 0x12,R24
					.dbline 144
				; }
					out 0x1b,R24
					.dbline -2
					.dbline 145
				; }
				L16:
					.dbline 0 ; func end
					ret
					.dbend
					.dbfunc e sw_touch _sw_touch fV
				;      remote_in -> R22
				;          sw_in -> R20
					.even
				_sw_touch::
					rcall push_gset2
					.dbline -1
					.dbline 161
				; }
				; }
				; }
				; }
				; }
				; }
				; }
				; }
				; }
				; }
				; }
				; }
				; }
				; }
				; }
				; }
					.dbline 163
				; }
				; }
					ldi R24,1
					out 0x14,R24
					.dbline 163
					ldi R24,255
					out 0x15,R24
					.dbline 164
				; }
					ldi R24,128
					out 0x17,R24
					.dbline 164
					ldi R24,255
					out 0x18,R24
					.dbline 166
				; }
				; }
					in R20,0x13
					andi R20,16
					.dbline 167
				; }
					brne L18
					.dbline 168
				; }
					.dbline 169
				; }
					rcall _backward
					.dbline 170
				; }
					ldi R16,250
					ldi R17,0
					rcall _delay_ms
					.dbline 172
				; }
				; }
					lds R24,_work_status
					cpi R24,112
					brne L20
					.dbline 173
				; }
					.dbline 174
				; }
					rcall _stop
					rjmp L23
				L22:
					.dbline 176
					.dbline 177
					ldi R24,85
					out 0x1b,R24
					.dbline 178
					ldi R16,250
					ldi R17,0
					rcall _delay_ms
					.dbline 179
					ldi R24,170
					out 0x1b,R24
					.dbline 180
					ldi R16,250
					ldi R17,0
					rcall _delay_ms
					.dbline 181
				L23:
					.dbline 175
				; }
					rjmp L22
				X1:
					.dbline 182
				; }
				; }
				; }
				; }
				; }
				; }
				; }
				L20:
					.dbline 184
				; }
				; }
					rcall _turn_left
					.dbline 185
				; }
					ldi R16,250
					ldi R17,0
					rcall _delay_ms
					.dbline 186
				; }
				L18:
					.dbline 188
				; }
				; }
					in R20,0x16
					andi R20,112
					.dbline 189
				; }
					cpi R20,80
					brne L25
					.dbline 190
				; }
					.dbline 191
				; }
					rcall _forward
					.dbline 192
				; }
					ldi R16,250
					ldi R17,0
					rcall _delay_ms
					.dbline 194
				; }
				; }
					rcall _turn_left
					.dbline 195
				; }
					ldi R16,250
					ldi R17,0
					rcall _delay_ms
					.dbline 196
				; }
				L25:
					.dbline 197
				; }
					cpi R20,48
					brne L27
					.dbline 198
				; }
					.dbline 199
				; }
					rcall _backward
					.dbline 200
				; }
					ldi R16,250
					ldi R17,0
					rcall _delay_ms
					.dbline 202
				; }
				; }
					rcall _turn_left
					.dbline 203
				; }
					ldi R16,250
					ldi R17,0
					rcall _delay_ms
					.dbline 204
				; }
				L27:
					.dbline 205
				; }
					cpi R20,96
					brne L29
					.dbline 206
				; }
					.dbline 207
				; }
					rcall _backward
					.dbline 208
				; }
					ldi R16,250
					ldi R17,0
					rcall _delay_ms
					.dbline 210
				; }
				; }
					rcall _turn_left
					.dbline 211
				; }
					ldi R16,250
					ldi R17,0
					rcall _delay_ms
					.dbline 212
				; }
				L29:
					.dbline 213
				; }
					cpi R20,32
					brne L31
					.dbline 214
				; }
					.dbline 215
				; }
					rcall _stop
					.dbline 216
				; }
					ldi R16,1000
					ldi R17,3
					rcall _delay_ms
					rjmp L34
				L33:
					.dbline 218
				; }
				; }
					.dbline 219
				; }
					in R20,0x13
					andi R20,16
					.dbline 220
				; }
					brne L36
					.dbline 221
				; }
					.dbline 221
					rjmp L35
				L36:
					.dbline 222
				; }
					ldi R24,85
					out 0x1b,R24
					.dbline 223
				; }
					ldi R16,250
					ldi R17,0
					rcall _delay_ms
					.dbline 224
				; }
					ldi R24,170
					out 0x1b,R24
					.dbline 225
				; }
					ldi R16,250
					ldi R17,0
					rcall _delay_ms
					.dbline 226
				; }
					in R22,0x16
					andi R22,15
					.dbline 227
				; }
					breq L38
					.dbline 228
				; }
					.dbline 228
					rjmp L35
				L38:
					.dbline 229
				L34:
					.dbline 217
					rjmp L33
				L35:
					.dbline 230
				L31:
					.dbline -2
					.dbline 231
				; }
				; }
				; }
				L17:
					rcall pop_gset2
					.dbline 0 ; func end
					ret
					.dbsym r remote_in 22 c
					.dbsym r sw_in 20 c
					.dbend
					.dbfunc e mic_startup _mic_startup fV
				;         mic_in -> R20
					.even
				_mic_startup::
					rcall push_gset1
					.dbline -1
					.dbline 234
				; }
				; }
				; }
					.dbline 236
				; }
				; }
					ldi R24,1
					out 0x14,R24
					.dbline 236
					ldi R24,255
					out 0x15,R24
					.dbline 237
				; }
					ldi R16,1
					ldi R17,0
					rcall _delay_us
					rjmp L42
				L41:
					.dbline 239
				; }
				; }
					.dbline 240
				; }
					in R20,0x13
					andi R20,8
					.dbline 241
				; }
					brne L44
					.dbline 241
					.dbline 241
					rjmp L43
				L44:
					.dbline 242
				L42:
					.dbline 238
					rjmp L41
				L43:
					.dbline -2
					.dbline 243
				; }
				; }
				L40:
					rcall pop_gset1
					.dbline 0 ; func end
					ret
					.dbsym r mic_in 20 c
					.dbend
					.dbfunc e remote_auto_time _remote_auto_time fV
				;      remote_in -> R16
					.even
				_remote_auto_time::
					.dbline -1
					.dbline 260
				; }
				; }
				; }
				; }
				; }
				; }
				; }
				; }
				; }
				; }
				; }
				; }
				; }
				; }
				; }
				; }
				; }
					.dbline 262
				; }
				; }
					in R16,0x16
					andi R16,15
					.dbline 263
				; }
					clr R17
					cpi R16,0
					cpc R16,R17
					brne X4
					rjmp L48
				X4:
				X2:
					cpi R16,1
					ldi R30,0
					cpc R17,R30
					brne X5
					rjmp L59
				X5:
					cpi R16,2
					ldi R30,0
					cpc R17,R30
					breq L53
					cpi R16,4
					ldi R30,0
					cpc R17,R30
					breq L50
					cpi R16,8
					ldi R30,0
					cpc R17,R30
					breq L56
					rjmp L47
				X3:
					.dbline 264
				; }
				L50:
					.dbline 266
				; }
				; }
					lds R24,_delay_time2
					lds R25,_delay_time2+1
					sbiw R24,50
					sts _delay_time2+1,R25
					sts _delay_time2,R24
					.dbline 267
				; }
					cpi R24,50
					ldi R30,0
					cpc R25,R30
					breq X6
					rjmp L48
				X6:
					.dbline 268
				; }
					.dbline 268
					ldi R24,100
					ldi R25,0
					sts _delay_time2+1,R25
					sts _delay_time2,R24
					.dbline 268
					.dbline 269
				; }
					rjmp L48
				L53:
					.dbline 271
				; }
				; }
					lds R24,_delay_time1
					lds R25,_delay_time1+1
					adiw R24,50
					sts _delay_time1+1,R25
					sts _delay_time1,R24
					.dbline 272
				; }
					cpi R24,2
					ldi R30,8
					cpc R25,R30
					brne L48
					.dbline 273
				; }
					.dbline 273
					ldi R24,2000
					ldi R25,7
					sts _delay_time1+1,R25
					sts _delay_time1,R24
					.dbline 273
					.dbline 274
				; }
					rjmp L48
				L56:
					.dbline 276
				; }
				; }
					lds R24,_delay_time1
					lds R25,_delay_time1+1
					sbiw R24,50
					sts _delay_time1+1,R25
					sts _delay_time1,R24
					.dbline 277
				; }
					cpi R24,50
					ldi R30,0
					cpc R25,R30
					brne L48
					.dbline 278
				; }
					.dbline 278
					ldi R24,100
					ldi R25,0
					sts _delay_time1+1,R25
					sts _delay_time1,R24
					.dbline 278
					.dbline 279
				; }
					rjmp L48
				L59:
					.dbline 281
				; }
				; }
					lds R24,_delay_time2
					lds R25,_delay_time2+1
					adiw R24,50
					sts _delay_time2+1,R25
					sts _delay_time2,R24
					.dbline 282
				; }
					cpi R24,2
					ldi R30,8
					cpc R25,R30
					brne L48
					.dbline 283
				; }
					.dbline 283
					ldi R24,2000
					ldi R25,7
					sts _delay_time2+1,R25
					sts _delay_time2,R24
					.dbline 283
					.dbline 284
				; }
					.dbline 286
				; }
				; }
				L47:
				L48:
					.dbline -2
					.dbline 288
				; }
				; }
				L46:
					.dbline 0 ; func end
					ret
					.dbsym r remote_in 16 c
					.dbend
					.dbfile E:\icc\iccavr\sl3010\trace_light\trace_light.c
					.dbfunc e trace_light _trace_light fV
					.even
				_trace_light::
					.dbline -1
					.dbline 12
					.dbline 13
					rcall _port_init
					.dbline 15
					ldi R24,112
					sts _work_status,R24
					.dbline 17
					rcall _mic_startup
					rjmp L65
				L64:
					.dbline 20
					.dbline 21
					rcall _sw_touch
					.dbline 23
					in R24,0x13
					andi R24,6
					sts _cds,R24
					.dbline 25
					tst R24
					brne L67
					.dbline 26
					.dbline 27
					rcall _forward
					.dbline 28
					ldi R16,100
					ldi R17,0
					rcall _delay_ms
					.dbline 29
				L67:
					.dbline 30
					lds R24,_cds
					cpi R24,2
					brne L69
					.dbline 31
					.dbline 32
					rcall _turn_right_s
					.dbline 33
					ldi R16,100
					ldi R17,0
					rcall _delay_ms
					.dbline 34
				L69:
					.dbline 35
					lds R24,_cds
					cpi R24,4
					brne L71
					.dbline 36
					.dbline 37
					rcall _turn_left_s
					.dbline 38
					ldi R16,100
					ldi R17,0
					rcall _delay_ms
					.dbline 39
				L71:
					.dbline 40
					lds R24,_cds
					cpi R24,6
					brne L73
					.dbline 41
					.dbline 42
					ldi R24,85
					out 0x1b,R24
					.dbline 43
					ldi R16,200
					ldi R17,0
					rcall _delay_ms
					.dbline 44
					rcall _stop
					.dbline 45
				L73:
					.dbline 46
				L65:
					.dbline 19
					rjmp L64
				X7:
					.dbline -2
					.dbline 47
				L63:
					.dbline 0 ; func end
					ret
					.dbend
					.dbfunc e main _main fV
					.even
				_main::
					.dbline -1
					.dbline 50
					.dbline 51
					.dbline -2
					.dbline 52
				L75:
					.dbline 0 ; func end
					rjmp _trace_light
					.dbend
					.area bss(ram, con, rel)
					.dbfile E:\icc\iccavr\sl3010\trace_light\trace_light.c
				_cds::
					.blkb 1
					.dbsym e cds _cds c
				_delay_time2::
					.blkb 2
					.dbfile e:/ICC/include/sl3010.c
					.dbsym e delay_time2 _delay_time2 i
				_delay_time1::
					.blkb 2
					.dbsym e delay_time1 _delay_time1 i
				_work_status::
					.blkb 1
					.dbsym e work_status _work_status c
							

相关资源