📄 ds18b20.lst
字号:
C51 COMPILER V7.09 DS18B20 08/06/2007 14:13:54 PAGE 1
C51 COMPILER V7.09, COMPILATION OF MODULE DS18B20
OBJECT MODULE PLACED IN DS18B20.OBJ
COMPILER INVOKED BY: C:\Keil\C51\BIN\C51.EXE DS18B20.c BROWSE DEBUG OBJECTEXTEND
line level source
1 #include "DS18B20.h"
*** ERROR C202 IN LINE 2 OF DS18B20.H: 'P3': undefined identifier
2 void delay_18b20(unsigned int count)
3 {
4 1 unsigned int i;
5 1 while(count)
6 1 {
7 2 i=200;
8 2 while(i>0) i--;
9 2 count--;
10 2
11 2 }
12 1 }
13 void Init_DS18B20(void)
14 {
15 1 unsigned int i=0;
16 1 unsigned char x=0;
17 1 while(1)
18 1 {
19 2 DQ = 1; //DQ复位
*** ERROR C202 IN LINE 19 OF DS18B20.C: 'DQ': undefined identifier
20 2 delay_18b20(8); //稍做延时
21 2 DQ = 0; //单片机将DQ拉低
*** ERROR C202 IN LINE 21 OF DS18B20.C: 'DQ': undefined identifier
22 2 i=100;while(i>0) i--;
23 2 DQ = 1; //拉高总线
*** ERROR C202 IN LINE 23 OF DS18B20.C: 'DQ': undefined identifier
24 2 i=6;while(i>0) i--;
25 2 x=DQ; //稍做延时后 如果x=0则初始化成功 x=1则初始化失败
*** ERROR C202 IN LINE 25 OF DS18B20.C: 'DQ': undefined identifier
26 2 x=DQ;
*** ERROR C202 IN LINE 26 OF DS18B20.C: 'DQ': undefined identifier
27 2 x=DQ;
*** ERROR C202 IN LINE 27 OF DS18B20.C: 'DQ': undefined identifier
28 2 x=DQ;
*** ERROR C202 IN LINE 28 OF DS18B20.C: 'DQ': undefined identifier
29 2 if(x==0)
30 2 {
31 3 flag=1;
*** ERROR C202 IN LINE 31 OF DS18B20.C: 'flag': undefined identifier
32 3 break;
33 3 }
34 2 else
35 2 {
36 3 if(i==3) break;
37 3 delay_18b20(30);
38 3 flag=0;
*** ERROR C202 IN LINE 38 OF DS18B20.C: 'flag': undefined identifier
39 3 i++;
40 3 }
41 2 }
42 1
43 1
44 1
45 1 unsigned char ReadOneChar(void)
C51 COMPILER V7.09 DS18B20 08/06/2007 14:13:54 PAGE 2
*** ERROR C141 IN LINE 45 OF DS18B20.C: syntax error near 'unsigned'
46 1 {
47 1 unsigned char i=0;
48 1 unsigned char j=0;
*** ERROR C141 IN LINE 48 OF DS18B20.C: syntax error near 'unsigned'
*** ERROR C202 IN LINE 48 OF DS18B20.C: 'j': undefined identifier
49 1 unsigned char dat = 0;
*** ERROR C141 IN LINE 49 OF DS18B20.C: syntax error near 'unsigned'
*** ERROR C202 IN LINE 49 OF DS18B20.C: 'dat': undefined identifier
50 1 for (i=8;i>0;i--)
51 1 {
52 2 DQ = 1;
*** ERROR C202 IN LINE 52 OF DS18B20.C: 'DQ': undefined identifier
53 2 DQ = 0; // 给脉冲信号
*** ERROR C202 IN LINE 53 OF DS18B20.C: 'DQ': undefined identifier
54 2 j++;
*** ERROR C202 IN LINE 54 OF DS18B20.C: 'j': undefined identifier
55 2 DQ = 1; // 给脉冲信号
*** ERROR C202 IN LINE 55 OF DS18B20.C: 'DQ': undefined identifier
56 2 dat>>=1;
*** ERROR C202 IN LINE 56 OF DS18B20.C: 'dat': undefined identifier
57 2 j++;
*** ERROR C202 IN LINE 57 OF DS18B20.C: 'j': undefined identifier
58 2 j++;
*** ERROR C202 IN LINE 58 OF DS18B20.C: 'j': undefined identifier
59 2 if(DQ)
*** ERROR C202 IN LINE 59 OF DS18B20.C: 'DQ': undefined identifier
60 2 dat|=0x80;
*** ERROR C202 IN LINE 60 OF DS18B20.C: 'dat': undefined identifier
61 2 j=10;while(j>0) j--;
*** ERROR C202 IN LINE 61 OF DS18B20.C: 'j': undefined identifier
*** ERROR C202 IN LINE 61 OF DS18B20.C: 'j': undefined identifier
*** ERROR C202 IN LINE 61 OF DS18B20.C: 'j': undefined identifier
62 2 }
63 1 return(dat);
*** ERROR C202 IN LINE 63 OF DS18B20.C: 'dat': undefined identifier
64 1 }
65
66 //写一个字节
67 void WriteOneChar(unsigned char dat)
68 {
69 1 unsigned char i=0;
70 1 unsigned char j=0;
71 1 for (i=8; i>0; i--)
72 1 {
73 2 DQ = 1;
*** ERROR C202 IN LINE 73 OF DS18B20.C: 'DQ': undefined identifier
74 2 DQ = 0;
*** ERROR C202 IN LINE 74 OF DS18B20.C: 'DQ': undefined identifier
75 2 j++;
76 2 j++;
77 2 //j=10;while(j>0) j--;
78 2 DQ = dat&0x01;
*** ERROR C202 IN LINE 78 OF DS18B20.C: 'DQ': undefined identifier
79 2 j=10;while(j>0) j--;
80 2 dat>>=1;
81 2 DQ=1;
*** ERROR C202 IN LINE 81 OF DS18B20.C: 'DQ': undefined identifier
82 2 j++;
83 2 }
84 1 }
85
C51 COMPILER V7.09 DS18B20 08/06/2007 14:13:54 PAGE 3
86 //读取温度
87 unsigned int ReadTemperature(void)
88 {
89 1 unsigned char a=0;
90 1 unsigned char b=0;
91 1 unsigned int t=0;
92 1 Init_DS18B20();
93 1 delay_18b20(1);
94 1 if(flag==1)
*** ERROR C202 IN LINE 94 OF DS18B20.C: 'flag': undefined identifier
95 1 {
96 2
97 2 WriteOneChar(0xCC); // 跳过读序号列号的操作
98 2 WriteOneChar(0x44); // 启动温度转换
99 2 delay_18b20(200);
100 2 Init_DS18B20();
101 2 delay_18b20(1);
102 2 WriteOneChar(0xCC); //跳过读序号列号的操作
103 2 WriteOneChar(0xBE); //读取温度寄存器等(共可读9个寄存器) 前两个就是温度
104 2 a=ReadOneChar();
105 2 b=ReadOneChar();
106 2 t=b;
107 2 t<<=8;
108 2 t=t|a;
109 2 t>>=4;
110 2 //tt=t*0.0625;
111 2 //t= tt*10+0.5; //放大10倍输出并四舍五入---此行没用
112 2 return(t);
113 2 }
114 1 else
115 1 return(0);
116 1 }
C51 COMPILATION COMPLETE. 0 WARNING(S), 33 ERROR(S)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -