📄 main.lst
字号:
C51 COMPILER V7.50 MAIN 09/20/2008 15:21:11 PAGE 1
C51 COMPILER V7.50, 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
2 #include "main.h"
3
4 extern idata Counter periodCounters[10];
5
6 xdata uchar state=NORMAL;
7 xdata Counter tCounter;
8 xdata uchar liangcheng;
9
10 xdata uchar s_MHz;//the second part of the period,The Millions of the frequency value
11 xdata uint ms_KHz,us_Hz;////the ms and us part of the period
12 xdata uint decimal;//the part after point of the frequency and period
13 bit canceled=0;
14 xdata uchar MeasureType=1;//1-frequency & period; 2-interval
15 xdata double dCounter;
16 xdata double fdCounter;
17 xdata char restorePos=0;//the length of HisData[10]
18 xdata char showPos=0;
19 xdata uchar coefficient;
20 //bit interrupted=0;
21
22 xdata refreshTime=0;
23 xdata refreshTemp=0;
24
25 xdata uchar ran;
26
27 xdata struct History HisData[10];
28
29
30
31 //xdata char ucCurtime[7];
32
33 void main()
34 {
35 1 uchar keyvalue;
36 1
37 1 SP=0xd0;
38 1
39 1 OpenWatchDog(0); //禁止看门狗
40 1 InitSysClock(); //时钟初始化
41 1 InitPort();
42 1 InitInterrupt();
43 1
44 1 LcdInit();
45 1
46 1 // Delayms(5000);
47 1 //数据初始化
48 1
49 1 // setDateTime();
50 1
51 1
52 1 //for(keyvalue=0;keyvalue<200;keyvalue++)
53 1 // v_Get1302(ucCurtime);
54 1
55 1 start1302();
C51 COMPILER V7.50 MAIN 09/20/2008 15:21:11 PAGE 2
56 1
57 1 keyvalue=NOKEY;
58 1 ShowDateTime();
59 1
60 1 while(1)
61 1 {
62 2 keyvalue=KeyScan();
63 2 if(keyvalue!=NOKEY)
64 2 ET0=0;
65 2 else
66 2 ET0=1;
67 2
68 2 if(state==NORMAL && keyvalue==HISTORY)
69 2 {
70 3 showPos=0;
71 3 if(restorePos==0)
72 3 {
73 4 LcdClear();
74 4 LcdShow(1,1,"无历史记录");
75 4 continue;
76 4 }
77 3
78 3 showHistory(showPos);
79 3 state=SHOW_HIST;
80 3
81 3 }
82 2 else if(state==SHOW_HIST && keyvalue==UP)
83 2 {
84 3 if(showPos<0)
85 3 showPos=restorePos-1;
86 3 showHistory(showPos);
87 3 showPos--;
88 3
89 3 }
90 2 else if(state==SHOW_HIST && keyvalue==DOWN)
91 2 {
92 3 if(++showPos==restorePos)
93 3 showPos=0;
94 3 showHistory(showPos);
95 3
96 3 }
97 2 else if(state==NORMAL && keyvalue==ZHOUQI)
98 2 {
99 3 LcdClear();
100 3 LcdShow(0,0,"周期测量");
101 3 MeasureType=1;
102 3 state=GET_PF;
103 3 }
104 2 else if(state==NORMAL && keyvalue==PINLV)
105 2 {
106 3 LcdClear();
107 3 LcdShow(0,0,"频率测量");
108 3 MeasureType=1;
109 3 state=GET_PF;
110 3 }
111 2 else if(state==NORMAL && keyvalue==JIANGE)
112 2 {
113 3 LcdClear();
114 3 LcdShow(0,0,"时间间隔测量");
115 3 NotifyStart();
116 3 if(canceled)
117 3 {
C51 COMPILER V7.50 MAIN 09/20/2008 15:21:11 PAGE 3
118 4 canceled=0;
119 4 returnMainGUI();
120 4 continue;
121 4 }
122 3 MeasureType=2;
123 3 state=GET_PF;
124 3 MeasureInterval();
125 3 }
126 2
127 2 else if(state==GET_PF && keyvalue==Hz1)
128 2 {
129 3 LcdClear();
130 3 LcdShow(1,0,"量程4M-10MHz");
131 3 Measure(4,100);
132 3
133 3 }
134 2 else if(state==GET_PF && keyvalue==Hz2)
135 2 {
136 3 LcdClear();
137 3 LcdShow(1,0,"量程200K-4MHz");
138 3 Measure(4,50);
139 3 }
140 2 else if(state==GET_PF && keyvalue==Hz3)
141 2 {
142 3 LcdClear();
143 3 LcdShow(1,0,"量程2K-200KHz");
144 3 Measure(3,5);
145 3 }
146 2 else if(state==GET_PF && keyvalue==Hz4)
147 2 {
148 3 LcdClear();
149 3 LcdShow(1,0,"量程400-2KHz");
150 3 Measure(3,1);
151 3 }
152 2 else if(state==GET_PF && keyvalue==Hz5)
153 2 {
154 3 LcdClear();
155 3 LcdShow(1,0,"量程40-400Hz");
156 3 Measure(2,1);
157 3 }
158 2 else if(state==GET_PF && keyvalue==Hz6)
159 2 {
160 3 LcdClear();
161 3 LcdShow(1,0,"量程4-40Hz");
162 3 Measure(1,1);
163 3 }
164 2 else if(state==GET_PF && keyvalue==Hz7)
165 2 {
166 3 LcdClear();
167 3 LcdShow(1,0,"量程4Hz以下");
168 3 Measure(5,1);
169 3 }
170 2
171 2
172 2 if(keyvalue==CANCEL)
173 2 {
174 3 LcdClear();
175 3 ShowDateTime();
176 3 state=NORMAL;
177 3 }
178 2 if(state==CALCU)
179 2 {
C51 COMPILER V7.50 MAIN 09/20/2008 15:21:11 PAGE 4
180 3 EX0=0;//外部中断0
181 3 tCounter=sortPeriod();
182 3 if(1==MeasureType)
183 3 {
184 4 switch(liangcheng)
185 4 {
186 5 case 4:
187 5 dCounter=(tCounter/65.536)*2/coefficient;
188 5 fdCounter=32768.00/tCounter*1000000*coefficient;
189 5 break;//65536 periods//定时器1延时为2微秒,这一步得到单位为0.001微秒的时间
190 5 case 3:
191 5 dCounter=(tCounter/1000.00)*2000/coefficient;
192 5 fdCounter=500000000.00/tCounter*coefficient;
193 5 break;//1000 periods//,这一步得到单位为0.001微秒的时间
194 5 case 2:
195 5 dCounter=(tCounter/100.00)*2000/(coefficient);
196 5 fdCounter=50000000.00/tCounter*(coefficient);
197 5 break;//100 periods//,这一步得到单位为0.001微秒的时间
198 5 case 1:
199 5 dCounter=(tCounter/10.00)*2000/(coefficient);
200 5 fdCounter=5000000.00/tCounter*(coefficient);
201 5 break;//10 periods//,这一步得到单位为0.001微秒的时间
202 5 case 5:
203 5 dCounter=(tCounter/5.00)*2000/(coefficient);
204 5 fdCounter=2500000.00/tCounter*(coefficient);
205 5 break;//5 periods//,这一步得到单位为0.001微秒的时间
206 5 }
207 4 }
208 3 else
209 3 {
210 4 dCounter=tCounter*2000;//2us ,这一步得到单位为0.001微秒的时间
211 4 }
212 3
213 3 show_sound_Result();
214 3 restore();//保存此次测量结果
215 3 //
216 3 while(CANCEL!=KeyScan());//waiting for CANCEL
217 3 state=NORMAL;
218 3 }
219 2 else if(state==NORMAL && keyvalue==NOKEY)
220 2 {
221 3 ET0=1;
222 3 EA=1;
223 3 if(refreshTime==1)
224 3 {
225 4 ShowTime();
226 4 refreshTime=0;
227 4 }
228 3 if(refreshTemp==1)
229 3 {
230 4 ShowTemp();
231 4 refreshTemp=0;
232 4 }
233 3 }
234 2
235 2 }//end while
236 1
237 1 }
238
239 Counter sortPeriod()
240 {
241 1 Counter c;
C51 COMPILER V7.50 MAIN 09/20/2008 15:21:11 PAGE 5
242 1 uchar i;
243 1 if(MeasureType==2)//use the biggest number at this range
244 1 {
245 2 c=periodCounters[0];
246 2 for(i=1;i<COUNTERS_LEN;i++)
247 2 {
248 3 if(c<periodCounters[i])
249 3 c=periodCounters[i];
250 3 }
251 2 }
252 1 else if(MeasureType==1)
253 1 c=periodCounters[2];
254 1
255 1 return c;
256 1
257 1 }
258
259
260 void AnalyzePeriod()//输入的周期以0.001微秒为单位,
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -