📄 t.lst
字号:
=2 sbit CP_RL2 = T2CON^0;
=2
=2 #endif
2 =1 #include<absacc.h>
1 =2 /*--------------------------------------------------------------------------
2 =2 ABSACC.H
3 =2
4 =2 Direct access to 8051, extended 8051 and Philips 80C51MX memory areas.
5 =2 Copyright (c) 1988-2002 Keil Elektronik GmbH and Keil Software, Inc.
6 =2 All rights reserved.
7 =2 --------------------------------------------------------------------------*/
8 =2
9 =2 #ifndef __ABSACC_H__
=2 #define __ABSACC_H__
=2
=2 #define CBYTE ((unsigned char volatile code *) 0)
=2 #define DBYTE ((unsigned char volatile data *) 0)
=2 #define PBYTE ((unsigned char volatile pdata *) 0)
=2 #define XBYTE ((unsigned char volatile xdata *) 0)
=2
=2 #define CWORD ((unsigned int volatile code *) 0)
=2 #define DWORD ((unsigned int volatile data *) 0)
=2 #define PWORD ((unsigned int volatile pdata *) 0)
=2 #define XWORD ((unsigned int volatile xdata *) 0)
=2
=2
=2 #ifdef __CX51__
=2 #define FVAR(object, addr) (*((object volatile far *) (addr)))
=2 #define FARRAY(object, base) ((object volatile far *) (base))
=2 #define FCVAR(object, addr) (*((object const far *) (addr)))
=2 #define FCARRAY(object, base) ((object const far *) (base))
=2 #else
=2 #define FVAR(object, addr) (*((object volatile far *) ((addr)+0x10000L)))
=2 #define FCVAR(object, addr) (*((object const far *) ((addr)+0x810000L)))
=2 #define FARRAY(object, base) ((object volatile far *) ((base)+0x10000L))
=2 #define FCARRAY(object, base) ((object const far *) ((base)+0x810000L))
=2 #endif
=2
=2 #endif
3 =1 sbit DQ = P1^0;
4 =1 void delay(int us);//
5 =1 bit reset18b20(void);
6 =1 bit readbit18b20(void);
7 =1 unsigned char readbyte18b20(void);
8 =1 void writebit18b20(bit databit);
9 =1 void writebyte18b20(unsigned char databyte);
6 #define LCD_CLS 0x01
C51 COMPILER V7.50 T 03/30/2009 21:38:00 PAGE 7
7 #define LCD_HOME 0x02
8 #define LCD_SETMODE 0x04
9 #define LCD_SETVISIBLE 0x08
10 #define LCD_SHIFT 0x10
11 #define LCD_SETFUNCTION 0x38
12 #define LCD_SETCGADDR 0x40
13 #define LCD_SETDDADDR 0x80
14
15 #define COMWR XBYTE [0x0000]
16 #define DATWR XBYTE [0x0001]
17 #define BUSYRD XBYTE [0x0002]
18 #define DATRD XBYTE [0x0003]
19 #define MAX_DISPLAY_CHAR 0x16
20
21 char text[] = {'I','o','L','O','V','E','u','Y','O','U',' ','I',' ','L','O','V','E',' ','Y','O','U','\n'};
-
22 char pacmanopen[] = {0x0E,0x07,0x03,0x01,0x03,0x07,0x0E,0x00,'\n'};
23 char pacmanshut[] = {0x00,0x0F,0x1F,0x01,0x1F,0x0F,0x00,0x00,'\n'};
24 uchar idata clock_curent[6]={1,2,3,4,0,1};//装载当前时间和设定时间
25 uchar idata half=0,updata=1,temph,templ,t,temp[6];
26 void wrcgchr(char *arrayptr, int offset);
27 void wrcmd (char cmdcode);
28 void lcd_init ();
29 void pause(int num);
30 void clearscreen ();
31 void eat ();
32 void wrdata (char ddata);
33 void lcd_wait ();
34 void disp(char pos,char tdata);
35 void dispcurrenttime(void);//显示时间
36
37
38 void main(void)
39 {
40 1 unsigned int tmp;
41 1 char *textptr = text,i;
42 1 bit flag=0;
43 1 IE=0x00;/*关中断*/
44 1 IT0=1; /*选择负跳变触发*/
45 1 TMOD=0X01;/*计数模式*/
46 1 IP=0X02; /*优先级*/
47 1 TL0=0XAF;//初值0.05秒
48 1 TH0=0X3C;
49 1 SP=0X60;
50 1 IE=0x80;/*开中断*/
51 1 TR0=1;
52 1
53 1 lcd_init(); // Initialise the LCD Display
54 1
55 1 while(1)
56 1 {
57 2 IE=0x80;
58 2 do
59 2 flag=reset18b20();
60 2 while(flag==1);
61 2
62 2 writebyte18b20(0xcc);
63 2 writebyte18b20(0x44);
64 2 delay(50);
65 2 do
66 2 flag=reset18b20();
67 2 while(flag==1);
C51 COMPILER V7.50 T 03/30/2009 21:38:00 PAGE 8
68 2
69 2 writebyte18b20(0xcc);
70 2 writebyte18b20(0xbe);
71 2 templ=readbyte18b20();
72 2 temph=readbyte18b20();
73 2 for(i=0;i<6;i++)
74 2 t=readbyte18b20();
75 2
76 2
77 2 /* if(temph/16>9)
78 2 temp[0]=(temph/16)-10+'A';
79 2 else
80 2 temp[0]=(temph/16)+'0';
81 2
82 2 if(temph%16>9)
83 2 temp[1]=(temph%16)-10+'A';
84 2 else
85 2 temp[1]=(temph%16)+'0';
86 2
87 2 if(templ/16>9)
88 2 temp[2]=(templ/16)-10+'A';
89 2 else
90 2 temp[2]=(templ/16)+'0';
91 2
92 2 if(templ%16>9)
93 2 temp[3]=(templ%16)-10+'A';
94 2 else
95 2 temp[3]=(templ%16)+'0';
96 2
97 2 for(i=8;i<12;i++)
98 2 disp(i,temp[i-8]);
99 2 *///
100 2 tmp=temph*256+templ;
101 2
102 2 temp[4]='.';
103 2 if(temph>=0xf8)
104 2 {
105 3 temp[0]='-';
106 3 //templ=~templ;
107 3 //templ++;
108 3 tmp=~tmp;
109 3 tmp++;
110 3 }
111 2 else
112 2 temp[0]='+';
113 2 if(templ&0x08)
114 2 temp[5]='5';
115 2 else
116 2 temp[5]='0';
117 2
118 2 //templ/=2;
119 2 tmp>>=4;
120 2 for(i=3;i>0;i--)
121 2 {
122 3 temp[i]=(tmp%10)+'0';
123 3 tmp=tmp/10;
124 3 // temp[i]=(templ%10)+'0';
125 3 // templ=templ/10;
126 3 }
127 2
128 2 for(i=0;i<6;i++)
129 2 disp(10+i,temp[i]);
C51 COMPILER V7.50 T 03/30/2009 21:38:00 PAGE 9
130 2
131 2 //}
132 2 IE=0X82;
133 2 // while(1)
134 2 // {
135 2 if(updata==1)
136 2 {
137 3 add_second(clock_curent);
138 3 updata=0;
139 3 dispcurrenttime();
140 3 }
141 2 }
142 1
143 1
144 1
145 1 for (;;) // Loop Forever.
146 1 { textptr = text;
147 2 while (*textptr!= '\n') // Write the String.
148 2 {
149 3 wrdata(*textptr++);
150 3 pause(2000);
151 3 }
152 2 pause(5000);
153 2 eat(); // Show and Animate the pacman.
154 2 pause(5000);
155 2 }
156 1 }
157
158 void dispcurrenttime(void)//显示时间
159 {
160 1 if(clock_curent[5]==0)
161 1 disp(0,11+'0'); //首位0消隐
162 1 else
163 1 disp(0,clock_curent[5]+'0');//小时
164 1 disp(1,clock_curent[4]+'0');
165 1 disp(2,10+'0');
166 1 disp(3,clock_curent[3]+'0');//分钟
167 1 disp(4,clock_curent[2]+'0');
168 1 disp(5,10+'0');
169 1 disp(6,clock_curent[1]+'0');//秒钟
170 1 disp(7,clock_curent[0]+'0');
171 1 }
172
173 void disp(char pos,char tdata)
174 {
175 1 wrcmd(LCD_SETDDADDR+pos);
176 1 wrdata(tdata);
177 1
178 1 }
179
180 void service_second(void) interrupt 1 /*外部中断置标志*/
181 {
182 1 TR0=0;
183 1 TL0=0XAF;
184 1 TH0=0X3C;
185 1 TR0=1;
186 1 half++;
187 1 if(half==2)
188 1 {
189 2 updata=1;
190 2 half=0;
191 2 }
C51 COMPILER V7.50 T 03/30/2009 21:38:00 PAGE 10
192 1 }
193
194 void eat ()
195 {
196 1 int count = MAX_DISPLAY_CHAR-1, eatflag = 0 , tmp;
197 1 while (count >= 0)
198 1 {
199 2 wrcmd(LCD_SETDDADDR + count); // Work from right to left.
200 2 eatflag ? wrdata(0x00): wrdata(0x01); // Toggle the custom graphics between mouth open
- and mouth shut.
201 2 eatflag ^= 1;
202 2 for (tmp = count; tmp <=MAX_DISPLAY_CHAR; ++tmp) // Anything to the right of pacman is wiped.
203 2 wrdata(' ');
204 2 count--; // Decrement the count (moving us 1 to the left)
-.
205 2 pause(4000);
206 2 }
207 1 clearscreen(); // Clear the final pacman graphic when we are do
-ne.
208 1 }
209
210 void pause(int num)
211 {
212 1 while(num--)
213 1 ;
214 1 }
215
216 void lcd_init (void)
217 {
218 1 wrcmd(LCD_SETFUNCTION); // 8-bit mode - 1 line - 5x7 font.
219 1 wrcmd(LCD_SETVISIBLE+0x04); // Display no cursor - no blink.
220 1 wrcmd(LCD_SETMODE+0x02); // Automatic Increment - No Display shift. // Wri
-te Custom Character to CG RAM.
221 1 wrcgchr(pacmanopen, 0); // Offset 0 - 40h-47h in CGRAM.
222 1 wrcgchr(pacmanshut, 8); // Offset 8 - 48h-4Fh in CGRAM.
223 1 wrcmd(LCD_SETDDADDR); // Address DDRAM with 0 offset 80h.
224 1 }
225
226 void clearscreen ()
227 {
228 1 wrcmd(LCD_CLS);
229 1 wrcmd(LCD_SETDDADDR);
230 1 }
231
232 void wrcmd (char cmdcode)
233 {
234 1 lcd_wait();
235 1 COMWR=cmdcode;
236 1
237 1 }
238
239 void wrdata (char ddata)
240 {
241 1 lcd_wait();
242 1 DATWR=ddata;
243 1 // Call the wait routine.
244 1 }
245
246 void wrcgchr(char *arrayptr, int offset)
247 {
248 1 wrcmd(LCD_SETCGADDR + offset);
249 1 while (*arrayptr != '\n')
C51 COMPILER V7.50 T 03/30/2009 21:38:00 PAGE 11
250 1 wrdata (*arrayptr++);
251 1 }
252
253 void lcd_wait ()
254 { char status;
255 1 do
256 1 { P0=0xff;
257 2 status=P0;
258 2 }
259 1 while (status & 0x80);
260 1 }
261
262
263
264
265
266
MODULE INFORMATION: STATIC OVERLAYABLE
CODE SIZE = 685 ----
CONSTANT SIZE = ---- ----
XDATA SIZE = ---- ----
PDATA SIZE = ---- ----
DATA SIZE = 40 16
IDATA SIZE = 17 ----
BIT SIZE = ---- 1
END OF MODULE INFORMATION.
C51 COMPILATION COMPLETE. 0 WARNING(S), 0 ERROR(S)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -