📄 standardtime.lst
字号:
C51 COMPILER V7.06 STANDARDTIME 11/30/2006 21:37:55 PAGE 1
C51 COMPILER V7.06, COMPILATION OF MODULE STANDARDTIME
OBJECT MODULE PLACED IN StandardTime.OBJ
COMPILER INVOKED BY: C:\Keil\C51\BIN\C51.EXE StandardTime.c BROWSE DEBUG OBJECTEXTEND
stmt level source
1 //QQ群:33495724 单片机 ARM FPGA 团队全力打造技术联盟
2 //实验课题:标准时间
3 //编写人:lc
4 //时间:2006.11.25.
5
6
7 #include<reg51.h>
8 #define uchar unsigned char
9 #define uint unsigned int
10 sfr p0=0x80;//初始化
11 sfr p1=0x90;
12 sfr p2=0xA0;
13
14 unsigned char code tab[10]={0xfc/*0*/,0x60/*1*/,0xda/*2*/,0xf2/*3*/,0x66/*4*/,
15 0xb6/*5*/,0xbe/*6*/,0xe0/*7*/,0xfe/*8*/,0xf6/*9*/};//段码查表
16
17 uint addi=0; //标示相对50mS的20次中断是否到达,到达就是一秒;
18 uchar hour=21;//时间初始化,其为全局变量!
19 uchar minute=38;
20 uchar second=20;
21 uchar templow,temphigh;//取十位,取个位
22 uchar displaylow(uchar middlenum1);//函数声明
23 uchar displayhigh(uchar middlenum2);
24 void delay(uint num);
25 void fun_frabrication();
26
27
28 void t0_show() interrupt 1 using 0//TO中断
29 {
30 1 TH0=(65536-50000)/256;//产生一次中断,重新配置定时器预置值
31 1 TL0=(65536-50000)%256;
32 1 addi++;
33 1 if(addi==20){second+=1;addi=0;}
34 1 }
35
36
37 void displaysecond(uchar p_second)//秒显
38 {
39 1 if(p_second<60||p_second==00)
40 1 {
41 2 p1=0x20;p0=displaylow(p_second);delay(1);p1=0x00;
42 2 p0=displayhigh(p_second);p1=0x10;delay(1);p1=0x00;
43 2 }
44 1 else
45 1 {
46 2 p_second=00;
47 2 second=00;
48 2 p1=0x20;p0=displaylow(p_second);delay(1);p1=0x00;
49 2 p0=displayhigh(p_second);p1=0x10;delay(1);p1=0x00;
50 2 minute+=1;
51 2 }
52 1 }
53
54
55 void displayminute(uchar p_minute)//分显
C51 COMPILER V7.06 STANDARDTIME 11/30/2006 21:37:55 PAGE 2
56 {
57 1 if(p_minute<60||p_minute==00)
58 1 {
59 2 p1=0x08;p0=displaylow(p_minute);delay(1);p1=0x00;
60 2 p0=displayhigh(p_minute);p1=0x04;delay(1);p1=0x00;
61 2 }
62 1 else
63 1 {
64 2 p_minute=00;
65 2 minute=00;
66 2 p1=0x08;p0=displaylow(p_minute);delay(1);p1=0x00;
67 2 p0=displayhigh(p_minute);p1=0x04;delay(1);p1=0x00;
68 2 hour+=1;
69 2 }
70 1 }
71
72
73 void displayhour(uchar p_hour)//时显
74 {
75 1 if(p_hour<24||p_hour==00)
76 1 {
77 2 p1=0x02;p0=displaylow(p_hour);delay(1);p1=0x00;
78 2 p0=displayhigh(p_hour);p1=0x01;delay(1);p1=0x00;
79 2 }
80 1 else
81 1 {
82 2 p_hour=00;
83 2 hour=00;
84 2 p1=0x02;p0=displaylow(p_hour);delay(1);p1=0x00;
85 2 p0=displayhigh(p_hour);p1=0x01;delay(1);p1=0x00;
86 2 }
87 1 }
88
89 uchar displaylow(uchar middlenum1)//显十位通用包
90 {
91 1 templow=tab[middlenum1%10];
92 1 return(templow);
93 1 }
94 uchar displayhigh(uchar middlenum2) //显示个位通用包
95 {
96 1 temphigh=tab[middlenum2/10];
97 1 return(temphigh);
98 1 }
99
100 void delay(uint num)//函数延迟程序包,可以通用;
101 {
102 1 uint i,j;
103 1 for(i=num;i>0;i--)
104 1 for(j=0;j<200;j++);
105 1 }
106 void fun_frabrication()//显示函数封装包,可以用在很多其他的时钟设计当中;
107 {
108 1 displaysecond(second);
109 1 displayminute(minute);
110 1 displayhour(hour);
111 1 }
112
113
114 void main()
115 {
116 1
117 1 TMOD=0X01;
C51 COMPILER V7.06 STANDARDTIME 11/30/2006 21:37:55 PAGE 3
118 1 TH0=(65536-50000)/256;
119 1 TL0=(65536-50000)%256;
120 1 IE=0X82;
121 1 TR0=1;
122 1 while(1)
123 1 {
124 2 fun_frabrication();//将该显示信号放里面就不会刷动了
125 2 }
126 1 }
127
MODULE INFORMATION: STATIC OVERLAYABLE
CODE SIZE = 345 ----
CONSTANT SIZE = 10 ----
XDATA SIZE = ---- ----
PDATA SIZE = ---- ----
DATA SIZE = 7 3
IDATA SIZE = ---- ----
BIT SIZE = ---- ----
END OF MODULE INFORMATION.
C51 COMPILATION COMPLETE. 0 WARNING(S), 0 ERROR(S)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -