📄 lpc935.lst
字号:
C51 COMPILER V7.09 LPC935 03/14/2006 04:35:09 PAGE 1
C51 COMPILER V7.09, COMPILATION OF MODULE LPC935
OBJECT MODULE PLACED IN lpc935.OBJ
COMPILER INVOKED BY: C:\Keil\C51\BIN\C51.EXE lpc935.c LARGE OPTIMIZE(0,SPEED) BROWSE DEBUG OBJECTEXTEND
line level source
1 #include "reg935.h"
2 #define byte unsigned char
3 #define word unsigned int
4 #define ulong unsigned long
5 //#define TH0_DATA 0x6F // On Chip Oscillator (7.3728MHz ± 2.5%)10ms
6 //#define TL0_DATA 0xFF
7
8 #define TH0_DATA 0xFE // On Chip Oscillator (7.3728MHz ± 2.51001us
9 #define TL0_DATA 0x8F
10
11
12 #define true 1
13 #define false 0
14 #define High 1
15 #define Low 0
16
17 #define On 1
18 #define Off 0
19
20 // values passed to the comparator functions
21 #define COMP_1 0 // comparator 1
22 #define COMP_2 1 // comparator 2
23 #define COMP_INPUTA 0x00 // comparator input CINnA
24 #define COMP_INPUTB 0x10 // comparator input CINnB
25 #define COMP_INPUTREF 0x00 // reference voltage input CMPREF
26 #define COMP_INTERNALREF 0x08 // internal reference voltage Vref
27 #define COMP_OUTPUTDISABLE 0x00 // disable comparator output pin
28 #define COMP_OUTPUTENABLE 0x04 // enable comparator output pin
29
30
31 //*************************************
32 //定义通讯协议
33 #define RELAX_COMMAND 0xA0
34 #define LED_COMMAND 0xA1
35 #define PWM_COMMAND 0xA2
36 #define ADSMPL_COMMAND 0xA3
37 #define SOFT_RESET 0xA5
38 #define GET_COUNT 0xA6
39
40 //******** Time constant **************
41 #define _100us 1
42 #define _MS 10
43 #define _10MS 100
44 #define _20MS 200
45 #define _30MS 300
46 #define _50MS 500
47 #define _100MS 1000
48 #define _200MS 2000
49 #define _250MS 2500
50 #define _300MS 3000
51 #define _500MS 5000
52 #define _800MS 8000
53 #define _1S 10000
54 #define _2S 20000
55 #define _3S 30000
C51 COMPILER V7.09 LPC935 03/14/2006 04:35:09 PAGE 2
56 #define _4S 40000
57 #define _5S 50000
58 #define _6S 60000
59 #define _7S 70000
60 #define _8S 80000
61 #define _10S 100000
62 #define _20S 200000
63 #define _900S 900000
64
65 //State Machina
66 #define State_Start 0
67 #define State_Check_Start 1
68 #define State_Work 2
69
70
71 typedef struct COMMAND_D{
72 byte Command;
73 word Param1;
74 word Param2;
75 }MyCommand;
76
77
78 //******************************************
79 //引脚定义
80 sbit RELAX1=P2^1;
81 sbit RELAX2=P2^2;
82 sbit RELAX3=P2^3;
83 sbit RELAX4=P2^4;
84 sbit LED7=P2^5;
85 sbit LED8=P2^6;
86 sbit LED9=P2^7;
87 sbit PDA=P0^4;
88 sbit test_pin=P1^6;
89
90 //******************************************
91 //变量定义
92 bit Flag_100us=false;
93 bit Flag_10ms=false;
94 bit Flag_COM_Rec=false;
95 bit Flag_Second=false;
96 bit Flag_AD=false;
97 bit Flag_GetCounter=false;
98 bit Send_Counter=true;
99 //byte State=State_Start;
100 //byte COM_Rec_Buf[5];
101 byte data Rec_Idx=0;
102 word data RecWord=0;
103 word data RecTmp=0;
104 word data Temp_Word=0;
105 word data Send_Ms_Cnt=20000;
106 byte data Temp_Byte;
107 word data Cnt_100us=0;
108 word data Cnt_MS=0;
109 word data Snd_Time_Cnt=0; //MS
110
111 byte data Temp=0;
112 byte data Temp_TH=0;
113 /*
114 byte data ADC_Time=0;
115 byte data ADC_BAT0=0;
116 byte data ADC_BAT1=0;
117 byte data ADC_BAT2=0;
C51 COMPILER V7.09 LPC935 03/14/2006 04:35:09 PAGE 3
118 byte data ADC_BAT3=0;
119 */
120 byte data AD_Channel=0;
121
122 byte data Minute_Cnt=0;
123 byte data Second_Cnt=0;
124 byte data AD_Load=0;
125 byte data AD_Battery=0;
126 byte data AD_Current=0;
127
128 MyCommand xdata CMD;
129 MyCommand xdata tempCMD;
130 //******************************************
131 //函数定义
132 void Init_IO();
133 void RecData();
134 void UART_init();
135 void Relay_Reset();
136 void Relay_On(byte Relay);
137 void Relay_Off(byte Relay);
138 void timer0_init();
139 void Clear_Timer(void);
140 void Counter_init();
141 void Counter_int();
142 void Counter_start(void);
143 void Counter_stop(void);
144 void ADC_init();
145 void delayms(word ms);
146 void SIO_Out_Str(byte *pstr);
147 void SIO_Out_Hex(byte b);
148 void Do_ADConvert();
149 void delayus(word us);
150 void SIO_Out_Byte(byte b);
151 byte Check_Start(byte channel);
152 void Do_Start(byte channel);
153 void Send_AD_Result(void);
154 void Get_Count();
155 void comparators_init();
156 void comparators_disable
157 (
158 bit compnum // comparator number: COMP_1 or COMP_2
159 );
160 bit comparators_getoutput
161 (
162 bit compnum // comparator number: COMP_1 or COMP_2
163 );
164 void comparators_selectposinput
165 (
166 bit compnum, // comparator number: COMP_1 or COMP_2
167 unsigned char posinput // positive input A or B: COMP_INPUTA or COMP_INPUTB
168 );
169
170 void main()
171 {
172 1
173 1 // byte Temp_Byte;
174 1 EA=0;
175 1 Init_IO();
176 1 timer0_init();
177 1 Clear_Timer();
178 1 UART_init();
179 1 ADC_init();
C51 COMPILER V7.09 LPC935 03/14/2006 04:35:09 PAGE 4
180 1 CMD.Command=0x00;
181 1 CMD.Param1=0x0000;
182 1 CMD.Param2=0x0000;
183 1 EA=1;
184 1 /*while(1) //For Test
185 1 {
186 1 RELAX1=High;
187 1 RELAX2=High;
188 1 RELAX3=High;
189 1 RELAX4=High;
190 1 LED7=On;
191 1 LED8=On;
192 1 LED9=On;
193 1 delayms(2000);
194 1 RELAX1=Low;
195 1 RELAX2=Low;
196 1 RELAX3=Low;
197 1 RELAX4=Low;
198 1 LED7=Off;
199 1 LED8=Off;
200 1 LED9=Off;
201 1 delayms(2000);
202 1 }
203 1 */
204 1
205 1 // SIO_Out_Str("Welcom to Battery test world!\r\n");
206 1
207 1 /*while (1)
208 1 {
209 1 SBUF=0xAA;
210 1 while(!TI);
211 1 TI=0;
212 1 }*/
213 1
214 1 Second_Cnt=0;
215 1 RELAX1=High;
216 1 RELAX2=High;
217 1 RELAX3=High;
218 1 RELAX4=High;
219 1 LED7=On;
220 1 LED8=On;
221 1 LED9=On;
222 1 while(Second_Cnt<1);
223 1 Second_Cnt=0;
224 1 RELAX1=Low;
225 1 RELAX2=Low;
226 1 RELAX3=Low;
227 1 RELAX4=Low;
228 1 LED7=Off;
229 1 LED8=Off;
230 1 LED9=Off;
231 1
232 1 while (1)
233 1 {
234 2 /*if(Flag_COM_Rec)// FOR TEST
235 2 {
236 2 Second_Cnt=0;
237 2 Flag_COM_Rec=false;
238 2 LED7=Off;
239 2 SIO_Out_Byte(CMD.Command);
240 2 SIO_Out_Byte((byte)(CMD.Param1>>8));
241 2 SIO_Out_Byte((byte)CMD.Param1);
C51 COMPILER V7.09 LPC935 03/14/2006 04:35:09 PAGE 5
242 2 SIO_Out_Byte((byte)(CMD.Param2>>8));
243 2 SIO_Out_Byte((byte)CMD.Param2);
244 2
245 2 }*/
246 2 //Do_ADConvert();
247 2 if(Snd_Time_Cnt>=Send_Ms_Cnt&&Flag_AD)
248 2 {
249 3 Send_AD_Result();
250 3 /*SIO_Out_Byte((byte)(Send_Ms_Cnt>>8));
251 3 SIO_Out_Byte((byte)Send_Ms_Cnt);
252 3 SIO_Out_Byte((byte)(CMD.Param2>>8));
253 3 SIO_Out_Byte(0x0D);
254 3 SIO_Out_Byte(0x0A);*/
255 3 Snd_Time_Cnt=0;
256 3 }
257 2 if(Flag_GetCounter)
258 2 {
259 3 Flag_GetCounter=false;
260 3 Get_Count();
261 3 }
262 2
263 2 if (Flag_COM_Rec)
264 2 {
265 3 Flag_COM_Rec=false;
266 3 switch(CMD.Command)
267 3 {
268 4 case RELAX_COMMAND:
269 4
270 4 if(CMD.Param2==1)
271 4 {
272 5 switch(CMD.Param1)
273 5 {
274 6 case 1:
275 6 RELAX1=High;
276 6 break;
277 6 case 2:
278 6 RELAX2=High;
279 6 break;
280 6 case 3:
281 6 RELAX3=High;
282 6 break;
283 6 case 4:
284 6 RELAX4=High;
285 6 break;
286 6 }
287 5 }
288 4 else
289 4 {
290 5 switch(CMD.Param1)
291 5 {
292 6 case 1:
293 6 RELAX1=Low;
294 6 break;
295 6 case 2:
296 6 RELAX2=Low;
297 6 break;
298 6 case 3:
299 6 RELAX3=Low;
300 6 break;
301 6 case 4:
302 6 RELAX4=Low;
303 6 break;
C51 COMPILER V7.09 LPC935 03/14/2006 04:35:09 PAGE 6
304 6 }
305 5 }
306 4 break;
307 4 case LED_COMMAND:
308 4
309 4 if(CMD.Param2==1)
310 4 {
311 5 switch(CMD.Param1)
312 5 {
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -