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

📄 mkq_m8.lss

📁 一个使用AVR的M8控制单相电容启动电机的程序
💻 LSS
📖 第 1 页 / 共 2 页
字号:
 1d4:	80 93 69 00 	sts	0x0069, r24
			state=3;			
 1d8:	83 e0       	ldi	r24, 0x03	; 3
 1da:	03 c0       	rjmp	.+6      	; 0x1e2 <door_state_init+0x32>
			err_f=1;
			break;

		case 6://110	行程开关位置有冲突 报警
			state=8;err_f=1;
 1dc:	88 e0       	ldi	r24, 0x08	; 8
 1de:	01 c0       	rjmp	.+2      	; 0x1e2 <door_state_init+0x32>
			break;
		case 7://111 	门安装初态111  门未合上
			state=4;err_f=1;
 1e0:	84 e0       	ldi	r24, 0x04	; 4
 1e2:	80 93 66 00 	sts	0x0066, r24
 1e6:	81 e0       	ldi	r24, 0x01	; 1
 1e8:	80 93 6f 00 	sts	0x006F, r24
			break;
	}
	//101 111为安装初态处理 (锁紧机构在中间,既未锁紧也未解锁)
	//001为可能的断电恢复处理(门合上且解锁)
	//000 010 110为行程开关不正常组合,应解除故障再操作!
	PORTD|=0XF0;PORTD&=(state<<4);//状态指示
 1ec:	82 b3       	in	r24, 0x12	; 18
 1ee:	80 6f       	ori	r24, 0xF0	; 240
 1f0:	82 bb       	out	0x12, r24	; 18
 1f2:	80 91 66 00 	lds	r24, 0x0066
 1f6:	99 27       	eor	r25, r25
 1f8:	24 e0       	ldi	r18, 0x04	; 4
 1fa:	88 0f       	add	r24, r24
 1fc:	99 1f       	adc	r25, r25
 1fe:	2a 95       	dec	r18
 200:	e1 f7       	brne	.-8      	; 0x1fa <door_state_init+0x4a>
 202:	22 b3       	in	r18, 0x12	; 18
 204:	28 23       	and	r18, r24
 206:	22 bb       	out	0x12, r18	; 18
 208:	08 95       	ret

0000020a <door_mainloop>:
}

