📄 main.lst
字号:
C51 COMPILER V8.02 MAIN 06/16/2007 16:57:02 PAGE 1
C51 COMPILER V8.02, COMPILATION OF MODULE MAIN
OBJECT MODULE PLACED IN main.OBJ
COMPILER INVOKED BY: C:\Keil\C51\BIN\C51.EXE main.c BROWSE DEBUG OBJECTEXTEND
line level source
1 #include <reg52.h>
2 //#include <string.h>
3 #include <intrins.h>
4 #include <math.h>
5 #include <stdio.h>
6 #include <borad.h>
7 #include <SERIAL.H>
8
9
10 #define uint unsigned int
11 #define uchar unsigned char
12 //#define STARTMESSAGE "简易高压测试仪:\nV2.11 2007-5-11\n 珠海晶研佳信\nTel:0756-3366219"
13 code char StartMessage[]="简易高压测试仪:\nV2.11 2007-5-11\n 珠海晶研佳信\nTel:0756-3366219";
14 #define BASECALIBRATIONMESSAGE "连接测试线\n断开负载\n按开始键自校……\n"
15 #define CYCLE (-10000)
16 #define STD_RESISTOR 1056
17 #define MIN_RESISTOR ((int)(STD_RESISTOR*0.8+0.5))
18 #define MAX_RESISTOR ((int)(STD_RESISTOR*1.2+0.5))
19 #define STD_CAPACITOR 500
20 #define MIN_CAPACITOR ((int)(STD_CAPACITOR-200))
21 #define MAX_CAPACITOR ((int)(STD_CAPACITOR+200))
22
23 #define RstdNo 8
24 #define CstdNo 12
25
26 //#include "VI2C_C51.h"
27 //#include "ocm4x8c串.h"
28
29 //#define Debugging 1
30
31
32 //sbit Rf=P3^2;
33 //sbit Cf=P3^3;
34
35
36 sbit DA=P1^0;
37 sbit CLK=P1^1;
38 sbit CS=P1^2;
39 sbit BELL=P1^3;
40 sbit LCM_RST=P1^4;
41 sbit LCM_CS=P1^5;
42 sbit LCM_STD=P1^6;
43 sbit LCM_SCLK=P1^7;
44 //bit NormalTest=0;
45
46 sbit RA=P2^0;
47 sbit RB=P2^1;
48 sbit RC=P2^2;
49 sbit INH=P2^3;
50 sbit CA=P2^4;
51 sbit CB=P2^5;
52 sbit AUTOSTEP=P2^6;
53 sbit STEP=P2^7;
54 #define GATE0 0x08
55 #define GATE1 0x80
C51 COMPILER V8.02 MAIN 06/16/2007 16:57:02 PAGE 2
56
57
58 sbit Signal=P3^3;
59 sbit SCL=P3^6;
60 sbit SDA=P3^7;
61
62
63 bit AUTO;
64 bit twingle=0;
65 bit twingledo=0;
66 bit Dis=0;
67 unsigned char dt=0;
68 #define OK 33
69 #define NG 44
70 unsigned int TestData[8];
71 unsigned long ParamC0[8]={-1,-1,-1,-1,0,0,0,0};
72 unsigned int MinR,MaxR,MinC,MaxC,nR,nC;
73 unsigned long StdR0,StdC0;
74 //#define StdR0 8873430
75 //#define StdC0 13000
76 unsigned long StdR=10000,StdC=10000;
77 //unsigned long C10,C20,C30,C40;
78 //unsigned long R10,R20,R30,R40;
79 bit StartTest=0;
80 //uchar tdTH,tdTL;
81 uint tn;
82 //uchar tc;
83 //uint wtt;
84 char OkLed;
85 #define Led0 1
86 #define Led1 2
87 #define Led2 4
88 #define Led3 8
89 #define Led4 16
90 #define Led5 32
91 #define ALLOK 64
92 void Test(char);
93 void LedSend8(char);
94 void LedShow(char,char);
95 void LedTest(void);
96 void Bell(unsigned int);
97 long Test0(char,unsigned int);
98 void Check(char);
99 void Display(char);
100 char Remote(void);
101 bit CheckAuto(bit);
102 char WaitKey(void);
103 long Tests(char,unsigned int);
104 bit CalC(void);
105 bit ComPrint(char *);
106 void DisplayData(unsigned char,unsigned int);
107 bit EEWrite8(char);
108 unsigned char EERead8(void);
109 void EEStart(void);
110 void EEStop(void);
111 bit EEWrite(char,char);
112 unsigned char EERead(char);
113 unsigned int GetInt(void);
114 void LongPrint(unsigned long);
115 unsigned long LngRead(unsigned char);
116 void DisParam(void);
117 void LmWrite(void);
C51 COMPILER V8.02 MAIN 06/16/2007 16:57:02 PAGE 3
118 void BsWrite(void);
119 void Waiting(void);
120 void DeftVal(char);
121
122 void main(void)
123 {
124 1 char i;
125 1 Initial();
126 1 CB=0;
127 1 twingle=0;
128 1 // StartTest=1
129 1 DeftVal(0);
130 1 DeftVal(1);
131 1 i=EERead(0);
132 1 // i=0xff;
133 1 if(i&1)
134 1 {
135 2 LmWrite();
136 2 i&=~1;
137 2 EEWrite(0,i);
138 2 }
139 1 else
140 1 {
141 2 MinR=EERead(0x11)*256+EERead(0x10);
142 2 MaxR=EERead(0x13)*256+EERead(0x12);
143 2 MinC=EERead(0x21)*256+EERead(0x20);
144 2 MaxC=EERead(0x23)*256+EERead(0x22);
145 2 nR=EERead(0x17)*256+EERead(0x16);
146 2 nC=EERead(0x27)*256+EERead(0x26);
147 2 }
148 1 if(i&2)
149 1 {
150 2 //StdR0=Tests(RstdNo,1000);
151 2 //StdC0=Tests(CstdNo,1000);
152 2 BsWrite();
153 2 i&=~2;
154 2 EEWrite(0,i);
155 2 }
156 1 else
157 1 {
158 2 StdR0=LngRead(0x30);
159 2 StdC0=LngRead(0x40);
160 2 }
161 1 LedShow(0xff,0xff);
162 1 // DelayMs(2000);
163 1 LcdClear();
164 1 LcdPrint(StartMessage );
165 1 ComPrint("\n");
166 1 ComPrint(StartMessage);
167 1 LedTest();
168 1 Bell(100);DelayMs(100);Bell(100);
169 1 LcdClear();
170 1 LcdPrint(BASECALIBRATIONMESSAGE);
171 1 LedShow(0xbf,0xbf);
172 1 OkLed=0xbf;
173 1 Waiting();
174 1 LcdClear();
175 1 LcdPrint("\n 正在自校……\n");
176 1 LedShow(0xc0,0xc0);
177 1 StdR=Tests(RstdNo,1000);
178 1 for(i=4;i<8;i++)
179 1 {
C51 COMPILER V8.02 MAIN 06/16/2007 16:57:02 PAGE 4
180 2 ParamC0[i]=Tests(i,1000);
181 2 }
182 1 // StdC0=31480;
183 1 StdC=Tests(CstdNo,1000);
184 1 StdC-=StdC0;
185 1 LedShow(0xff,0xff);
186 1 Bell(500);
187 1 DisParam();
188 1 LcdClear();
189 1 LcdPrint("按开始键\n开始测试……\n");
190 1 while(1)
191 1 {
192 2 Waiting();
193 2 OkLed=0;
194 2 Bell(200);
195 2 LedShow(0xff,0xff);
196 2 LcdClear();
197 2 LcdPrint("\n * Testing *");
198 2 ComPrint("TestBegin\n{\n");
199 2 if(!AUTO) LcdClear();
200 2 OkLed=0;
201 2 for(i=0;i<8;i++)
202 2 {
203 3 DelayMs(20);
204 3 Test(i);
205 3 // if(i>=4) CalC(i);
206 3 if(i<4) Check(i);
-
-
-
-
-
-
-
-
-
207 3 if(!AUTO&&i<4)
208 3 {
209 4 Display(i);
210 4 if(i<5) WaitKey();
211 4 }
212 3 }
213 2 P2=(P2&0xF0)|CstdNo|0XC0; //通道设定8
214 2 twingle=1;
215 2 DelayMs(100);
216 2 CalC();
217 2 //
218 2
219 2 //
220 2 Check(4);
221 2 Check(5);
222 2 Check(6); //all
223 2 // NormalTest=1;
224 2 // if(AUTO)
225 2 // StdC=Test0(CstdNo,1000)-StdC0;
226 2 // DelayMs(50);
227 2 // StdR=Test0(RstdNo,1000);
228 2 //StdR=1.0*StdR0*StdR/(StdR0-StdR);
229 2 {
230 3 LcdClear();
231 3 for(i=0;i<6;i++)
232 3 {
C51 COMPILER V8.02 MAIN 06/16/2007 16:57:02 PAGE 5
233 4 Display(i);
234 4 }
235 3 }
236 2 if(OkLed&ALLOK)
237 2 {
238 3 LcdPrint(" *** PASS ***");
239 3 ComPrint("PASS\n");
240 3 Bell(800);
241 3 }
242 2 else
243 2 {
244 3 LcdPrint(" !!FAIL!!");
245 3 ComPrint("Fail\n");
246 3 Bell(100);DelayMs(100);Bell(100);
247 3 }
248 2 ComPrint("}\nTestEnd\n\n");
249 2 }
250 1 }
251 void DeftVal(char t)
252 {
253 1 switch(t)
254 1 {
255 2 case 0:
256 2 MaxR=MAX_RESISTOR;
257 2 MinR=MIN_RESISTOR;
258 2 MaxC=MAX_CAPACITOR;
259 2 MinC=MIN_CAPACITOR;
260 2 nR=300;
261 2 nC=1000;
262 2 break;
263 2 case 1:
264 2 StdR0=8873430L;
265 2 StdC0=11500L;
266 2 break;
267 2 }
268 1 }
269 void Waiting(void)
270 {
271 1 char i,d;
272 1 // unsigned long R0,C0;
273 1 while(1)
274 1 {
275 2 i=WaitKey();
276 2 if(i!=0)
277 2 {
278 3 if(i>'Z') i-='z'-'Z';
279 3 switch(i)
280 3 {
281 4 case 'A':AUTO=1;ComPrint("Auto");return;
282 4 case 'S':AUTO=0;ComPrint("Step");return;
283 4 case 'D':
284 4 DisParam();
285 4 break;
286 4 case 'P':
287 4 ComPrint("New parameter:\n");
288 4 ComPrint("Min_R: ");MinR=GetInt()==0?MinR*10:GetInt();DisplayData(0x80,MinR);ComPrint(" KΩ\n");MinR/=
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -