?? 12887.lst
字號:
C51 COMPILER V7.06 12887 06/24/2008 23:08:39 PAGE 1
C51 COMPILER V7.06, COMPILATION OF MODULE 12887
OBJECT MODULE PLACED IN 12887.OBJ
COMPILER INVOKED BY: D:\program\Keil\C51\BIN\C51.EXE 12887.c BROWSE DEBUG OBJECTEXTEND
stmt level source
1 /*
2 管腳配置:
3 MOT: 接地
4 CS: 接P27 地址:0x7f00
5
6 AS: 接單片機 ALE
7 R/W: 接 RW
8 DS: 接 RD
9 RESET: 接高
10 IRQ: 空
11 SQW: 空
12 */
13
14 #include <reg51.h>
15
16 #define DS12887 0x7f00 //定義時鐘芯片的片選基址
17
18 #define DS12887_sec DS12887+0x00 // 秒
19 #define DS12887_min DS12887+0x02 // 分
20 #define DS12887_hour DS12887+0x04 // 時
21
22 #define DS12887_day DS12887+0x06 // 星期
23 #define DS12887_date DS12887+0x07 // 日期
24 #define DS12887_month DS12887+0x08 //月份
25 #define DS12887_year DS12887+0x09 //年
26
27 #define DS12887_Reg_A DS12887+0x0a //寄存器A
28 #define DS12887_Reg_B DS12887+0x0b //寄存器B
29 #define DS12887_Reg_C DS12887+0x0c //寄存器C
30 #define DS12887_Reg_D DS12887+0x0d //寄存器D
31
32 sbit P27=P2^7;
33 unsigned char xdata *REG_ADD;
34
35 unsigned char Date_Time[7]={8,6,3,2,19,31,21};//年月日周時分秒 定義時間數組并設定初始值
36
37 void Delay1ms(unsigned int ms);//延時1毫秒(不夠精確的)
38 void Init_Dis();
39 void Lcd_Dis_String(unsigned char addr,unsigned char *p);
40 void Lcd_Dis_Char(unsigned char addr,unsigned char c);
41
42 void Write_Ds12887()
43 {
44 1 P27=0;
45 1 REG_ADD=DS12887_Reg_B;
46 1 *REG_ADD=0x80;
47 1
48 1 REG_ADD=DS12887_year; *REG_ADD=Date_Time[0]; //年
49 1 REG_ADD=DS12887_month; *REG_ADD=Date_Time[1]; //月
50 1 REG_ADD=DS12887_date; *REG_ADD=Date_Time[2]; //日期
51 1 REG_ADD=DS12887_day; *REG_ADD=Date_Time[3]; //星期
52 1 REG_ADD=DS12887_hour; *REG_ADD=Date_Time[4]; //時
53 1 REG_ADD=DS12887_min; *REG_ADD=Date_Time[5]; //分
54 1 REG_ADD=DS12887_sec; *REG_ADD=Date_Time[6]; //秒
55 1 REG_ADD=DS12887_Reg_A; *REG_ADD=0x20;
C51 COMPILER V7.06 12887 06/24/2008 23:08:39 PAGE 2
56 1 REG_ADD=DS12887_Reg_B; *REG_ADD=0x06;
57 1
58 1 }
59
60 void Read_Ds12887()
61 {
62 1 unsigned char temp;
63 1 REG_ADD=DS12887_Reg_A;
64 1 do
65 1 {
66 2 temp=*REG_ADD;
67 2 }while((temp&0x80)==0x80);
68 1
69 1 REG_ADD=DS12887_year; Date_Time[0]=*REG_ADD; //年
70 1 REG_ADD=DS12887_month; Date_Time[1]=*REG_ADD; //月
71 1 REG_ADD=DS12887_date; Date_Time[2]=*REG_ADD; //日期
72 1 REG_ADD=DS12887_day; Date_Time[3]=*REG_ADD; //星期
73 1 REG_ADD=DS12887_hour; Date_Time[4]=*REG_ADD; //時
74 1 REG_ADD=DS12887_min; Date_Time[5]=*REG_ADD; //分
75 1 REG_ADD=DS12887_sec; Date_Time[6]=*REG_ADD; //秒
76 1 }
77
78
79 /********************************************************************/
80 void Display_Calendar(void)
81 {
82 1 //Lcd_Dis_String(0x80," ");
83 1 Lcd_Dis_String(0x80,"20 - - ");
84 1 Lcd_Dis_Char(0x82,(Date_Time[0]/10)|0X30);
85 1 Lcd_Dis_Char(0x83,(Date_Time[0]%10)|0X30);//顯示年,轉換成了ASC碼
86 1 Lcd_Dis_Char(0x85,(Date_Time[1]/10)|0X30);
87 1 Lcd_Dis_Char(0x86,(Date_Time[1]%10)|0X30);//顯示月
88 1 Lcd_Dis_Char(0x88,(Date_Time[2]/10)|0X30);
89 1 Lcd_Dis_Char(0x89,(Date_Time[2]%10)|0X30);//顯示天
90 1 if(Date_Time[3]==1)
91 1 Lcd_Dis_String(0x8d,"Mon");
92 1 if(Date_Time[3]==2)
93 1 Lcd_Dis_String(0x8d,"Tue");
94 1 if(Date_Time[3]==3)
95 1 Lcd_Dis_String(0x8d,"Wen");
96 1 if(Date_Time[3]==4)
97 1 Lcd_Dis_String(0x8d,"Thu");
98 1 if(Date_Time[3]==5)
99 1 Lcd_Dis_String(0x8d,"Fri");
100 1 if(Date_Time[3]==6)
101 1 Lcd_Dis_String(0x8d,"Sat");
102 1 if(Date_Time[3]==7)
103 1 Lcd_Dis_String(0x8d,"Sun");//顯示星期,以上信息均第一行顯示
104 1
105 1 Lcd_Dis_String(0xc0," : :");
106 1 Lcd_Dis_Char(0xc8,(Date_Time[4]/10)|0X30);
107 1 Lcd_Dis_Char(0xc9,(Date_Time[4]%10)|0X30);//時
108 1 Lcd_Dis_Char(0xcb,(Date_Time[5]/10)|0X30);
109 1 Lcd_Dis_Char(0xcc,(Date_Time[5]%10)|0X30);//分
110 1 Lcd_Dis_Char(0xce,(Date_Time[6]/10)|0X30);
111 1 Lcd_Dis_Char(0xcf,(Date_Time[6]%10)|0X30);//秒
112 1 }
113 /*
114 void extern1_IRS(void) interrupt 2//只要把值存入外部變量就可以調用了
115 {
116 if(Right==0)//地址右移(位選擇)
117 {
C51 COMPILER V7.06 12887 06/24/2008 23:08:39 PAGE 3
118 wr_com(++addr);
119 wr_com(0x0f);//光標閃爍
120 delay1ms(500);
121 if(addr==0x90) addr=0xbf;
122 if(addr==0xd0) addr=0x7f;
123 }
124 if(add==0)//數值改變
125 {
126 wr_com(0x0e);//顯示光標但不閃爍
127 wr_com(addr);
128 wr_dat(num++);
129 wr_com(addr);//帶有光標的位的數值改變
130 if(num==0x3a)
131 num=0x30;
132 delay1ms(500);
133
134 }*/
135 void main()
136 {
137 1
138 1 Init_Dis();
139 1 Delay1ms(1000);
140 1 Write_Ds12887();
141 1 while(1)
142 1 {
143 2 Read_Ds12887();
144 2 Display_Calendar();
145 2 }
146 1
147 1 }
148
MODULE INFORMATION: STATIC OVERLAYABLE
CODE SIZE = 611 ----
CONSTANT SIZE = 54 ----
XDATA SIZE = ---- ----
PDATA SIZE = ---- ----
DATA SIZE = 9 ----
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 + -