?? 24c02.lst
字號(hào):
C51 COMPILER V6.23a 24C02 08/23/2005 15:28:25 PAGE 1
C51 COMPILER V6.23a, COMPILATION OF MODULE 24C02
OBJECT MODULE PLACED IN 24c02.OBJ
COMPILER INVOKED BY: C:\Keil\C51\BIN\c51.exe 24c02.c DB OE SMALL ROM(LARGE)
stmt level source
1 #include <reg51.h>
2
3 // 對(duì)24C02的讀、寫
4 // extern void DelayMs(unsigned int);
5 // extern void Read24c02(unsigned char *RamAddress,unsigned char RomAddress,unsigned char bytes);
6 // extern void Write24c02(unsigned char *RamAddress,unsigned char RomAddress,unsigned char bytes);
7
8 /***************************************************************************/
9 #define WriteDeviceAddress 0xa0
10 #define ReadDviceAddress 0xa1
11
12 /***************************************************************************/
13 sbit SCL=P1^0;
14 sbit SDA=P1^1;
15 sbit DOG=P3^7;
16
17 /***************************************************************************/
18 void DelayMs(unsigned int number)
19 {
20 1 unsigned char temp;
21 1 for(;number!=0;number--,DOG=!DOG)
22 1 {
23 2 for(temp=112;temp!=0;temp--);
24 2 }
25 1 }
26
27 /***************************************************************************/
28 void Start()
29 {
30 1 SDA=1;
31 1 SCL=1;
32 1 SDA=0;
33 1 SCL=0;
34 1 }
35
36 /***************************************************************************/
37 void Stop()
38 {
39 1 SCL=0;
40 1 SDA=0;
41 1 SCL=1;
42 1 SDA=1;
43 1 }
44
45 /***************************************************************************/
46 void Ack()
47 {
48 1 SDA=0;
49 1 SCL=1;
50 1 SCL=0;
51 1 SDA=1;
52 1 }
53
54 /***************************************************************************/
55 void NoAck()
C51 COMPILER V6.23a 24C02 08/23/2005 15:28:25 PAGE 2
56 {
57 1 SDA=1;
58 1 SCL=1;
59 1 SCL=0;
60 1 }
61
62 /***************************************************************************/
63 bit TestAck()
64 {
65 1 bit ErrorBit;
66 1 SDA=1;
67 1 SCL=1;
68 1 ErrorBit=SDA;
69 1 SCL=0;
70 1 return(ErrorBit);
71 1 }
72
73 /***************************************************************************/
74 bit Write8Bit(unsigned char input)
75 {
76 1 unsigned char temp;
77 1 for(temp=8;temp!=0;temp--)
78 1 {
79 2 SDA=(bit)(input&0x80);
80 2 SCL=1;
81 2 SCL=0;
82 2 input=input<<1;
83 2 }
84 1 }
*** WARNING C173 IN LINE 84 OF 24C02.C: missing return-expression
85
86 /***************************************************************************/
87 void Write24c02(unsigned char *Wdata,unsigned char RomAddress,unsigned char number)
88 {
89 1 Start();
90 1 Write8Bit(WriteDeviceAddress);
91 1 TestAck();
92 1 Write8Bit(RomAddress);
93 1 TestAck();
94 1 for(;number!=0;number--)
95 1 {
96 2 Write8Bit(*Wdata);
97 2 TestAck();
98 2 Wdata++;
99 2 }
100 1 Stop();
101 1 DelayMs(10);
102 1 }
103
104 /***************************************************************************/
105 unsigned char Read8Bit()
106 {
107 1 unsigned char temp,rbyte=0;
108 1 for(temp=8;temp!=0;temp--)
109 1 {
110 2 SCL=1;
111 2 rbyte=rbyte<<1;
112 2 rbyte=rbyte|((unsigned char)(SDA));
113 2 SCL=0;
114 2 }
115 1 return(rbyte);
116 1 }
C51 COMPILER V6.23a 24C02 08/23/2005 15:28:25 PAGE 3
117
118 /***************************************************************************/
119 void Read24c02(unsigned char *RamAddress,unsigned char RomAddress,unsigned char bytes)
120 {
121 1 unsigned char temp,rbyte;
122 1 Start();
123 1 Write8Bit(WriteDeviceAddress);
124 1 TestAck();
125 1 Write8Bit(RomAddress);
126 1 TestAck();
127 1 Start();
128 1 Write8Bit(ReadDviceAddress);
129 1 TestAck();
130 1 while(bytes!=1)
131 1 {
132 2 *RamAddress=Read8Bit();
133 2 Ack();
134 2 RamAddress++;
135 2 bytes--;
136 2 }
137 1 *RamAddress=Read8Bit();
138 1 NoAck();
139 1 Stop();
140 1 }
*** WARNING C280 IN LINE 121 OF 24C02.C: 'temp': unreferenced local variable
*** WARNING C280 IN LINE 121 OF 24C02.C: 'rbyte': unreferenced local variable
141 /**************************************/
142 void main()
143 {
144 1 unsigned char a[8]="01234567",b[8];
145 1 Write24c02(a,0,8);
146 1 Read24c02(b,0,8);
147 1 while(1);
148 1 }
149 /***************************************************************************/
150
151
MODULE INFORMATION: STATIC OVERLAYABLE
CODE SIZE = 266 ----
CONSTANT SIZE = 8 ----
XDATA SIZE = ---- ----
PDATA SIZE = ---- ----
DATA SIZE = ---- 28
IDATA SIZE = ---- ----
BIT SIZE = ---- 1
END OF MODULE INFORMATION.
C51 COMPILATION COMPLETE. 3 WARNING(S), 0 ERROR(S)
?? 快捷鍵說(shuō)明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -