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

📄 led_car.lst

📁 单片机开发资料光盘-双龙-686M.zip
💻 LST
📖 第 1 页 / 共 3 页
字号:
(0208) 	   turn_left();         //左转
    00F2 DFA1      RCALL	_turn_left
(0209)        delay_ms(touch_time);
    00F3 EF0A      LDI	R16,0xFA
    00F4 E010      LDI	R17,0
    00F5 DF8B      RCALL	_delay_ms
(0210)    }
(0211)  if(sw_in == 0x20)// 0b 0010,0000  两侧开关同时接触,停止运动
    00F6 918000E0  LDS	R24,_sw_in
    00F8 3280      CPI	R24,0x20
    00F9 F4F1      BNE	0x0118
(0212)    {
(0213) 	stop();       //停止运动,熄灭指示灯
    00FA DFB2      RCALL	_stop
(0214)     delay_ms(touch_time*4);
    00FB EE08      LDI	R16,0xE8
    00FC E013      LDI	R17,3
    00FD DF83      RCALL	_delay_ms
    00FE C018      RJMP	0x0117
(0215) 	while(1)
(0216) 	     {
(0217) 		  sw_in = PINC & 0x10;
    00FF B383      IN	R24,0x13
    0100 7180      ANDI	R24,0x10
    0101 938000E0  STS	_sw_in,R24
(0218) 		  if(sw_in == 0x00)
    0103 2388      TST	R24
    0104 F409      BNE	0x0106
(0219) 		    {break;}
    0105 C012      RJMP	0x0118
(0220) 		  PORTA = 0x55;
    0106 E585      LDI	R24,0x55
    0107 BB8B      OUT	0x1B,R24
(0221) 		  delay_ms(250);
    0108 EF0A      LDI	R16,0xFA
    0109 E010      LDI	R17,0
    010A DF76      RCALL	_delay_ms
(0222) 		  PORTA = 0xAA;
    010B EA8A      LDI	R24,0xAA
    010C BB8B      OUT	0x1B,R24
(0223) 		  delay_ms(250);
    010D EF0A      LDI	R16,0xFA
    010E E010      LDI	R17,0
    010F DF71      RCALL	_delay_ms
(0224) 		  remote_in = PINB & 0x0f;
    0110 B386      IN	R24,0x16
    0111 708F      ANDI	R24,0xF
    0112 938000DF  STS	_remote_in,R24
(0225) 		  if(remote_in != 0x00)
    0114 2388      TST	R24
    0115 F009      BEQ	0x0117
(0226) 		    {break;}
    0116 C001      RJMP	0x0118
    0117 CFE7      RJMP	0x00FF
(0227) 		 }
(0228)    }   
(0229) }
    0118 9508      RET
(0230) 
(0231) void mic_startup()
(0232) {//声控启动程序运行
_mic_startup:
    0119 C007      RJMP	0x0121
(0233) 
(0234)  while(1)//等待pc3(声控键)按键按下	
(0235)  {	  //无键按下等待
(0236)   mic_in = PINC & 0x08;     //pc2=0
    011A B383      IN	R24,0x13
    011B 7088      ANDI	R24,0x8
    011C 938000DE  STS	_mic_in,R24
(0237)   if(mic_in == 0){break;}
    011E 2388      TST	R24
    011F F409      BNE	0x0121
    0120 C001      RJMP	0x0122
    0121 CFF8      RJMP	0x011A
(0238)  }//有键按下运行下面的程序
(0239) }
    0122 9508      RET