//************************************
void	door_mainloop(void)
{
	uchar	temp;
	if(!f_200ms)return;
 20a:	80 91 6b 00 	lds	r24, 0x006B
 20e:	88 23       	and	r24, r24
 210:	09 f4       	brne	.+2      	; 0x214 <door_mainloop+0xa>
 212:	bd c0       	rjmp	.+378    	; 0x38e <door_mainloop+0x184>
	f_200ms=0;
 214:	10 92 6b 00 	sts	0x006B, r1
	temp=XCKG;
 218:	23 b3       	in	r18, 0x13	; 19
 21a:	28 73       	andi	r18, 0x38	; 56
	temp>>=3;
 21c:	26 95       	lsr	r18
 21e:	26 95       	lsr	r18
 220:	26 95       	lsr	r18
	err_f=0;ERR_OFF;//暂时关闭报警
 222:	10 92 6f 00 	sts	0x006F, r1
 226:	c1 9a       	sbi	0x18, 1	; 24
	switch(state)
 228:	80 91 66 00 	lds	r24, 0x0066
 22c:	99 27       	eor	r25, r25
 22e:	aa 27       	eor	r26, r26
 230:	bb 27       	eor	r27, r27
 232:	fc 01       	movw	r30, r24
 234:	09 97       	sbiw	r24, 0x09	; 9
 236:	08 f0       	brcs	.+2      	; 0x23a <door_mainloop+0x30>
 238:	93 c0       	rjmp	.+294    	; 0x360 <door_mainloop+0x156>
 23a:	e5 5e       	subi	r30, 0xE5	; 229
 23c:	ff 4f       	sbci	r31, 0xFF	; 255
 23e:	09 94       	ijmp
	{
		case 0://锁紧
			switch(temp)//锁紧态,只有按钮和密码板脉冲才能开启。
 240:	24 30       	cpi	r18, 0x04	; 4
 242:	09 f0       	breq	.+2      	; 0x246 <door_mainloop+0x3c>
 244:	75 c0       	rjmp	.+234    	; 0x330 <door_mainloop+0x126>
			{
				case 4:if(f_key){state=1;moto_fan();f_12s=0;cnt_12s=CONST_12S;}//进入开门初始态  
 246:	80 91 6d 00 	lds	r24, 0x006D
 24a:	88 23       	and	r24, r24
 24c:	09 f4       	brne	.+2      	; 0x250 <door_mainloop+0x46>
 24e:	88 c0       	rjmp	.+272    	; 0x360 <door_mainloop+0x156>
 250:	65 c0       	rjmp	.+202    	; 0x31c <door_mainloop+0x112>
					break;
				default:state=8;f_key=0;err_f=1;
					break;	
				//3 5 7 行程开关位置错误 此错误只有手动使门锁紧行程开关合上=0,才能恢复
			}
			break;
			
		case 1://正开门态
			switch(temp)
 252:	23 30       	cpi	r18, 0x03	; 3
 254:	39 f4       	brne	.+14     	; 0x264 <door_mainloop+0x5a>
			{
				case 3: state=2;UNLOCK_OFF;f_key=0;
 256:	82 e0       	ldi	r24, 0x02	; 2
 258:	80 93 66 00 	sts	0x0066, r24
 25c:	a9 9a       	sbi	0x15, 1	; 21
 25e:	10 92 6d 00 	sts	0x006D, r1
					break;//完成开门
 262:	7e c0       	rjmp	.+252    	; 0x360 <door_mainloop+0x156>
				default:
					if(f_12s==1)
 264:	90 91 6e 00 	lds	r25, 0x006E
 268:	91 30       	cpi	r25, 0x01	; 1
 26a:	09 f0       	breq	.+2      	; 0x26e <door_mainloop+0x64>
 26c:	79 c0       	rjmp	.+242    	; 0x360 <door_mainloop+0x156>
					{
						state=8;f_key=0;UNLOCK_OFF;err_f=1;//门规定时间解不了锁
 26e:	88 e0       	ldi	r24, 0x08	; 8
 270:	80 93 66 00 	sts	0x0066, r24
 274:	10 92 6d 00 	sts	0x006D, r1
 278:	a9 9a       	sbi	0x15, 1	; 21
 27a:	90 93 6f 00 	sts	0x006F, r25
						if(temp==4){state=6;}//门一直锁紧
 27e:	24 30       	cpi	r18, 0x04	; 4
 280:	09 f0       	breq	.+2      	; 0x284 <door_mainloop+0x7a>
 282:	6e c0       	rjmp	.+220    	; 0x360 <door_mainloop+0x156>
 284:	86 e0       	ldi	r24, 0x06	; 6
 286:	63 c0       	rjmp	.+198    	; 0x34e <door_mainloop+0x144>
					}
						
					break;
			}
			break;

		case 2://打开
			switch(temp)
 288:	82 2f       	mov	r24, r18
 28a:	99 27       	eor	r25, r25
 28c:	81 30       	cpi	r24, 0x01	; 1
 28e:	91 05       	cpc	r25, r1
 290:	21 f0       	breq	.+8      	; 0x29a <door_mainloop+0x90>
 292:	03 97       	sbiw	r24, 0x03	; 3
 294:	09 f4       	brne	.+2      	; 0x298 <door_mainloop+0x8e>
 296:	64 c0       	rjmp	.+200    	; 0x360 <door_mainloop+0x156>
 298:	02 c0       	rjmp	.+4      	; 0x29e <door_mainloop+0x94>
			{
				case 3: 
					break;//门已打开
				case 1:	//门被合上
					state=3;moto_zhen();f_10s=0;cnt_10s=CONST_10S;//进入关门态
 29a:	83 e0       	ldi	r24, 0x03	; 3
 29c:	1c c0       	rjmp	.+56     	; 0x2d6 <door_mainloop+0xcc>
					break;
				default:state=8;err_f=1;
 29e:	88 e0       	ldi	r24, 0x08	; 8
 2a0:	80 93 66 00 	sts	0x0066, r24
 2a4:	5a c0       	rjmp	.+180    	; 0x35a <door_mainloop+0x150>
					break;	
			}		
			break;
			
		case 3://正锁门态
			switch(temp)
 2a6:	24 30       	cpi	r18, 0x04	; 4
 2a8:	19 f4       	brne	.+6      	; 0x2b0 <door_mainloop+0xa6>
			{
				case 4:	state=0;LOCK_OFF;
 2aa:	10 92 66 00 	sts	0x0066, r1
 2ae:	2e c0       	rjmp	.+92     	; 0x30c <door_mainloop+0x102>
					break;//门锁
				default:if(f_10s==1){state=8;LOCK_OFF;err_f=1;}//门规定时间锁不上
 2b0:	90 91 68 00 	lds	r25, 0x0068
 2b4:	91 30       	cpi	r25, 0x01	; 1
 2b6:	09 f0       	breq	.+2      	; 0x2ba <door_mainloop+0xb0>
 2b8:	53 c0       	rjmp	.+166    	; 0x360 <door_mainloop+0x156>
 2ba:	88 e0       	ldi	r24, 0x08	; 8
 2bc:	80 93 66 00 	sts	0x0066, r24
 2c0:	a8 9a       	sbi	0x15, 0	; 21
 2c2:	90 93 6f 00 	sts	0x006F, r25
					break;
			}		
			break;	
 2c6:	4c c0       	rjmp	.+152    	; 0x360 <door_mainloop+0x156>
		
		case 4://安装等关门
			err_f=1;
 2c8:	81 e0       	ldi	r24, 0x01	; 1
 2ca:	80 93 6f 00 	sts	0x006F, r24
			switch(temp)
 2ce:	25 30       	cpi	r18, 0x05	; 5
 2d0:	09 f0       	breq	.+2      	; 0x2d4 <door_mainloop+0xca>
 2d2:	46 c0       	rjmp	.+140    	; 0x360 <door_mainloop+0x156>
			{
				case 5:state=5;moto_zhen();f_10s=0;cnt_10s=CONST_10S;//进入关门态
 2d4:	85 e0       	ldi	r24, 0x05	; 5
 2d6:	80 93 66 00 	sts	0x0066, r24
 2da:	5c df       	rcall	.-328    	; 0x194 <moto_zhen>
 2dc:	10 92 68 00 	sts	0x0068, r1
 2e0:	82 e3       	ldi	r24, 0x32	; 50
 2e2:	80 93 69 00 	sts	0x0069, r24
					break;	
 2e6:	3c c0       	rjmp	.+120    	; 0x360 <door_mainloop+0x156>
				default:break;	
			}
			break;
			
		case 5://安装的锁门
			err_f=1;
 2e8:	81 e0       	ldi	r24, 0x01	; 1
 2ea:	80 93 6f 00 	sts	0x006F, r24
			switch(temp)
 2ee:	24 30       	cpi	r18, 0x04	; 4
 2f0:	31 f4       	brne	.+12     	; 0x2fe <door_mainloop+0xf4>
			{
				case 4:	state=0;LOCK_OFF;err_f=0;
 2f2:	10 92 66 00 	sts	0x0066, r1
 2f6:	a8 9a       	sbi	0x15, 0	; 21
 2f8:	10 92 6f 00 	sts	0x006F, r1
					break;//门锁
 2fc:	31 c0       	rjmp	.+98     	; 0x360 <door_mainloop+0x156>
				default:if(f_10s==1){state=8;LOCK_OFF;}//门规定时间锁不上
 2fe:	80 91 68 00 	lds	r24, 0x0068
 302:	81 30       	cpi	r24, 0x01	; 1
 304:	69 f5       	brne	.+90     	; 0x360 <door_mainloop+0x156>
 306:	88 e0       	ldi	r24, 0x08	; 8
 308:	80 93 66 00 	sts	0x0066, r24
 30c:	a8 9a       	sbi	0x15, 0	; 21
					break;
			}		
			break;							
 30e:	28 c0       	rjmp	.+80     	; 0x360 <door_mainloop+0x156>
		case 6://门一直锁紧,只有按键能使它退出			
			switch(temp)//锁紧态,只有按钮和密码板脉冲才能开启。
 310:	24 30       	cpi	r18, 0x04	; 4
 312:	71 f4       	brne	.+28     	; 0x330 <door_mainloop+0x126>
			{
				case 4:
					if(f_key){state=1;moto_fan();f_12s=0;cnt_12s=CONST_12S;}//进入开门初始态  
 314:	80 91 6d 00 	lds	r24, 0x006D
 318:	88 23       	and	r24, r24
 31a:	f9 f0       	breq	.+62     	; 0x35a <door_mainloop+0x150>
 31c:	81 e0       	ldi	r24, 0x01	; 1
 31e:	80 93 66 00 	sts	0x0066, r24
 322:	3f df       	rcall	.-386    	; 0x1a2 <moto_fan>
 324:	10 92 6e 00 	sts	0x006E, r1
 328:	8c e3       	ldi	r24, 0x3C	; 60
 32a:	80 93 61 00 	sts	0x0061, r24
 32e:	18 c0       	rjmp	.+48     	; 0x360 <door_mainloop+0x156>
					else{err_f=1;}
					break;
				default:state=8;f_key=0;err_f=1;
 330:	88 e0       	ldi	r24, 0x08	; 8
 332:	80 93 66 00 	sts	0x0066, r24
 336:	10 92 6d 00 	sts	0x006D, r1
 33a:	0f c0       	rjmp	.+30     	; 0x35a <door_mainloop+0x150>
					break;	
			}
			break;	
					
		case 8://异常 只有门全开和门锁紧正常 才能退出异常
			switch(temp)
 33c:	82 2f       	mov	r24, r18
 33e:	99 27       	eor	r25, r25
 340:	83 30       	cpi	r24, 0x03	; 3
 342:	91 05       	cpc	r25, r1
 344:	19 f0       	breq	.+6      	; 0x34c <door_mainloop+0x142>
 346:	04 97       	sbiw	r24, 0x04	; 4
 348:	29 f0       	breq	.+10     	; 0x354 <door_mainloop+0x14a>
 34a:	07 c0       	rjmp	.+14     	; 0x35a <door_mainloop+0x150>
			{
				case 3:	state=2;break;//门开
 34c:	82 e0       	ldi	r24, 0x02	; 2
 34e:	80 93 66 00 	sts	0x0066, r24
 352:	06 c0       	rjmp	.+12     	; 0x360 <door_mainloop+0x156>
				case 4:	state=0;break;//门锁
 354:	10 92 66 00 	sts	0x0066, r1
 358:	03 c0       	rjmp	.+6      	; 0x360 <door_mainloop+0x156>
				default:err_f=1;break;
 35a:	81 e0       	ldi	r24, 0x01	; 1
 35c:	80 93 6f 00 	sts	0x006F, r24
			}		
			break;
		
		default: break;
		
	}		

	//开门解锁后的关门(开门解锁后,没有手动拉开门导致报警,此时又手动合上门,如何处理?)
	//不会出现,因为close开关紧贴门边的
	//关门过程中的开门(在门合上正在锁紧的过程中,里面手动按下开门按钮或外面密码板有信号,如何处理?)
	//关门过程中不响应开门!
	PORTD|=0XF0;PORTD&=state<<4;//状态指示
 360:	82 b3       	in	r24, 0x12	; 18
 362:	80 6f       	ori	r24, 0xF0	; 240
 364:	82 bb       	out	0x12, r24	; 18
 366:	80 91 66 00 	lds	r24, 0x0066
 36a:	99 27       	eor	r25, r25
 36c:	34 e0       	ldi	r19, 0x04	; 4
 36e:	88 0f       	add	r24, r24
 370:	99 1f       	adc	r25, r25
 372:	3a 95       	dec	r19
 374:	e1 f7       	brne	.-8      	; 0x36e <door_mainloop+0x164>
 376:	22 b3       	in	r18, 0x12	; 18
 378:	28 23       	and	r18, r24
 37a:	22 bb       	out	0x12, r18	; 18
	if((blink_b==1)&&(err_f==1)){ERR_ON;}
 37c:	80 91 67 00 	lds	r24, 0x0067
 380:	81 30       	cpi	r24, 0x01	; 1
 382:	29 f4       	brne	.+10     	; 0x38e <door_mainloop+0x184>
 384:	80 91 6f 00 	lds	r24, 0x006F
 388:	81 30       	cpi	r24, 0x01	; 1
 38a:	09 f4       	brne	.+2      	; 0x38e <door_mainloop+0x184>
 38c:	c1 98       	cbi	0x18, 1	; 24
 38e:	08 95       	ret

00000390 <keypd_mainloop>:
}

