微波EDA网,见证研发工程师的成长!
首页 > 硬件设计 > 嵌入式设计 > 模拟自动车库源程序

模拟自动车库源程序

时间:08-29 来源:互联网 点击:
//////////////////////////////////////////////////名称:模拟自动车库//电路原理:P86--P87//作者:李春起//版本:CARLIB.ASM-V0.0//编写时间:2010.11.01//修订日志:INTER EQU P3.3//驶入LEAVE EQU P3.2//驶离IN    EQU P1.6//存入OUT   EQU P1.7//取出 ORG 0000HJMP MAIN//  ORG 000BH//  JMP T00ORG 0030HMAIN:MOV TMOD,#01HMOV TH0,#3CHMOV TL0,#0B0HSETB TR0SETB EASETB ET0MOV 20H,#0FFH //车位状态初始化MOV 21H,#0FFH//请求车位LOOP://ACALL DELAY2S//CLR P2.4//初始态平板车位置SETB P2.0SETB P2.1SETB P2.2K1:  JB INTER,K2//不等0转移JNB  INTER,$//等待放开CLR P2.4//指示有车待入库K2:  JB LEAVE,K3JNB LEAVE,$SETB P2.4K3:  JB IN,K4JNB IN,$CLR P2.4CLR P2.1//选择存入SETB P2.0JMP K5K4:  JB OUT,K1JNB OUT,$CLR P2.0SETB P2.1JMP K6K5: SETB P2.2     KA1:JB OUT,KA2JMP K1JB P1.0,KA2JNB P1.0,$JNB P0.0,KA2CLR P2.2MOV 20H,#0FEHJMP KENT KA2:JB P1.1,KA3JNB P1.1,$JNB P0.1,KA3//CLR P2.2MOV 20H,#0FDHJMP KENTKA3:JB P1.2,KA4JNB P1.2,$JNB P0.2,KA4CLR P2.2MOV 20H,#0FBHJMP KENTKA4:JB P1.3,KA5JNB P1.3,$JNB P0.3,KA5CLR P2.2MOV 20H,#0F7HJMP KENTKA5:JB P1.4,KA6JNB P1.4,$JNB P0.4,KA6CLR P2.2MOV 20H,#0EFHJMP KENTKA6:JB P1.5,KENTJNB P1.5,$JNB P0.5,KENTCLR P2.2MOV 20H,#0DFHKENT:JB P3.0,KA1JNB P3.0,$JB P2.2,KA1ACALL DELAY2SSETB P2.4CLR P2.5ACALL DELAY2SMOV A,20HCJNE A,#0FEH,NA1SETB P2.5CLR P0.0ACALL DELAY2SCLR P2.5ACALL DELAY2SSETB P2.5CLR P2.4JMP LOOPNA1: CJNE A,#0F7H,NA2SETB P2.5CLR P0.3ACALL DELAY2SCLR P2.5ACALL DELAY2SSETB P2.5CLR P2.4JMP LOOPNA2: SETB P2.5CLR P2.6ACALL DELAY2SCJNE A,#0FDH,NA3SETB P2.6CLR P0.1ACALL DELAY2SCLR P2.6ACALL DELAY2SSETB P2.6CLR P2.5ACALL DELAY2SSETB P2.5CLR P2.4JMP LOOPNA3: CJNE A,#0EFH,NA4SETB P2.6CLR P0.4ACALL DELAY2SCLR P2.6ACALL DELAY2SSETB P2.6CLR P2.5ACALL DELAY2SSETB P2.5CLR P2.4JMP LOOPNA4: SETB P2.6CLR P2.7ACALL DELAY2S  CJNE A,#0FBH,NA5SETB P2.7CLR P0.2ACALL DELAY2SCLR P2.7ACALL DELAY2SSETB P2.7CLR P2.6ACALL DELAY2SSETB P2.6CLR P2.5ACALL DELAY2SSETB P2.5CLR P2.4JMP LOOPNA5: CJNE A,#0DFH,NA6SETB P2.7CLR P0.5ACALL DELAY2SCLR P2.7ACALL DELAY2SSETB P2.7CLR P2.6ACALL DELAY2SSETB P2.6CLR P2.5ACALL DELAY2SSETB P2.5CLR P2.4NA6: JMP LOOP//============取车===========================K6:  SETB P2.2 KB1:JB IN,KB2JMP K1JB P1.0,KB2JNB P1.0,$JB P0.0,KB2CLR P2.2MOV 20H,#0FEHJMP KENV KB2:JB P1.1,KB3JNB P1.1,$JB P0.1,KB3//CLR P2.2MOV 20H,#0FDHJMP KENVKB3:JB P1.2,KB4JNB P1.2,$JB P0.2,KB4CLR P2.2MOV 20H,#0FBHJMP KENVKB4:JB P1.3,KB5JNB P1.3,$JB P0.3,KB5CLR P2.2MOV 20H,#0F7HJMP KENVKB5:JB P1.4,KB6JNB P1.4,$JB P0.4,KB6CLR P2.2MOV 20H,#0EFHJMP KENVKB6:JB P1.5,KENVJNB P1.5,$JB P0.5,KENVCLR P2.2MOV 20H,#0DFHKENV:JB P3.0,KB1JNB P3.0,$JB P2.2,KB1ACALL DELAY2S SETB P2.4CLR P2.5ACALL DELAY2SMOV A,20HCJNE A,#0FEH,NB1SETB P2.5//  CLR P0.0ACALL DELAY2SSETB P0.0CLR P2.5ACALL DELAY2SSETB P2.5CLR P2.4JMP LOOPNB1: CJNE A,#0F7H,NB2SETB P2.5//  CLR P0.3ACALL DELAY2SSETB P0.3CLR P2.5ACALL DELAY2SSETB P2.5CLR P2.4JMP LOOPNB2: SETB P2.5CLR P2.6ACALL DELAY2SCJNE A,#0FDH,NB3SETB P2.6//  CLR P0.1ACALL DELAY2SSETB P0.1CLR P2.6ACALL DELAY2SSETB P2.6CLR P2.5ACALL DELAY2SSETB P2.5CLR P2.4JMP LOOPNB3: CJNE A,#0EFH,NB4SETB P2.6// CLR P0.4ACALL DELAY2SSETB P0.4CLR P2.6ACALL DELAY2SSETB P2.6CLR P2.5ACALL DELAY2SSETB P2.5CLR P2.4JMP LOOPNB4: SETB P2.6CLR P2.7ACALL DELAY2S  CJNE A,#0FBH,NB5SETB P2.7// CLR P0.2ACALL DELAY2SSETB P0.2CLR P2.7ACALL DELAY2SSETB P2.7CLR P2.6ACALL DELAY2SSETB P2.6CLR P2.5ACALL DELAY2SSETB P2.5CLR P2.4JMP LOOPNB5: CJNE A,#0DFH,NB6SETB P2.7//  CLR P0.5ACALL DELAY2SSETB P0.5CLR P2.7ACALL DELAY2SSETB P2.7CLR P2.6ACALL DELAY2SSETB P2.6CLR P2.5ACALL DELAY2SSETB P2.5CLR P2.4NB6: JMP LOOPDELAY2S:MOV R1,#8DELA1:MOV R2,#255DELA2:MOV R3,#100DELA3:NOPNOPDJNZ R3,DELA3DJNZ R2,DELA2DJNZ R1,DELA1RETEND

Copyright © 2017-2020 微波EDA网 版权所有

网站地图

Top