(0240) 
(0241) //                #       
(0242) //                #
(0243) //                #
(0244) //                #
(0245) //                #    //  delay_time1  转弯时间
(0246) //        # # # # #    //  delay_time2  直行时间
(0247) //      # X       #    //<A>  0x04  delay_time2-50
(0248) //      #   B  C  #    //<B>  0x02  delay_time1+50
(0249) //      #  D  A   #    //<C>  0x08  delay_time1-50
(0250) //      #         #    //<D>  0x01  delay_time2+50
(0251) //        # # # #      // max: 2000   min: 200 
(0252) 
(0253) void remote_auto_time()
(0254) {
(0255)  	  remote_in = PINB & 0x0F;
_remote_auto_time:
    0123 B386      IN	R24,0x16
    0124 708F      ANDI	R24,0xF
    0125 938000DF  STS	_remote_in,R24
(0256)       switch (remote_in)
    0127 2F08      MOV	R16,R24
    0128 2711      CLR	R17
    0129 3000      CPI	R16,0
    012A 0701      CPC	R16,R17
    012B F409      BNE	0x012D
    012C C062      RJMP	0x018F
    012D 3001      CPI	R16,1
    012E E0E0      LDI	R30,0
    012F 071E      CPC	R17,R30
    0130 F409      BNE	0x0132
    0131 C04A      RJMP	0x017C
    0132 3002      CPI	R16,2
    0133 E0E0      LDI	R30,0
    0134 071E      CPC	R17,R30
    0135 F0F1      BEQ	0x0154
    0136 3004      CPI	R16,4
    0137 E0E0      LDI	R30,0
    0138 071E      CPC	R17,R30
    0139 F029      BEQ	0x013F
    013A 3008      CPI	R16,0x8
    013B E0E0      LDI	R30,0
    013C 071E      CPC	R17,R30
    013D F151      BEQ	0x0168
    013E C050      RJMP	0x018F
(0257)       	{//检测遥控器是否有键按下
(0258)       case 0x04:  // < A >
(0259) 		 delay_time2 = delay_time2 - 50;
    013F 918000DA  LDS	R24,_delay_time2
    0141 919000DB  LDS	R25,_delay_time2+1
    0143 97C2      SBIW	R24,0x32
    0144 939000DB  STS	_delay_time2+1,R25
    0146 938000DA  STS	_delay_time2,R24
(0260) 	     if(delay_time2 == 50)
    0148 3382      CPI	R24,0x32
    0149 E0E0      LDI	R30,0
    014A 079E      CPC	R25,R30
    014B F009      BEQ	0x014D
    014C C042      RJMP	0x018F
(0261) 		   {delay_time2 = 100;}	 
    014D E684      LDI	R24,0x64
    014E E090      LDI	R25,0
    014F 939000DB  STS	_delay_time2+1,R25
    0151 938000DA  STS	_delay_time2,R24
(0262)       	break;
    0153 C03B      RJMP	0x018F
(0263)       case 0x02:  // < B >
(0264) 		 delay_time1 = delay_time1 + 50;
    0154 918000DC  LDS	R24,_delay_time1
    0156 919000DD  LDS	R25,_delay_time1+1
    0158 96C2      ADIW	R24,0x32
    0159 939000DD  STS	_delay_time1+1,R25
    015B 938000DC  STS	_delay_time1,R24
(0265) 	     if(delay_time1 == 2050)
    015D 3082      CPI	R24,2
    015E E0E8      LDI	R30,0x8
    015F 079E      CPC	R25,R30
    0160 F571      BNE	0x018F
(0266) 		   {delay_time1 = 2000;}	 
    0161 ED80      LDI	R24,0xD0
    0162 E097      LDI	R25,7
    0163 939000DD  STS	_delay_time1+1,R25
    0165 938000DC  STS	_delay_time1,R24
(0267)       	break;
    0167 C027      RJMP	0x018F
(0268)       case 0x08:  // < C >
(0269) 		 delay_time1 = delay_time1 - 50;
    0168 918000DC  LDS	R24,_delay_time1
    016A 919000DD  LDS	R25,_delay_time1+1
    016C 97C2      SBIW	R24,0x32
    016D 939000DD  STS	_delay_time1+1,R25
    016F 938000DC  STS	_delay_time1,R24
(0270) 	     if(delay_time1 == 50)
    0171 3382      CPI	R24,0x32
    0172 E0E0      LDI	R30,0
    0173 079E      CPC	R25,R30
    0174 F4D1      BNE	0x018F
(0271) 		   {delay_time1 = 100;}	 
    0175 E684      LDI	R24,0x64
    0176 E090      LDI	R25,0
    0177 939000DD  STS	_delay_time1+1,R25
    0179 938000DC  STS	_delay_time1,R24
(0272)       	break;
    017B C013      RJMP	0x018F
(0273)       case 0x01:  // < D >
(0274)          delay_time2 = delay_time2 + 50;
    017C 918000DA  LDS	R24,_delay_time2
    017E 919000DB  LDS	R25,_delay_time2+1
    0180 96C2      ADIW	R24,0x32
    0181 939000DB  STS	_delay_time2+1,R25
    0183 938000DA  STS	_delay_time2,R24
(0275) 	     if(delay_time2 == 2050)
    0185 3082      CPI	R24,2
    0186 E0E8      LDI	R30,0x8
    0187 079E      CPC	R25,R30
    0188 F431      BNE	0x018F
(0276) 		   {delay_time2 = 2000;}	 
    0189 ED80      LDI	R24,0xD0
    018A E097      LDI	R25,7
    018B 939000DB  STS	_delay_time2+1,R25
    018D 938000DA  STS	_delay_time2,R24
(0277)       	break;
(0278)       case 0x00:  // 无按键
(0279) 	     break;
(0280) 		} 
(0281) }
    018F 9508      RET
