微波EDA网,见证研发工程师的成长!
首页 > 硬件设计 > 嵌入式设计 > 时钟+秒表+流水灯的汇编程序

时钟+秒表+流水灯的汇编程序

时间:09-08 来源:互联网 点击:
//HJSMSY-V1.0单片机开发板测试程序//---------------------------------------------//          电脑钟>>//---------------------------------------------//=======主函数==================================ORG   0000HLJMP   MAINORG    000BHLJMP   T00//	   ORG    001BH//	   LJMP   T11ORG  0030H//=======程序初始化=============================MAIN:MOV  TMOD,#11HMOV   TH0,#3CHMOV   TL0,#0B0HMOV   TH1,#0F0HMOV   TL1,#0B0HSETB   EASETB   ET0//	SETB   ET1SETB   TR0//	SETB   TR1CLR P3.4	 MOV R7,#00H		 ;秒值MOV 30H,#00H		 ;秒个位值MOV 31H,#00H		 ;秒十位值MOV 32H,#00H		 ;分个位MOV 33H,#00H 	         ;分十位MOV 34H,#00H		 ;时个位MOV 35H,#00H		 ;时十位MOV 44H,#00H		 ;秒表毫秒十位MOV 45H,#00H		 ;秒表秒毫秒百位MOV 46H,#00H		 ;秒表秒个位MOV 47H,#00H		 ;秒表秒十位MOV 48H,#00H		 ;秒表分个位MOV 49H,#00H		 ;秒表分十位MOV P2,#0F0H		 ;P2口按键初始化MOV 40H,#01H		 ;数码管休眠值	/流水灯/秒表开关数MOV 41H,#08H		 ;流水灯循环值MOV 42H,#00H         ;秒表暂停//  ACALL T11//----------------------------------------------- MAIN1:  MOV P0,#0FFHMOV P1,#0FFHMOV R0,40HCJNE R0,#01H,ACL1ACALL MAIN2	       ;时钟显示ACL1:CJNE R0,#02H,ACL2ACALL MAIN3	   ;秒表ACL2:CJNE R0,#03H,ACL3ACALL LED		  ;流水灯ACL3:ACALL KEY		       ;按键扫描//	ACALL BAO	       ;定时报警LJMP MAIN1//=======报警子程序============================BAO:MOV R4,33H				  CJNE R4,#03H,YY1CLR P3.2ACALL KEYLJMP YY2YY1:CJNE R4,#05H,YY2SETB P3.2  ACALL KEYYY2:RET//======时钟扫描子程序=======================MAIN2:MOV   A,30H	     MOV  DPTR,#TABMOVC  A,@A+DPTRMOV P0,ACLR P1.0ACALL DELAYMOV  A,31HMOV  DPTR,#TABMOVC  A,@A+	DPTRMOV  P0,ACLR P1.1SETB P1.0ACALL DELAYMOV A,32HMOV DPTR,#TABMOVC A,@A+DPTRMOV P0,ACLR P1.2SETB P1.1ACALL DELAYMOV A,33HMOV DPTR,#TABMOVC A,@A+DPTRMOV P0,ACLR P1.3SETB P1.2ACALL DELAYMOV A,34HMOV DPTR,#TABMOVC A,@A+DPTRMOV P0,ACLR P1.4SETB P1.3ACALL DELAYMOV A,35HMOV DPTR,#TABMOVC A,@A+DPTRMOV P0,ACLR P1.5SETB P1.4ACALL DELAY	MOV P0,#7FH	MOV P1,#0EBHACALL DELAYMOV P1,#0FFHRET//========秒表扫描子程序=========================MAIN3:MOV   A,44H	     MOV  DPTR,#TABMOVC  A,@A+DPTRMOV P0,ACLR P1.0ACALL DELAYMOV  A,45HMOV  DPTR,#TABMOVC  A,@A+	DPTRMOV  P0,ACLR P1.1SETB P1.0ACALL DELAYMOV A,46HMOV DPTR,#TABMOVC A,@A+DPTRMOV P0,ACLR P1.2SETB P1.1ACALL DELAYMOV A,47HMOV DPTR,#TABMOVC A,@A+DPTRMOV P0,ACLR P1.3SETB P1.2ACALL DELAYMOV A,48HMOV DPTR,#TABMOVC A,@A+DPTRMOV P0,ACLR P1.4SETB P1.3ACALL DELAYMOV A,49HMOV DPTR,#TABMOVC A,@A+DPTRMOV P0,ACLR P1.5SETB P1.4ACALL DELAY	MOV P0,#7FH	MOV P1,#0EBHACALL DELAYMOV P1,#0FFHRET//=======定时器T0中断服务========================T00:MOV  TH0,#0D8HMOV   TL0,#0F0HINC   R7CJNE  R7,#64H,AAMOV   R7,#00H//-------时钟跑值--------------------------------TK1:INC  30H			;每秒钟秒个位增一MOV R6,30HCJNE  R6,#0AH,AAMOV   30H,#00HTK2:INC   31HMOV   R6,31HCJNE  R6,#06H,AAMOV   31H,#00H  TK3:INC   32H MOV    R6,32HCJNE   R6,#0AH,AAMOV    32H,#00HTK4:INC    33HMOV    R6,33HCJNE   R6,#06H,AAMOV    33H,#00HTK5:INC    34HMOV    R5,34HMOV    R6,35HCJNE   R5,#04H,TK6CJNE   R6,#02H,TK6MOV    34H,#00HMOV    35H,#00HTK6:CJNE   R5,#0AH,AAMOV    34H,#00HINC    35H//-------秒表跑值----------------------AA:MOV R5,42HCJNE R5,#01H,TK7INC 44HTK7:MOV R5,44HCJNE R5,#0AH,AA1MOV 44H,#00HINC 45HMOV R5,45HCJNE R5,#0AH,AA1MOV 45H,#00HINC 46HMOV R5,46HCJNE	R5,#0AH,AA1MOV 46H,#00HINC 47HMOV R5,47HCJNE R5,#06H,AA1MOV 47H,#00HINC 48HMOV R5,48HCJNE R5,#0AH,AA1MOV 48H,#00HINC 49HMOV R5,49HCJNE R5,#06H,AA1MOV 49H,#00HAA1:RETI//====定时器T1中断服务子程序====================//T11:MOV   TH1,#0F0H//   MOV   TL1,#0B0H//	RETI//******定时时间调整子程序*************************//TBAO:MOV 50H,#00HMOV 51H,#00HMOV 52H,#00HMOV 53H,#00HMOV 54H,#00HMOV 55H,#00HMOV R3,50HDJNZ 30H,RET1RET1: RET//======键盘扫描子程序==========================	  KEY:MOV P2,#0F0HMOV R3,P2CJNE R3,#0F0H,KE0LJMP KK13KE0:CJNE R3,#0E0H,KE1	        ;P2.4行MOV P2,#0EFHJB P2.3,KK1		    //用作调定时时间     ;K13 秒个位增一ACALL DELAY1ACALL TK1KK1:JB P2.2,KK2			;K14   秒十增一ACALL DELAY1ACALL TK2KK2:JB P2.1,KK3			;K15	分个位增一ACALL DELAY1ACALL TK3KK3:JB P2.0,KE1			;K16	分十位增一ACALL DELAY1ACALL TK4KE1:MOV P2,#0DFH	        ;P2.5行JB P2.3,KK4		;K9	 时个位增一ACALL DELAY1ACALL TK5KK4:JB P2.2,KK5			;K10	 时十位增一ACALL DELAY1INC 35H	MOV R3,35HCJNE R3,#03H,HH0MOV 35H,#00HLJMP KK5HH0:CJNE R3,#02H,HH1LJMP   KK5HH1:CJNE R3,#01H,HH2LJMP   KK5HH2:MOV 35H,#00HKK5:JB P2.1,KK6	ACALL DELAY1			;K11	   开/关蜂鸣器CPL P3.2KK6:JB P2.0,KE2  			;K12	  秒表暂停MOV 42H,#00H   KE2:MOV P2,#0BFH			;P.6行JB P2.3,KK7				;K5	时钟暂停/取消暂停ACALL DELAY1CPL ET0	KK7:JB P2.2,KK8				 ;K6  显示/休眠/流水灯ACALL DELAY2INC 40HMOV R3,40HCJNE R3,#04H,KK8MOV 40H,#01HKK8:JB P2.1,KK9	// ACALL DELAY3			;K7 秒表清0    MOV 44H,#00HMOV 45H,#00HMOV 46H,#00HMOV 47H,#00HMOV 48H,#00HMOV 49H,#00HKK9:JB P2.0,KE3		     ;K8	秒表开始跑MOV 42H,#01H   		  KE3:MOV P2,#7FH			  ;P2.7行JB P2.3,KK10		   ;K1		   秒十位减一ACALL DELAY1MOV R3,31HCJNE R3,#00H,JA1LJMP  KK10JA1:DEC 31HKK10:JB P2.2,KK11		  ;K2	   分个位减一ACALL DELAY1MOV R3,32HCJNE R3,#00H,JA2LJMP KK11JA2: DEC 32HKK11:JB P2.1,KK12			;K3	分十位减一ACALL DELAY1MOV R3,33HCJNE R3,#00H,JA3LJMP KK12JA3:DEC 33HKK12:JB P2.0,KK13		   ;K4		时个位减一ACALL DELAY1MOV R3,34HCJNE R3,#00H,JA4LJMP KK13JA4:DEC 34HKK13:RET//=====流水灯子程序===========================LED: MOV A,#0feHMOV 41H,#08HMOV P0,#0FFH	LED1: MOV P1,AMOV R3,#100D0: ACALL DELAYDJNZ R3,D0MOV R3,41HDJNZ R3,AAALJMP BBAAA:RL AMOV 41H,R3 ACALL KEYLJMP LED1BB:	MOV 41H,#07HCC: MOV P1,AMOV R3,#30D1: ACALL DELAYDJNZ R3,D1MOV R3,41HDJNZ R3,DDLJMP LED0DD:RR AMOV 41H,R3ACALL KEYLJMP CCLED0:RET		  //=====延时子程序==============================	DELAY:MOV R1,#250DEL1:NOP NOPNOPNOP DJNZ R1,DEL1RET//====调用时钟显示作延时========================DELAY1:MOV R2,#20		DELA3: ACALL MAIN2DJNZ R2,DELA3  RET//====调用秒表显示作延时========================DELAY3:MOV R2,#20DELA5:ACALL MAIN3DJNZ R2,DELA5RET//====调用延时子程序作延时======================DELAY2:MOV R2,#100	DELA4:ACALL DELAYDJNZ R2,DELA4RET//======共阳数码管段码表=================================	TAB:DB  0C0H,0F9H,0A4H,0B0H,99H,92H,82H,0F8H,80H,90H,87HEND	   

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

网站地图

Top