//************************************
void	keypd_mainloop(void)
{
	uchar	temp;
	static uchar	keystate;
	if((f_20ms==1)&&(f_key==0))
 390:	40 91 65 00 	lds	r20, 0x0065
 394:	41 30       	cpi	r20, 0x01	; 1
 396:	51 f5       	brne	.+84     	; 0x3ec <keypd_mainloop+0x5c>
 398:	30 91 6d 00 	lds	r19, 0x006D
 39c:	33 23       	and	r19, r19
 39e:	31 f5       	brne	.+76     	; 0x3ec <keypd_mainloop+0x5c>
	{
		f_20ms=0;
 3a0:	30 93 65 00 	sts	0x0065, r19
		temp = PINB;
 3a4:	26 b3       	in	r18, 0x16	; 22
		switch(keystate)
 3a6:	80 91 60 00 	lds	r24, 0x0060
 3aa:	99 27       	eor	r25, r25
 3ac:	81 30       	cpi	r24, 0x01	; 1
 3ae:	91 05       	cpc	r25, r1
 3b0:	71 f0       	breq	.+28     	; 0x3ce <keypd_mainloop+0x3e>
 3b2:	82 30       	cpi	r24, 0x02	; 2
 3b4:	91 05       	cpc	r25, r1
 3b6:	1c f4       	brge	.+6      	; 0x3be <keypd_mainloop+0x2e>
 3b8:	89 2b       	or	r24, r25
 3ba:	21 f0       	breq	.+8      	; 0x3c4 <keypd_mainloop+0x34>
 3bc:	08 95       	ret
 3be:	02 97       	sbiw	r24, 0x02	; 2
 3c0:	79 f0       	breq	.+30     	; 0x3e0 <keypd_mainloop+0x50>
 3c2:	08 95       	ret
		{
			case 0:/*有键按下*/
				if((temp&BIT7)==0)	keystate=1;
 3c4:	27 fd       	sbrc	r18, 7
 3c6:	12 c0       	rjmp	.+36     	; 0x3ec <keypd_mainloop+0x5c>
 3c8:	40 93 60 00 	sts	0x0060, r20
				break;
 3cc:	08 95       	ret
			case 1://确认有键
				if((temp&BIT7)==0)	{keystate=2;}
 3ce:	27 fd       	sbrc	r18, 7
 3d0:	04 c0       	rjmp	.+8      	; 0x3da <keypd_mainloop+0x4a>
 3d2:	82 e0       	ldi	r24, 0x02	; 2
 3d4:	80 93 60 00 	sts	0x0060, r24
 3d8:	08 95       	ret
				else {keystate=0;}
 3da:	30 93 60 00 	sts	0x0060, r19
				break;
 3de:	08 95       	ret
			case 2://等待释放
				if((temp&BIT7)!=0) 
 3e0:	27 ff       	sbrs	r18, 7
 3e2:	04 c0       	rjmp	.+8      	; 0x3ec <keypd_mainloop+0x5c>
				{
					keystate=0;
 3e4:	30 93 60 00 	sts	0x0060, r19
					f_key=1;
 3e8:	40 93 6d 00 	sts	0x006D, r20
 3ec:	08 95       	ret

000003ee <main>:
				}
				break; 
		}
	}
}
//************************************
int main(void)
{
 3ee:	cf e5       	ldi	r28, 0x5F	; 95
 3f0:	d4 e0       	ldi	r29, 0x04	; 4
 3f2:	de bf       	out	0x3e, r29	; 62
 3f4:	cd bf       	out	0x3d, r28	; 61
	main_init();
 3f6:	5c de       	rcall	.-840    	; 0xb0 <main_init>
	door_state_init();
 3f8:	db de       	rcall	.-586    	; 0x1b0 <door_state_init>

	sei();
 3fa:	78 94       	sei
	while(1)
	{
		tim0_mainloop();//10ms时间处理
 3fc:	76 de       	rcall	.-788    	; 0xea <tim0_mainloop>
		led_alarm(err_f);//100ms报警闪烁
 3fe:	80 91 6f 00 	lds	r24, 0x006F
 402:	b4 de       	rcall	.-664    	; 0x16c <led_alarm>
		keypd_mainloop();//20ms检测按键和密码脉冲---》fkey=1;
 404:	c5 df       	rcall	.-118    	; 0x390 <keypd_mainloop>
		door_mainloop();//200ms根据行程开关和KEY进行响应处理
 406:	01 df       	rcall	.-510    	; 0x20a <door_mainloop>
 408:	f9 cf       	rjmp	.-14     	; 0x3fc <main+0xe>

⌨️ 快捷键说明

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