FILE: E:\icc\iccavr\sl3010\led_car\led_car.c
(0001) // Target : 8515
(0002) // Crystal: 8.0000Mhz
(0003) //最后更新:2003.03.15
(0004) 
(0005) #include <io8515v.h>
(0006) #include <macros.h>
(0007) #include <sl3010.c>
(0008) static unsigned char led_data[]=
(0009)     {//设置LED广告灯数据表
(0010)      0xfe,0xfd,0xfb,0xf7,0xef,0xdf,0xbf,0x7f,0xbf,0xdf,0xef,0xf7,0xfb,0xfd,
(0011)      0xfe,0xfd,0xfb,0xf7,0xef,0xdf,0xbf,0x7f,0xbf,0xdf,0xef,0xf7,0xfb,0xfd,
(0012)      0x00,0x18,0x3c,0x7e,0xff,0x7e,0x3c,0x18,
(0013)      0x00,0x18,0x3c,0x7e,0xff,0x7e,0x3c,0x18,
(0014)      0xf8,0xf1,0xe3,0xc7,0x8f,0x1f,0x8f,0xc7,0xe3,0xf1,
(0015)      0xf8,0xf1,0xe3,0xc7,0x8f,0x1f,0x8f,0xc7,0xe3,0xf1,
(0016)      0xfe,0xfc,0xf8,0xf0,0xe0,0xc0,0x80,0x00,0x80,0xc0,0xe0,0xf0,0xf8,0xfc,
(0017)      0xfe,0xfc,0xf8,0xf0,0xe0,0xc0,0x80,0x00,0x80,0xc0,0xe0,0xf0,0xf8,0xfc,
(0018)      0xff,0xe7,0xdb,0xbd,0x7e,0xbd,0xdb,0xe7,
(0019)      0xff,0xe7,0xdb,0xbd,0x7e,0xbd,0xdb,0xe7,
(0020)      0xff,0x00,0xff,0x00,0xff,0x00,0xff,0x00,
(0021)      0x0a,0x0a
(0022)     };
(0023) unsigned char pa,timers;
(0024) unsigned int led_delayms=600;
(0025) 	 //定义为字符型变量
(0026) void led_car(void)
(0027) {
(0028)  port_init();         //PA,PB,PC,PD 初始化
_led_car:
    0190 DED8      RCALL	_port_init
(0029)  
(0030)  work_status = 0x40;//置对应的工作状态标志
    0191 E480      LDI	R24,0x40
    0192 938000E1  STS	_work_status,R24
(0031)  
(0032)  mic_startup();       //等待声控启动
    0194 DF84      RCALL	_mic_startup
    0195 C20E      RJMP	0x03A4
(0033)  
(0034)  while (1)
(0035)  	{
(0036) 	 pa = 0x00;
    0196 2422      CLR	R2
    0197 922000D9  STS	_pa,R2
(0037) 	 for(timers=0;timers<4;timers++)
    0199 922000D8  STS	_timers,R2
    019B C014      RJMP	0x01B0
(0038) 	    {//8 LED 整体亮灭闪烁
(0039) 	     PORTA=pa;
    019C 902000D9  LDS	R2,_pa
    019E BA2B      OUT	0x1B,R2
(0040) 	     delay_ms(led_delayms*2);
    019F 910000D6  LDS	R16,0xD6
    01A1 911000D7  LDS	R17,0xD7
    01A3 0F00      LSL	R16
    01A4 1F11      ROL	R17
    01A5 DEDB      RCALL	_delay_ms
(0041) 		 pa=~pa;
    01A6 902000D9  LDS	R2,_pa
    01A8 9420      COM	R2
    01A9 922000D9  STS	_pa,R2
    01AB 918000D8  LDS	R24,_timers
    01AD 5F8F      SUBI	R24,0xFF
    01AE 938000D8  STS	_timers,R24
    01B0 918000D8  LDS	R24,_timers
    01B2 3084      CPI	R24,4
    01B3 F340      BCS	0x019C
(0042) 		}
(0043) 	 
(0044) 	 pa = 0x01;
    01B4 E081      LDI	R24,1
    01B5 938000D9  STS	_pa,R24
(0045) 	 for(timers=0;timers<8;timers++)
    01B7 2422      CLR	R2
    01B8 922000D8  STS	_timers,R2
    01BA C015      RJMP	0x01D0
(0046) 	    {
(0047) 	     PORTA=~pa;
    01BB 902000D9  LDS	R2,_pa
    01BD 9420      COM	R2
    01BE BA2B      OUT	0x1B,R2
(0048) 	     delay_ms(led_delayms/2);
    01BF 910000D6  LDS	R16,0xD6
    01C1 911000D7  LDS	R17,0xD7
    01C3 9516      LSR	R17
    01C4 9507      ROR	R16
    01C5 DEBB      RCALL	_delay_ms
(0049) 		 pa=pa<<1;
    01C6 902000D9  LDS	R2,_pa
    01C8 0C22      LSL	R2
    01C9 922000D9  STS	_pa,R2
    01CB 918000D8  LDS	R24,_timers
    01CD 5F8F      SUBI	R24,0xFF
    01CE 938000D8  STS	_timers,R24
    01D0 918000D8  LDS	R24,_timers
    01D2 3088      CPI	R24,0x8
    01D3 F338      BCS	0x01BB
(0050) 		}
(0051) 		
(0052) 	 pa = 0x80;
    01D4 E880      LDI	R24,0x80
    01D5 938000D9  STS	_pa,R24
(0053) 	 for(timers=0;timers<8;timers++)
    01D7 2422      CLR	R2
    01D8 922000D8  STS	_timers,R2
    01DA C015      RJMP	0x01F0
(0054) 	    {
(0055) 	     PORTA=~pa;
    01DB 902000D9  LDS	R2,_pa
    01DD 9420      COM	R2
    01DE BA2B      OUT	0x1B,R2
(0056) 	     delay_ms(led_delayms/2);
    01DF 910000D6  LDS	R16,0xD6
    01E1 911000D7  LDS	R17,0xD7
    01E3 9516      LSR	R17
    01E4 9507      ROR	R16
    01E5 DE9B      RCALL	_delay_ms
(0057) 		 pa=pa>>1;
    01E6 902000D9  LDS	R2,_pa
    01E8 9426      LSR	R2
    01E9 922000D9  STS	_pa,R2
    01EB 918000D8  LDS	R24,_timers
    01ED 5F8F      SUBI	R24,0xFF
    01EE 938000D8  STS	_timers,R24
    01F0 918000D8  LDS	R24,_timers
    01F2 3088      CPI	R24,0x8
    01F3 F338      BCS	0x01DB
(0058) 		}
(0059) 
(0060) 	 pa = 0x01;
    01F4 E081      LDI	R24,1
    01F5 938000D9  STS	_pa,R24
(0061) 	 for(timers=0;timers<8;timers++)
    01F7 2422      CLR	R2
    01F8 922000D8  STS	_timers,R2
    01FA C018      RJMP	0x0213
(0062) 	    {
(0063) 	     PORTA=~pa;
    01FB 902000D9  LDS	R2,_pa
    01FD 9420      COM	R2
    01FE BA2B      OUT	0x1B,R2
(0064) 	     delay_ms(led_delayms/2);
    01FF 910000D6  LDS	R16,0xD6
    0201 911000D7  LDS	R17,0xD7
    0203 9516      LSR	R17
    0204 9507      ROR	R16
    0205 DE7B      RCALL	_delay_ms
(0065) 		 pa=pa|(pa<<1);
    0206 902000D9  LDS	R2,_pa
    0208 0C22      LSL	R2
    0209 903000D9  LDS	R3,_pa
    020B 2832      OR	R3,R2
    020C 923000D9  STS	_pa,R3
    020E 918000D8  LDS	R24,_timers
    0210 5F8F      SUBI	R24,0xFF
    0211 938000D8  STS	_timers,R24
    0213 918000D8  LDS	R24,_timers
    0215 3088      CPI	R24,0x8
    0216 F320      BCS	0x01FB
(0066) 		}
(0067) 	
(0068) 	 pa = 0x7f;
    0217 E78F      LDI	R24,0x7F
    0218 938000D9  STS	_pa,R24
(0069) 	 for(timers=0;timers<8;timers++)
    021A 2422      CLR	R2
    021B 922000D8  STS	_timers,R2
    021D C018      RJMP	0x0236
(0070) 	    {
(0071) 	     PORTA=~pa;
    021E 902000D9  LDS	R2,_pa
    0220 9420      COM	R2
    0221 BA2B      OUT	0x1B,R2
(0072) 	     delay_ms(led_delayms/2);
    0222 910000D6  LDS	R16,0xD6
    0224 911000D7  LDS	R17,0xD7
    0226 9516      LSR	R17
    0227 9507      ROR	R16
    0228 DE58      RCALL	_delay_ms
(0073) 		 pa=pa & (pa>>1);
    0229 902000D9  LDS	R2,_pa
    022B 9426      LSR	R2

⌨️ 快捷键说明

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