iic20080107.lst
字号:
C51 COMPILER V8.05a IIC20080107 01/08/2008 18:22:40 PAGE 1
C51 COMPILER V8.05a, COMPILATION OF MODULE IIC20080107
OBJECT MODULE PLACED IN IIC20080107.OBJ
COMPILER INVOKED BY: C:\Keilc51\C51\BIN\C51.EXE IIC20080107.c BROWSE DEBUG OBJECTEXTEND
line level source
1 /************************************************/
2 #include <REG52.H>
3 #define uchar unsigned char
4 #define uint unsigned int
5 #define ulong unsigned long
6 sbit I2C_SDA= P1^5;
7 sbit I2C_SCK= P1^4;
8 sbit I2C_WP= P1^3;
9 sbit GRE=P1^7;
10 sbit RED=P1^6;
11
12 //===============================================
13
14 //=============================
15 //延时10US
16 //内部调用函数
17 void Delay_10_uS(void)
18 {
19 1 char i=10;
20 1 while(i--);
21 1 }
22
23 //延时n_milisecond MS
24 //供内部调用函数
25 void delay_n_ms( uint n_milisecond) /* n mS delay */
26 {
27 1 uchar i;
28 1 while(n_milisecond--)
29 1 {
30 2 i=37;
31 2 while(i--);
32 2 }
33 1 }
34
35 //开始位
36 //内部调用函数
37 bit I2C_Start(void)
38 {
39 1 Delay_10_uS();
40 1 I2C_SDA =1;
41 1 Delay_10_uS();
42 1 I2C_SCK =1;
43 1 Delay_10_uS();
44 1 if ( I2C_SDA == 0) return 0;
45 1 if ( I2C_SCK == 0) return 0;
46 1 I2C_SDA = 0;
47 1 Delay_10_uS();
48 1 I2C_SCK = 0;
49 1 Delay_10_uS();
50 1 return 1;
51 1 }
52
53 //停止位
54 //内部调用函数
55 void I2C_Stop(void)
C51 COMPILER V8.05a IIC20080107 01/08/2008 18:22:40 PAGE 2
56 {
57 1 Delay_10_uS();
58 1 I2C_SDA = 0;
59 1 Delay_10_uS();
60 1 I2C_SCK = 1;
61 1 Delay_10_uS();
62 1 I2C_SDA = 1;
63 1 Delay_10_uS();
64 1 }
65
66
67 //写单字节数据
68 //内部调用函数
69 bit I2C_Send_Byte( uchar d)
70 {
71 1 uchar i = 8;
72 1 bit bit_ack;
73 1 while( i-- )
74 1 {
75 2 Delay_10_uS();
76 2 if ( d &0x80 ) I2C_SDA =1;
77 2 else I2C_SDA =0;
78 2 Delay_10_uS();
79 2 I2C_SCK = 1;
80 2 Delay_10_uS();
81 2 I2C_SCK = 0;
82 2 d = d << 1;
83 2 }
84 1 Delay_10_uS();
85 1 I2C_SDA = 1;
86 1 Delay_10_uS();
87 1 I2C_SCK = 1;
88 1 Delay_10_uS();
89 1 bit_ack = I2C_SDA;
90 1 I2C_SCK =0;
91 1 Delay_10_uS();
92 1 return bit_ack;
93 1 }
94
95
96
97 //写多字节数据
98 //供外部调用函数
99 void AT24C64_W(void *mcu_address,uint AT24C64_address,uint count)
100 {
101 1
102 1 while(count--)
103 1 {
104 2 I2C_Start();
105 2 /*I2C_Send_Byte( 0xa0 + AT24C64_address /256 *2);*/ /* 24C16 USE */
106 2 I2C_Send_Byte( 0xa0 );//写命令设备地址为10100000最后一位为0"写标志"
107 2 I2C_Send_Byte( AT24C64_address/256 );//写存储器页地址
108 2 I2C_Send_Byte( AT24C64_address %256 );//写存储器字节地址
109 2 I2C_Send_Byte( *(uchar*)mcu_address );//写MCU地址指针指数据到存储单元
110 2 I2C_Stop();
111 2 delay_n_ms(10); /* waiting for write cycle to be completed */
112 2 ((uchar*)mcu_address)++;
113 2 AT24C64_address++;
114 2 }
115 1 }
116
117 //读多字节数据
C51 COMPILER V8.05a IIC20080107 01/08/2008 18:22:40 PAGE 3
118 //供外部调用函数
119
120 void write1()
121 {
122 1 uchar code tab[96]=
123 1 {//欢迎您
124 1 0x0,0x80,0x40,0x0,0x8,0x0,0x0,0x80,0x21,0x80,0x9,0x0,0xfc,0x80,0x36,0x7c,0x11,0xfe,0x5,0xfe,0x24,0x44,0x12
-,0x4,0x85,0x4,0x4,0x44,0x34,0x40,0x4a,0x48,0x4,0x44,0x32,0x50,0x28,0x40,0xe4,0x44,0x52,0x48,0x10,0x40,0x24,0x44,0x94,0x4
-4,0x18,0x40,0x25,0x44,0x11,0x44,0x18,0x60,0x26,0x54,0x10,0x80,0x24,0xa0,0x24,0x48,0x0,0x0,0x24,0x90,0x20,0x40,0x29,0x4,0
-x41,0x18,0x20,0x40,0x28,0x92,0x86,0xe,0x50,0x0,0x68,0x12,0x38,0x4,0x8f,0xfe,0x7,0xf0,0x0,0x0,0x0,0x0,0x0,0x0
125 1 };
126 1 AT24C64_W(tab,0x0,0x60);
127 1
128 1 }
129
130 void write2()
131 {
132 1 uchar code tab[96]={
133 1 //欢迎光临
134 1 0x0,0x0,0x0,0x0,0x0,0x0,0x3,0x0,0x0,0x2,0x1,0x0,0x2,0x4,0x7e,0x4,0x1,0x20,0x7a,0x2,0x92,0x4,0x45,0x20,0xb,
-0xe2,0x92,0x14,0x85,0x7e,0xa,0x20,0x92,0x14,0x85,0x50,0x55,0x40,0x92,0x14,0x5,0xd8,0x35,0x6,0x92,0x7f,0xe5,0x8,0x31,0x2,
-0x92,0x9,0x5,0x7e,0x11,0x2,0xb2,0x9,0x5,0x52,0x29,0x82,0xf6,0x9,0x5,0x52,0x29,0x82,0x90,0x9,0x5,0x52,0x4a,0x42,0x10,0x11
-,0x25,0x52,0x46,0x63,0x0,0x31,0x25,0x7e,0xc,0x24,0xfe,0x61,0xe1,0x42,0x0,0x0,0x0,0x0,0x0,0x0
135 1
136 1
137 1 };
138 1 AT24C64_W(tab,0x60,0x60);
139 1 }
140
141 void write3()
142 {
143 1 uchar code tab[96]={
144 1 //13.24
145 1 0x0,0x0,0x0,0x0,0x0,0x0,0x4,0x0,0x0,0x0,0x0,0x40,0x4,0x1,0x80,0x3f,0xc0,0x20,0x24,0x44,0x40,0x2,0x7,0xfe,0
-x24,0x40,0x60,0x2,0x44,0x2,0x24,0x40,0x20,0x12,0xc4,0x2,0x24,0x40,0x60,0x12,0x80,0x42,0x3f,0xc0,0x50,0x12,0x80,0x80,0x4,
-0x0,0xd0,0x2,0x7,0xfe,0x24,0x40,0x90,0x7f,0xe0,0x88,0x24,0x41,0x88,0x2,0x1,0x10,0x24,0x41,0xc,0x2,0x0,0xd0,0x24,0x42,0x6
-,0x2,0x0,0x30,0x3f,0xc6,0x2,0x2,0x0,0xdc,0x0,0x40,0x0,0x2,0x7,0x87,0x0,0x0,0x0,0x0,0x0,0x0
146 1
147 1
148 1 };
149 1 AT24C64_W(tab,0xc0,0x60);
150 1 }
151 void write4()
152 {
153 1 uchar code tab[96]={
154 1 //温世坚
155 1 0x40,0x0,0x0,0x0,0x8,0x0,0x27,0xf0,0x12,0x10,0xb,0xfc,0x24,0x10,0x12,0x10,0x49,0x8,0x7,0xf0,0x12,0x10,0x49
-,0x10,0x94,0x10,0x12,0x10,0x48,0xa0,0x54,0x10,0xff,0xfe,0x48,0x40,0x17,0xf0,0x12,0x10,0x48,0xb0,0x20,0x0,0x12,0x10,0x49,
-0xe,0x2f,0xfc,0x12,0x10,0xa,0x4,0xc9,0x24,0x13,0xf0,0x9,0x0,0x49,0x24,0x12,0x10,0x3f,0xf8,0x49,0x24,0x10,0x0,0x1,0x0,0x4
-9,0x24,0x10,0x8,0x1,0x0,0x49,0x24,0x1f,0xfc,0x1,0x0,0x5f,0xfe,0x0,0x0,0xff,0xfe,0x40,0x0,0x0,0x0,0x0,0x0
156 1
157 1
158 1 };
159 1 AT24C64_W(tab,0x120,0x60);
160 1 }
161
162 //=====================================
163 void main()
164 {
165 1
166 1 //uchar i,j;
167 1 //P1=0;
C51 COMPILER V8.05a IIC20080107 01/08/2008 18:22:40 PAGE 4
168 1 //P2=0;
169 1
170 1 P3=0;
171 1 RED=0;
172 1 GRE=0;
173 1 write1();
174 1 write2();
175 1 write3();
176 1 write4();
177 1 // write2();
178 1 GRE=1;
179 1 RED=1;
180 1 }
181
182
183
184
185
186
MODULE INFORMATION: STATIC OVERLAYABLE
CODE SIZE = 313 ----
CONSTANT SIZE = 384 ----
XDATA SIZE = ---- ----
PDATA SIZE = ---- ----
DATA SIZE = ---- 7
IDATA SIZE = ---- ----
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 + -