📄 单片机数字钟.htm
字号:
<TR>
<TD><A href="http://www.my07d.com/news/69/2006419142816.htm"
target=_blank>单片机数字钟</A></TD></TR>
<TR>
<TD><A href="http://www.my07d.com/news/69/2006419142414.htm"
target=_blank>四位数数字温度计</A></TD></TR>
<TR>
<TD><A href="http://www.my07d.com/news/69/2006414232020.htm"
target=_blank>温度传感器ds1820 的汇</A></TD></TR>
<TR>
<TD><A href="http://www.my07d.com/news/69/2006415185057.htm"
target=_blank>AT89C2051驱动步进电</A></TD></TR>
<TR>
<TD><A href="http://www.my07d.com/news/69/200641914216.htm"
target=_blank>单片机数字电压表</A></TD></TR>
<TR>
<TD><A href="http://www.my07d.com/news/69/2006421152726.htm"
target=_blank>[转帖]用单片机设计频率计2</A></TD></TR>
<TR>
<TD><A href="http://www.my07d.com/news/69/2006415184939.htm"
target=_blank>24c02储存计数器程序</A></TD></TR></TBODY></TABLE></TD></TR></TBODY></TABLE></TD>
<TD vAlign=top scope=col width=628>
<TABLE style="WORD-BREAK: break-all" cellSpacing=0 borderColorDark=#ffffff
cellPadding=5 width="100%" align=center borderColorLight=#000000
border=0><TBODY>
<TR>
<TD width="100%"></TD></TR>
<TR>
<TD width="100%">
<DIV align=center>
<P class=style7><SPAN class=style1 style5>单片机数字钟</SPAN></P>
<HR width="100%" color=#0a778b SIZE=1>
发布时间:2006-4-19 被阅览数:
<SCRIPT src="单片机数字钟.files/counter.htm"></SCRIPT>
次 作者:网上 </DIV></TD></TR>
<TR>
<TD width="100%">
<P class=style5>
<P
style="MARGIN-LEFT: 18pt; TEXT-INDENT: -18pt; mso-list: l2 level1 lfo2; tab-stops: list 18.0pt">1.
实验任务
<P
style="MARGIN-LEFT: 36pt; TEXT-INDENT: -36pt; mso-list: l0 level1 lfo3; tab-stops: list 36.0pt">(1.
开机时,显示12:00:00的时间开始计时;
<P
style="MARGIN-LEFT: 36pt; TEXT-INDENT: -36pt; mso-list: l0 level1 lfo3; tab-stops: list 36.0pt">(2.
P0.0/AD0控制“秒”的调整,每按一次加1秒;
<P
style="MARGIN-LEFT: 36pt; TEXT-INDENT: -36pt; mso-list: l0 level1 lfo3; tab-stops: list 36.0pt">(3.
P0.1/AD1控制“分”的调整,每按一次加1分;
<P
style="MARGIN-LEFT: 36pt; TEXT-INDENT: -36pt; mso-list: l0 level1 lfo3; tab-stops: list 36.0pt">(4.
P0.2/AD2控制“时”的调整,每按一次加1个小时;
<P
style="MARGIN-LEFT: 18pt; TEXT-INDENT: -18pt; mso-list: l2 level1 lfo2; tab-stops: list 18.0pt">2.
电路原理图
<P><IMG height=581 src="单片机数字钟.files/2006419142816305.gif" width=521
v:shapes="_x0000_i1025">
<P style="TEXT-ALIGN: center" align=center>图4.20.1
<P
style="MARGIN-LEFT: 18pt; TEXT-INDENT: -18pt; mso-list: l2 level1 lfo2; tab-stops: list 18.0pt">3.
系统板上硬件连线
<P
style="MARGIN-LEFT: 36pt; TEXT-INDENT: -36pt; mso-list: l5 level1 lfo4; tab-stops: list 36.0pt">(1.
把“单片机系统”区域中的P1.0-P1.7端口用8芯排线连接到“动态数码显示”区域中的A-H端口上;
<P
style="MARGIN-LEFT: 36pt; TEXT-INDENT: -36pt; mso-list: l5 level1 lfo4; tab-stops: list 36.0pt">(2.
把“单片机系统:区域中的P3.0-P3.7端口用8芯排线连接到“动态数码显示”区域中的S1-S8端口上;
<P
style="MARGIN-LEFT: 36pt; TEXT-INDENT: -36pt; mso-list: l5 level1 lfo4; tab-stops: list 36.0pt">(3.
把“单片机系统”区域中的P0.0/AD0、P0.1/AD1、P0.2/AD2端口分别用导线连接到“独立式键盘”区域中的SP3、SP2、SP1端口上;
<P
style="MARGIN-LEFT: 18pt; TEXT-INDENT: -18pt; mso-list: l2 level1 lfo2; tab-stops: list 18.0pt">4.
相关基本知识
<P
style="MARGIN-LEFT: 36pt; TEXT-INDENT: -36pt; mso-list: l1 level1 lfo5; tab-stops: list 36.0pt">(1.
动态数码显示的方法
<P
style="MARGIN-LEFT: 36pt; TEXT-INDENT: -36pt; mso-list: l1 level1 lfo5; tab-stops: list 36.0pt">(2.
独立式按键识别过程
<P
style="MARGIN-LEFT: 36pt; TEXT-INDENT: -36pt; mso-list: l1 level1 lfo5; tab-stops: list 36.0pt">(3.
“时”,“分”,“秒”数据送出显示处理方法
<P
style="MARGIN-LEFT: 18pt; TEXT-INDENT: -18pt; mso-list: l2 level1 lfo2; tab-stops: list 18.0pt">5.
程序框图
<P><IMG height=1523 src="单片机数字钟.files/2006419142817295.gif"
width=314
v:shapes="_x0000_s1026 _x0000_s1027 _x0000_s1028 _x0000_s1029 _x0000_s1030 _x0000_s1031 _x0000_s1032 _x0000_s1033 _x0000_s1034 _x0000_s1035 _x0000_s1036 _x0000_s1037 _x0000_s1038 _x0000_s1039 _x0000_s1040 _x0000_s1041 _x0000_s1042 _x0000_s1043 _x0000_s1044 _x0000_s1045 _x0000_s1046 _x0000_s1047 _x0000_s1048 _x0000_s1049 _x0000_s1050 _x0000_s1051 _x0000_s1052 _x0000_s1053 _x0000_s1054 _x0000_s1055 _x0000_s1056 _x0000_s1057 _x0000_s1058 _x0000_s1059 _x0000_s1060 _x0000_s1061 _x0000_s1062 _x0000_s1063 _x0000_s1064 _x0000_s1065 _x0000_s1066 _x0000_s1067 _x0000_s1068 _x0000_s1069 _x0000_s1070 _x0000_s1071 _x0000_s1072 _x0000_s1073 _x0000_s1074 _x0000_s1075 _x0000_s1076 _x0000_s1077 _x0000_s1078 _x0000_s1079 _x0000_s1080 _x0000_s1081 _x0000_s1082 _x0000_s1083 _x0000_s1084 _x0000_s1085 _x0000_s1086 _x0000_s1087 _x0000_s1088 _x0000_s1089 _x0000_s1090 _x0000_s1091 _x0000_s1092 _x0000_s1093 _x0000_s1094 _x0000_s1095 _x0000_s1096 _x0000_s1097 _x0000_s1098 _x0000_s1099 _x0000_s1100 _x0000_s1101 _x0000_s1102 _x0000_s1103 _x0000_s1104 _x0000_s1105 _x0000_s1106 _x0000_s1107 _x0000_s1108 _x0000_s1109 _x0000_s1110 _x0000_s1111 _x0000_s1112 _x0000_s1113 _x0000_s1114 _x0000_s1115 _x0000_s1116 _x0000_s1117 _x0000_s1118 _x0000_s1119 _x0000_s1120 _x0000_s1121 _x0000_s1122 _x0000_s1123 _x0000_s1124 _x0000_s1125 _x0000_s1126 _x0000_s1127 _x0000_s1128 _x0000_s1129 _x0000_s1130 _x0000_s1131 _x0000_s1132 _x0000_s1133 _x0000_s1134 _x0000_s1135 _x0000_s1136 _x0000_s1137 _x0000_s1138 _x0000_s1139 _x0000_s1140 _x0000_s1141 _x0000_s1142 _x0000_s1143 _x0000_s1144 _x0000_s1145 _x0000_s1146 _x0000_s1147 _x0000_s1148 _x0000_s1149 _x0000_s1150 _x0000_s1151 _x0000_s1152 _x0000_s1153 _x0000_s1154 _x0000_s1155 _x0000_s1156 _x0000_s1157 _x0000_s1158 _x0000_s1159 _x0000_s1160 _x0000_s1161 _x0000_s1162 _x0000_s1163 _x0000_s1164 _x0000_s1165 _x0000_s1166">
<P>6. 汇编源程序<BR>SECOND EQU 30H<BR>MINITE EQU 31H<BR>HOUR EQU
32H<BR>HOURK BIT P0.0<BR>MINITEK BIT P0.1<BR>SECONDK BIT
P0.2<BR>DISPBUF EQU 40H<BR>DISPBIT EQU 48H<BR>T2SCNTA EQU
49H<BR>T2SCNTB EQU 4AH<BR>TEMP EQU 4BH<BR><BR>ORG 00H<BR>LJMP
START<BR>ORG 0BH<BR>LJMP INT_T0<BR>START: MOV SECOND,#00H<BR>MOV
MINITE,#00H<BR>MOV HOUR,#12<BR>MOV DISPBIT,#00H<BR>MOV
T2SCNTA,#00H<BR>MOV T2SCNTB,#00H<BR>MOV TEMP,#0FEH<BR>LCALL
DISP<BR>MOV TMOD,#01H<BR>MOV TH0,#(65536-2000) / 256<BR>MOV
TL0,#(65536-2000) MOD 256<BR>SETB TR0<BR>SETB ET0<BR>SETB EA<BR>WT:
JB SECONDK,NK1<BR>LCALL DELY10MS<BR>JB SECONDK,NK1<BR>INC
SECOND<BR>MOV A,SECOND<BR>CJNE A,#60,NS60<BR>MOV
SECOND,#00H<BR>NS60: LCALL DISP<BR>JNB SECONDK,$<BR>NK1: JB
MINITEK,NK2<BR>LCALL DELY10MS<BR>JB MINITEK,NK2<BR>INC MINITE<BR>MOV
A,MINITE<BR>CJNE A,#60,NM60<BR>MOV MINITE,#00H<BR>NM60: LCALL
DISP<BR>JNB MINITEK,$<BR>NK2: JB HOURK,NK3<BR>LCALL DELY10MS<BR>JB
HOURK,NK3<BR>INC HOUR<BR>MOV A,HOUR<BR>CJNE A,#24,NH24<BR>MOV
HOUR,#00H<BR>NH24: LCALL DISP<BR>JNB HOURK,$<BR>NK3: LJMP
WT<BR>DELY10MS:<BR>MOV R6,#10<BR>D1: MOV R7,#248<BR>DJNZ
R7,$<BR>DJNZ R6,D1<BR>RET<BR>DISP:<BR>MOV A,#DISPBUF<BR>ADD
A,#8<BR>DEC A<BR>MOV R1,A<BR>MOV A,HOUR<BR>MOV B,#10<BR>DIV
AB<BR>MOV @R1,A<BR>DEC R1<BR>MOV A,B<BR>MOV @R1,A<BR>DEC R1<BR>MOV
A,#10<BR>MOV@R1,A<BR>DEC R1<BR>MOV A,MINITE<BR>MOV B,#10<BR>DIV
AB<BR>MOV @R1,A<BR>DEC R1<BR>MOV A,B<BR>MOV @R1,A<BR>DEC R1<BR>MOV
A,#10<BR>MOV@R1,A<BR>DEC R1<BR>MOV A,SECOND<BR>MOV B,#10<BR>DIV
AB<BR>MOV @R1,A<BR>DEC R1<BR>MOV A,B<BR>MOV @R1,A<BR>DEC
R1<BR>RET<BR>INT_T0:<BR>MOV TH0,#(65536-2000) / 256<BR>MOV
TL0,#(65536-2000) MOD 256<BR>MOV A,#DISPBUF<BR>ADD A,DISPBIT<BR>MOV
R0,A<BR>MOV A,@R0<BR>MOV DPTR,#TABLE<BR>MOVC A,@A+DPTR<BR>MOV
P1,A<BR>MOV A,DISPBIT<BR>MOV DPTR,#TAB<BR>MOVC A,@A+DPTR<BR>MOV
P3,A<BR>INC DISPBIT<BR>MOV A,DISPBIT<BR>CJNE A,#08H,KNA<BR>MOV
DISPBIT,#00H<BR>KNA: INC T2SCNTA<BR>MOV A,T2SCNTA<BR>CJNE
A,#100,DONE<BR>MOV T2SCNTA,#00H<BR>INC T2SCNTB<BR>MOV
A,T2SCNTB<BR>CJNE A,#05H,DONE<BR>MOV T2SCNTB,#00H<BR>INC
SECOND<BR>MOV A,SECOND<BR>CJNE A,#60,NEXT<BR>MOV SECOND,#00H<BR>INC
MINITE<BR>MOV A,MINITE<BR>CJNE A,#60,NEXT<BR>MOV MINITE,#00H<BR>INC
HOUR<BR>MOV A,HOUR<BR>CJNE A,#24,NEXT<BR>MOV HOUR,#00H<BR>NEXT:
LCALL DISP<BR>DONE: RETI<BR>TABLE: DB
3FH,06H,5BH,4FH,66H,6DH,7DH,07H,7FH,6FH,40H<BR>TAB: DB
0FEH,0FDH,0FBH,0F7H,0EFH,0DFH,0BFH,07FH<BR>END<BR><BR>7.
C语言源程序<BR>#include <AT89X51.H><BR>unsigned char code
dispcode[]={0x3f,0x06,0x5b,0x4f,<BR>0x66,0x6d,0x7d,0x07,<BR>0x7f,0x6f,0x77,0x7c,<BR>0x39,0x5e,0x79,0x71,0x00};<BR>unsigned
char
dispbitcode[]={0xfe,0xfd,0xfb,0xf7,<BR>0xef,0xdf,0xbf,0x7f};<BR>unsigned
char dispbuf[8]={0,0,16,0,0,16,0,0};<BR>unsigned char
dispbitcnt;<BR><BR>unsigned char second;<BR>unsigned char
minite;<BR>unsigned char hour;<BR>unsigned int tcnt;<BR>unsigned
char mstcnt;<BR><BR>unsigned char i,j;<BR><BR>void
main(void)<BR>{<BR>TMOD=0x02;<BR>TH0=0x06;<BR>TL0=0x06;<BR>TR0=1;<BR>ET0=1;<BR>EA=1;<BR><BR>while(1)<BR>{<BR>if(P0_0==0)<BR>{<BR>for(i=5;i>0;i--)<BR>for(j=248;j>0;j--);<BR>if(P0_0==0)<BR>{<BR>second++;<BR>if(second==60)<BR>{<BR>second=0;<BR>}<BR>dispbuf[0]=second%10;<BR>dispbuf[1]=second/10;<BR>while(P0_0==0);<BR>}<BR>}<BR>if(P0_1==0)<BR>{<BR>for(i=5;i>0;i--)<BR>for(j=248;j>0;j--);<BR>if(P0_1==0)<BR>{<BR>minite++;<BR>if(minite==60)<BR>{<BR>minite=0;<BR>}<BR>dispbuf[3]=minite%10;<BR>dispbuf[4]=minite/10;<BR>while(P0_1==0);<BR>}<BR>}<BR>if(P0_2==0)<BR>{<BR>for(i=5;i>0;i--)<BR>for(j=248;j>0;j--);<BR>if(P0_2==0)<BR>{<BR>hour++;<BR>if(hour==24)<BR>{<BR>hour=0;<BR>}<BR>dispbuf[6]=hour%10;<BR>dispbuf[7]=hour/10;<BR>while(P0_2==0);<BR>}<BR>}<BR>}<BR>}<BR>void
t0(void) interrupt 1 using
0<BR>{<BR>mstcnt++;<BR>if(mstcnt==8)<BR>{<BR>mstcnt=0;<BR>P1=dispcode[dispbuf[dispbitcnt]];<BR>P3=dispbitcode[dispbitcnt];<BR>dispbitcnt++;<BR>if(dispbitcnt==8)<BR>{<BR>dispbitcnt=0;<BR>}<BR>}<BR>tcnt++;<BR>if(tcnt==4000)<BR>{<BR>tcnt=0;<BR>second++;<BR>if(second==60)<BR>{<BR>second=0;<BR>minite++;<BR>if(minite==60)<BR>{<BR>minite=0;<BR>hour++;<BR>if(hour==24)<BR>{<BR>hour=0;<BR>}<BR>}<BR>}<BR>dispbuf[0]=second%10;<BR>dispbuf[1]=second/10;<BR>dispbuf[3]=minite%10;<BR>dispbuf[4]=minite/10;<BR>dispbuf[6]=hour%10;<BR>dispbuf[7]=hour/10;<BR>}<BR>}<BR></P>
<P></P>
<P> </P></TD></TR>
<TR>
<TD class=font1 borderColor=#0 width=628>
<P>
<HR width="100%" color=#0a778b SIZE=1>
<TABLE>
<TBODY>
<TR>
<TD align=middle width=269>上一篇: <A title=两点间温度控制
href="http://www.my07d.com/news/81/2006419142514.htm">两点间温度控制</A>
</TD>
<TD align=middle width=285>下一篇: <A title=单片机模拟开关灯
href="http://www.my07d.com/news/80/200641914371.htm">单片机模拟开关灯</A></TD></TR></TBODY></TABLE>
<HR width="100%" color=#0a778b SIZE=1>
<DIV align=right><A href="javascript:window.print()"><IMG height=14
src="单片机数字钟.files/printer.gif" width=16 align=absMiddle
border=0>打印本页</A> | <A href="javascript:window.close()"><IMG
height=14 src="单片机数字钟.files/close.gif" width=14 align=absMiddle
border=0>关闭窗口</A> </DIV>
<P></P></TD></TR></TBODY></TABLE></TD></TR></TBODY></TABLE>
<TABLE height=62 cellSpacing=0 cellPadding=0 width=800 align=center
background=单片机数字钟.files/webtop_bg.gif border=0>
<TBODY>
<TR>
<TD>
<DIV class=style4 align=center>Copyright @ 2006—2008
http://www.my07d.com 零起点学习网-开发小组版权所有<BR>公司地址:河南.新乡.河南科技学院.
电话:03733715243 邮编:453003<BR>email:lsp73@sohu.com<BR><A
href="http://www.miibeian.gov.cn/" target=_blank><FONT
color=#ff0000>豫ICP备05023058号</FONT></A>
<SCRIPT language=javascript src="单片机数字钟.files/37095.js"
type=text/javascript></SCRIPT>
<NOSCRIPT><A href="http://www.51.la/?37095" target=_blank><IMG
style="BORDER-RIGHT: medium none; BORDER-TOP: medium none; BORDER-LEFT: medium none; BORDER-BOTTOM: medium none"
alt=我要啦免费统计 src="单片机数字钟.files/s.htm"></A></NOSCRIPT>
</DIV></TD></TR></TBODY></TABLE></BODY></HTML>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -