📄 bl37.lst
字号:
C51 COMPILER V8.08 BL37 03/01/2008 06:32:25 PAGE 1
C51 COMPILER V8.08, COMPILATION OF MODULE BL37
OBJECT MODULE PLACED IN bl37.OBJ
COMPILER INVOKED BY: C:\Keil\C51\BIN\C51.EXE bl37.c BROWSE DEBUG OBJECTEXTEND
line level source
1 #include "reg52.h"
2 #include "INTRINS.H"
3 sbit R372A_SCL = P2^4;
4 sbit R372A_SDA = P2^5;
5 sbit CS = 0xa0;
6 sbit Clk = 0xa1;
7 sbit DO1 = 0xa2;
8 sbit DI = 0xa3;
9
10 unsigned char time12[] = { 0x12,0x01,0x02,0x03,0x04,0x05,0x06,0x07,0x08,0x09,0x10,0x11,
11 0x32,0x21,0x22,0x23,0x24,0x25,0x26,0x27,0x28,0x29,0x30,0x31};
12 unsigned char time24[] = { 0x00,0x01,0x02,0x03,0x04,0x05,0x06,0x07,0x08,0x09,0x10,0x11,
13 0x12,0x13,0x14,0x15,0x16,0x17,0x18,0x19,0x20,0x21,0x22,0x23};
14
15 void Show_XW_LCD(unsigned char xPos,unsigned char yPos,unsigned char sData);
16 void LCD_Init( void );
17 void Print_LCD ( unsigned char xPos, unsigned char yPos,int nSentenceID );
18 void Clear_H_LCD(unsigned char H);
19 void Delay_xMs(unsigned int xMs);
20 unsigned char T2S(unsigned char dat);
21 unsigned char A_D(bit CH);
22 /*
23 {
24 unsigned int i,j;
25 for(i=0;i < xMs;i++)
26 {
27 for(j=0;j<500;j++);
28 }
29 }*/
30 /*----------------------------------------------------------------------------*/
31 void Start_Cond()
32 {
33 1 R372A_SCL = 0;
34 1 _nop_();_nop_();_nop_();_nop_();_nop_();
35 1 R372A_SDA = 1;
36 1 _nop_();_nop_();_nop_();_nop_();_nop_();
37 1 R372A_SCL = 1;
38 1 _nop_();_nop_();_nop_();_nop_();_nop_();
39 1 R372A_SDA = 0;
40 1 _nop_();_nop_();_nop_();_nop_();_nop_();
41 1 }
42 /*----------------------------------------------------------------------------*/
43 void Stop_Cond()
44 {
45 1 R372A_SCL = 0;
46 1 _nop_();_nop_();_nop_();_nop_();_nop_();
47 1 R372A_SDA = 0;
48 1 _nop_();_nop_();_nop_();_nop_();_nop_();
49 1 R372A_SCL = 1;
50 1 _nop_();_nop_();_nop_();_nop_();_nop_();
51 1 R372A_SDA = 1;
52 1 _nop_();_nop_();_nop_();_nop_();_nop_();
53 1 }
54 /*----------------------------------------------------------------------------*/
55 void Ack()
C51 COMPILER V8.08 BL37 03/01/2008 06:32:25 PAGE 2
56 {
57 1
58 1 R372A_SCL = 0;
59 1 _nop_();_nop_();_nop_();_nop_();_nop_();
60 1 R372A_SDA = 0;
61 1 _nop_();_nop_();_nop_();_nop_();_nop_();
62 1 R372A_SCL = 1;
63 1 _nop_();_nop_();_nop_();_nop_();_nop_();
64 1 R372A_SCL = 0;
65 1 _nop_();_nop_();_nop_();_nop_();_nop_();
66 1 R372A_SDA = 1;
67 1 _nop_();_nop_();_nop_();_nop_();_nop_();
68 1 }
69
70
71
72
73 /*----------------------------------------------------------------------------*/
74 void NoAck()
75 {
76 1 R372A_SCL = 0;
77 1 _nop_();_nop_();_nop_();_nop_();_nop_();
78 1 R372A_SDA = 1;
79 1 _nop_();_nop_();_nop_();_nop_();_nop_();
80 1 R372A_SCL = 1;
81 1 _nop_();_nop_();_nop_();_nop_();_nop_();
82 1 R372A_SCL = 0;
83 1 _nop_();_nop_();_nop_();_nop_();_nop_();
84 1 }
85 /*----------------------------------------------------------------------------*/
86 bit Write8Bit(unsigned char input) {
87 1 unsigned char i;
88 1 R372A_SCL = 0;
89 1 for (i=0;i<8;i++)
90 1 {
91 2 input <<= 1;
92 2 R372A_SDA = CY;
93 2 R372A_SCL = 1;
94 2 _nop_();_nop_();_nop_();_nop_();_nop_();
95 2 R372A_SCL = 0;
96 2 _nop_();_nop_();_nop_();_nop_();_nop_();
97 2 }
98 1 R372A_SCL = 0;
99 1 _nop_();_nop_();_nop_();_nop_();_nop_();
100 1 R372A_SDA = 1;
101 1 _nop_();_nop_();_nop_();_nop_();_nop_();
102 1 R372A_SCL = 1;
103 1 _nop_();_nop_();_nop_();_nop_();_nop_();
104 1 CY = R372A_SDA;
105 1 return(CY) ;
106 1 }
107 /*----------------------------------------------------------------------------*/
108 unsigned char Read8Bit()
109 {
110 1 unsigned char temp,rbyte=0;
111 1 for (temp = 8;temp != 0;temp--)
112 1 {
113 2 R372A_SCL = 0;
114 2 _nop_();_nop_();
115 2 rbyte = (rbyte << 1) | R372A_SDA;
116 2 R372A_SCL = 1;
117 2 _nop_();_nop_();
C51 COMPILER V8.08 BL37 03/01/2008 06:32:25 PAGE 3
118 2 }
119 1 return rbyte;
120 1 }
121 /*----------------------------------------------------------------------------*/
122 bit Write_Byte_R372A(unsigned char nRegister,unsigned char nCommand)
123 {
124 1 Start_Cond();
125 1 Write8Bit(0x64);
126 1 Write8Bit(nRegister << 4);
127 1 Write8Bit(nCommand);
128 1 Stop_Cond();
129 1 _nop_();
130 1 Stop_Cond();
131 1 return(CY);
132 1 }
133
134 /*----------------------------------------------------------------------------*/
135 bit Init_R372A (void)
136 {
137 1 unsigned char i,Temp;
138 1 bit Error_Flag = 0;
139 1
140 1 for (i = 0;i < 255;i++)
141 1 {
142 2 Start_Cond();
143 2 if (Write8Bit(0x64)) /*写Slave address 写模式 MSB 0 1 1 0 0 1 0 R/W LSB*/
144 2 {
145 3 Error_Flag = 1 ;
146 3 Delay_xMs(10);
147 3 continue;
148 3 }
149 2 else
150 2 {
151 3 Write8Bit(0xf4);
152 3 Temp = Read8Bit();
153 3 Ack();//NoAck(); //BL372A Ack(); RICOH372A NoAck();
154 3 if (Temp == 0xFF)
155 3 {
156 4 Error_Flag = 1;
157 4 continue;
158 4 }
159 3 break;
160 3 }
161 2 }
162 1
163 1 Delay_xMs(25);
164 1
165 1 Write_Byte_R372A(0x0F,0x0C); /*24 Hours System,ADJ=0,CLEN=1,CTFG=0*/
166 1 Write_Byte_R372A(0x07,0x00); /*XSL=0 Use 32.768KHz,no time trimming*/
167 1 Write_Byte_R372A(0x0E,0x00); /*Control Register 1 ALE=BLE=0 SL2=SL1=0 CT2=CT1=CT0=0*/
168 1
169 1 Stop_Cond();
170 1 return(Error_Flag);
171 1 }
172 /*----------------------------------------------------------------------------*/
173 bit Read_R372A (unsigned char *nContent)
174 {
175 1 unsigned char i;
176 1
177 1 Start_Cond();
178 1 _nop_();
179 1 Write8Bit(0x64); /*写Slave address 写模式 MSB 0 1 1 0 0 1 0 R/W LSB*/
C51 COMPILER V8.08 BL37 03/01/2008 06:32:25 PAGE 4
180 1 Write8Bit(0x04); //04 /*从0寄存器开始读,采用方式第2种*/
181 1
182 1
183 1 for( i = 0;i < 6;i++ )
184 1 {
185 2 nContent[i] = Read8Bit();
186 2 Ack();
187 2 }
188 1 nContent[6] = Read8Bit();
189 1 NoAck();
190 1 Stop_Cond();
191 1 nContent[3] = nContent[4];
192 1 nContent[4] = nContent[5];
193 1 nContent[5] = nContent[6];
194 1
195 1 for(i=0;i<24;i++)
196 1 {
197 2 if ( nContent[2] == time12[i] )
198 2 break;
199 2 }
200 1
201 1 nContent[2] = time24[i];
202 1
203 1
204 1 if ( (nContent[5] & 0x0f ) > 0x09 || ( nContent[5] & 0xf0 ) > 0x90
205 1 || ( nContent[4] > 0x12 )
206 1 || ( nContent[3] > 0x31 ) )
207 1 return(1);
208 1
209 1 if (nContent[3] == 0xff || nContent[4] == 0xff || nContent[4] == 0 || nContent[3] == 0 )
210 1 return(1);
211 1
212 1
213 1
214 1 return(0);
215 1 }
216 /*----------------------------------------------------------------------------*/
217 bit Write_R372A (unsigned char *nContent)
218 {
219 1 unsigned char i;
220 1 bit Error_Flag = 0;
221 1 // nContent[2] = time[nContent[2]];
222 1 for(i=0;i<24;i++)
223 1 {
224 2 if ( nContent[2] == time24[i] )
225 2 break;
226 2 }
227 1
228 1 nContent[2] = time12[i];
229 1
230 1
231 1
232 1 Start_Cond();
233 1 Write8Bit(0x64); /*写Slave address 写模式 MSB 0 1 1 0 0 1 0 R/W LSB*/
234 1 Write8Bit(0x00); /*从0寄存器开始写,采用方式第1种*/
235 1 for (i = 0; i < 7; i++)
236 1 {
237 2 if (i == 3)
238 2 {
239 3 Error_Flag = Write8Bit(1); /*将Week寄存器写入1 不用*/
240 3 }
241 2 else
C51 COMPILER V8.08 BL37 03/01/2008 06:32:25 PAGE 5
242 2 {
243 3 Error_Flag = Write8Bit(*nContent);
244 3 nContent++;
245 3 }
246 2 }
247 1 Stop_Cond();
248 1 return(Error_Flag); /*返回0正确,返回1错误*/
249 1 }
250
251
252
253
254 void main()
255 {
256 1 unsigned char CH0_Data,Show_Data;
257 1 unsigned char y = 0,Temp[7],Data1[] = {0x00,0x00,0x12,0x16,0x05,0x03};
258 1 unsigned char hour,min,sec;
259 1 Init_R372A();
260 1 Write_R372A(Data1);
261 1 LCD_Init(); //液晶初始化?
262 1 Clear_H_LCD(0);
263 1 Clear_H_LCD(1);
264 1 Print_LCD(5,0,0); //显示★电子工作室★
265 1 Print_LCD(0,2,1); //显示现在是: : :
266 1 while(1)
267 1 {
268 2 Read_R372A(Temp);
269 2 hour = Temp[2];
270 2 min = Temp[1];
271 2 sec = Temp[0];
272 2 Show_XW_LCD(56,2,(hour>>4));
273 2 Show_XW_LCD(64,2,(hour&0x0f));
274 2 Show_XW_LCD(80,2,(min>>4));
275 2 Show_XW_LCD(88,2,(min&0x0f));
276 2 Show_XW_LCD(104,2,(sec>>4));
277 2 Show_XW_LCD(112,2,(sec&0x0f));
278 2 //Delay_xMs(300);
279 2 CH0_Data = A_D(0); //AD采样
280 2 Show_Data = T2S(CH0_Data); //温度转换成显示码
281 2 Show_XW_LCD(84,0,(Show_Data>>4)); //显示温度十位
282 2 Show_XW_LCD(92,0,(Show_Data&0x0f)); //显示温度个位
283 2 }
284 1 }
MODULE INFORMATION: STATIC OVERLAYABLE
CODE SIZE = 825 ----
CONSTANT SIZE = 6 ----
XDATA SIZE = ---- ----
PDATA SIZE = ---- ----
DATA SIZE = 48 23
IDATA SIZE = ---- ----
BIT SIZE = ---- 2
END OF MODULE INFORMATION.
C51 COMPILATION COMPLETE. 0 WARNING(S), 0 ERROR(S)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -