资源描述:
《单片机—电子钟实验源程序》由会员上传分享,免费在线阅读,更多相关内容在工程资料-天天文库。
1、;22H~24H存时钟时间;32H~34H存闹钟时间;42H~44H存秒表吋I'可;MON用于选择时钟/闹钟调时;30H作为标志;RST用于选择时、分、秒;LAST调时减1,NEXT调时加1;EXEC用于开始秒表计吋;40H作为标志CM1EQU8001HCM2EQU8002HCM4EQU8004HORG0000HUMPMAINORG000BHLJMPSEROORGOO1BHUMPSERIORG0030HMAIN:MOVSP,#70HMOV32H,#OOHMOV33H,#OOHMOV34H,#00H;设置闹钟初始值MOV42H,#00HMOV43H,#
2、00HMOV44H,#00H;设置秒表初始值MOV26H?#11H;26H作为标志(h,min,s)MOV3OH,#OOH;30H作为时钟(0)与闹钟⑴的标志MOVR4,#0C8H;设200次循环MOVTMOD,#20H;T0方式0,T2方式2MOVTH0,#63H;5msMOVTL0,#10HMOVTH1,#9CHMOVTL1Z#9CH;100MSSETBPl.lSETBEASETBETOSETBET1SETBTROMOVA,22H;检查吋钟格式是否正确CLRCSUBBA,#24HJNCINITMOVA,23HCLRCSUBBA,#60HJNCIN
3、ITMOVA,24HCLRCSUBBA,#60HJNCINITUMPLOADINIT:MOV22H,#12H;时钟格式不正确时进行初始化,为12:00:00MOV23H,#00HMOV24H,#00HLOAD:CLRRSOCLRRSI;第一组工作寄存器MOVA,40HJZS1;40H为1时,42H~44H(秒表)送显示缓冲区MOVR0,#42HUMPNOADSI:MOVA,30HJZSOAD;30H为0时,22H~24H(时钟)送显示缓冲区MOVR0,#32H;30H为[时,32H~34H(闹钟)送显示缓冲区UMPNOADSOAD:MOVR0,#22
4、HNOAD:MOVRl,#60H;将对应的时间送入显示缓冲区60H~65HMOVR5Z#O3HL00P1:MOVA,@ROANLA,#OFOHSWAPAMOV@R1,AMOVA,3OHINCRlJZC4MOVA,@ROLCALLNJ;闹钟调用NJANLA,#OFHUMPSENDMOV@R1,AC4:LCALLAJ;时钟调用AJINCRlUMPSENDINCROCl:MOVA,25HDJNZR5,LOOP1CJNEA,#01H,C2LCALLDPILCALLLAST;调用显示子程序;键值为LAST时,调用减1运算MOVA,32HUMPSENDCJNEA
5、,22H,SWEEPC2:MOVA,25HMOVA,33HJNZSENDCJNEA,23H,SWEEPLCALLNEXTSETBTR1;键值为NEXT时,调用加1运算;时钟与闹钟的时和分相等时开定时器1SEND:MOV25H,#99HSWEEP:LCALLSEARCHCLRRSOMOVA,25HCLRRSI;25H存键号UMPLOADCJNEA,#04H,C6•/MOVA,40H•9•判断时钟h/min/s标志位26HADDA,#01H•9MOVB,#02HAJ:SETBRSODIVAB;换工作寄存器MOV40H,BCLRRSI;键值为EXEC时,处
6、理40H标志位MOVA,26HMOV42H,#00HCJNEAZ#11H,AJ1MOV43H,#00HMOVR1,#21HMOV44H,#00HSETBTRO;秒表赋初值UMPARETLJMPSEND;R1存对应时钟位C6:CJNEA,#O2H,C3AJ1:CLRTROMOVA,3OHCJNEA,#22H,AJ2ADDA,#O1HMOVR1,#22HMOVB,#02HAJ2:CJNEA,#44H,AJ3DIVABMOVR1Z#23HMOV3OH,BAJ3:CJNEA,#88H,ARET;键值为MON吋,处理30H标志位MOVR1,#24HUMPSEN
7、DARET:RETC3:CJNEAZ#O3H,C1■/MOVA,26H•9•判断闹钟h/min/s标志位26HRLA•9;键值为RST时,处理26H标志位NJ:SETBRSOMOV26H,ACLRRSI;第1组工作寄存器MOVA,26HCJNEAZ#11H,NJ1MOVR1,#31HUMPARET;R1存对应时钟位NJ1:CJNEA,#22H,NJ2NJ2:MOVR1,#32HCJNEA,#44H,NJ3NJ3:MOVR1,#33HCJNEA,#88H,NJRETNJRET:■MOVR1,#34HRET9■f一减1运算LAST:MOVA,3OHJZL
8、AO;30H为0时,时钟进行减1运算UMPNA0;30H为1时,闹钟进行减1运算LAO:LCALLAJCJN