?? 1602.lst
字號:
C51 COMPILER V7.07 1602 03/16/2009 11:13:25 PAGE 1
C51 COMPILER V7.07, COMPILATION OF MODULE 1602
OBJECT MODULE PLACED IN 1602.OBJ
COMPILER INVOKED BY: C:\Keil\C51\BIN\C51.EXE 1602.c BROWSE DEBUG OBJECTEXTEND
stmt level source
1 #include <at89x51.h>
2 #include <intrins.h>
3 sbit LcdRs = P2^0;
4 sbit LcdRw = P2^1;
5 sbit LcdEn = P2^2;
6 #define DBPort P0
7 /***************************************************************************/
8 #define WriteDeviceAddress 0xa0
9 #define ReadDviceAddress 0xa1
10 sbit SCL=P2^4;
11 sbit SDA=P2^5;
12 unsigned char code tab[10]={'0','1','2','3','4','5','6','7','8','9'}; //1602液晶顯示代碼表
13 unsigned char number=2 ;
14 unsigned char num[3]={' ','2','\0'} ;
15 unsigned char second,minite,hour,day ;
16 unsigned char buffer[13]={' ','0',' ',' ','0','0',':','0','0',':','0','0','\0'} ;
17 unsigned char shi,qian,shiwan ;
18 unsigned char buf[7]={' ',' ',' ',' ',' ','0','\0'} ;
19 unsigned char line=0;
20 unsigned char buff[2]={'L',' '};
21 unsigned char bufss[16]={0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};
22 unsigned char bufs[8];
23 unsigned adder[9]={0x0,0x08,0x10,0x18,0x20,0x28,0x30,0x38,0x40};
24 bit flag1=0;
25 bit flag2=0;
26 unsigned char q=0;
27 bit f0=1,f1=1,f2=1,f3=1,f4=1,f5=1,f6=1,f7=1;
28 //內部等待函數**************************************************************************
29 unsigned char LCD_Wait(void)
30 {
31 1 LcdRs=0;
32 1 LcdRw=1;
33 1 _nop_();
34 1 LcdEn=1;
35 1 _nop_();
36 1 LcdEn=0;
37 1 return DBPort;
38 1 }
39 //向LCD寫入命令或數據************************************************************
40 #define LCD_COMMAND 0 // Command
41 #define LCD_DATA 1 // Data
42 void LCD_Write(bit style, unsigned char input)
43 {
44 1 LcdEn=0;
45 1 LcdRs=style;
46 1 LcdRw=0; _nop_();
47 1 DBPort=input; _nop_();//注意順序
48 1 LcdEn=1; _nop_();//注意順序
49 1 LcdEn=0; _nop_();
50 1 LCD_Wait();
51 1 }
52 void LCD_Initial() //初始化LCD************************
53 {
54 1 LcdEn=0;
55 1 LCD_Write(LCD_COMMAND,0x38); //8位數據端口,2行顯示,5*7點陣
C51 COMPILER V7.07 1602 03/16/2009 11:13:25 PAGE 2
56 1 LCD_Write(LCD_COMMAND,0x38);
57 1 LCD_Write(LCD_COMMAND,0x0c); //開啟顯示, 無光標
58 1 LCD_Write(LCD_COMMAND,0x01); //清屏
59 1 LCD_Write(LCD_COMMAND,0x06); //AC遞增, 畫面不動
60 1 }
61 void GotoXY(unsigned char x, unsigned char y)
62 {
63 1 if(y==0)
64 1 LCD_Write(LCD_COMMAND,0x80|x);
65 1 if(y==1)
66 1 LCD_Write(LCD_COMMAND,0x80|(x-0x40));
67 1 }
68 void Print(unsigned char *str)
69 {
70 1 while(*str!='\0')
71 1 {
72 2 LCD_Write(LCD_DATA,*str);
73 2 str++;
74 2 }
75 1 }
76
77 ///////////////////////////////////////////////////////////////////////////
78
79 void delay(unsigned char i)//12MHZ 延時1ms
80 {
81 1 unsigned char j;
82 1 for(i;i;i--)
83 1
84 1 for(j=112;j;j--);
85 1 }
86 /***************************************************************************/
87 void Start()
88 {
89 1
90 1 SDA=1;
91 1 _nop_();
92 1 SCL=1;
93 1 _nop_();
94 1 _nop_();
95 1 _nop_();
96 1 _nop_();
97 1 _nop_();
98 1 SDA=0;
99 1 _nop_();
100 1 _nop_();
101 1 _nop_();
102 1 _nop_();
103 1 SCL=0;
104 1 _nop_();
105 1 }
106
107 /***************************************************************************/
108 void Stop()
109 {
110 1
111 1 SDA=0;
112 1 _nop_();
113 1 _nop_();
114 1 SCL=1;
115 1 _nop_();
116 1 _nop_();
117 1 _nop_();
C51 COMPILER V7.07 1602 03/16/2009 11:13:25 PAGE 3
118 1 _nop_();
119 1 _nop_();
120 1 SDA=1;
121 1 _nop_();
122 1 _nop_();
123 1 _nop_();
124 1 _nop_();
125 1 _nop_();
126 1 }
127
128 /***************************************************************************/
129 void Ack()
130 {
131 1 SDA=0;
132 1 _nop_();
133 1 _nop_();
134 1 SCL=1;
135 1 _nop_();
136 1 _nop_();
137 1 _nop_();
138 1 _nop_();
139 1 _nop_();
140 1 SCL=0;
141 1 _nop_();
142 1 _nop_();
143 1
144 1 }
145
146 /***************************************************************************/
147 void NoAck()
148 {
149 1 SDA=1;
150 1 _nop_();
151 1 _nop_();
152 1 SCL=1;
153 1 _nop_();
154 1 _nop_();
155 1 _nop_();
156 1 _nop_();
157 1 _nop_();
158 1 SCL=0;
159 1 _nop_();
160 1 _nop_();
161 1 }
162
163 /***************************************************************************/
164 bit TestAck()
165 {
166 1 bit ErrorBit;
167 1 SDA=1;
168 1 _nop_();
169 1 _nop_();
170 1 SCL=1;
171 1 _nop_();
172 1 _nop_();
173 1 ErrorBit=SDA;
174 1 SCL=0;
175 1 _nop_();
176 1 return(ErrorBit);
177 1 }
178
179 /***************************************************************************/
C51 COMPILER V7.07 1602 03/16/2009 11:13:25 PAGE 4
180 Write8Bit(unsigned char input)
181 {
182 1 unsigned char temp;
183 1 for(temp=8;temp!=0;temp--)
184 1 {
185 2 SDA=(bit)(input&0x80);
186 2 _nop_();
187 2 SCL=1;
188 2 _nop_();
189 2 _nop_();
190 2 _nop_();
191 2 _nop_();
192 2 _nop_();
193 2 SCL=0;
194 2 input=input<<1;
195 2 }
196 1 }
197
198 /***************************************************************************/
199 void Write24c02(unsigned char *Wdata,unsigned char RomAddress,unsigned char number)
200 {
201 1 Start();
202 1 Write8Bit(WriteDeviceAddress);
203 1 TestAck();
204 1 Write8Bit(RomAddress);
205 1 TestAck();
206 1 for(;number;number--)
207 1 {
208 2 Write8Bit(*Wdata);
209 2 TestAck();
210 2 Wdata++;
211 2 }
212 1 Stop();
213 1 delay(10);
214 1 }
215
216 /***************************************************************************/
217 unsigned char Read8Bit()
218 {
219 1 unsigned char temp,rbyte=0;
220 1 for(temp=8;temp;temp--)
221 1 {
222 2 SDA=1;
223 2 _nop_();
224 2 SCL=1;
225 2 _nop_();
226 2 _nop_();
227 2 rbyte=rbyte<<1;
228 2 if(SDA)rbyte=rbyte|0x01;
229 2 SCL=0;
230 2 _nop_();
231 2 _nop_();
232 2 _nop_();
233 2 _nop_();
234 2 _nop_();
235 2 }
236 1 return(rbyte);
237 1 }
238
239 /***************************************************************************/
240 void Read24c02(unsigned char *RamAddress,unsigned char RomAddress,unsigned char bytes) {
241 1 Start();
C51 COMPILER V7.07 1602 03/16/2009 11:13:25 PAGE 5
242 1 Write8Bit(WriteDeviceAddress);
243 1 TestAck();
244 1 Write8Bit(RomAddress);
245 1 TestAck();
246 1 Start();
247 1 Write8Bit(ReadDviceAddress);
248 1 TestAck();
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -