📄 main.lst
字号:
223 1
224 1 RCAP2LH = RCAP2_1ms;
225 1 T2LH = RCAP2_1ms;
226 1 ET2 = 0; // Disable timer2 interrupt
227 1 T2CON = 0x04; // 16-bit auto-reload, clear TF2, start timer
228 1
229 1 while (_1ms--)
230 1 {
231 2 while (!TF2);
232 2 TF2 = FALSE;
233 2 }
234 1 TR2 = FALSE;
235 1
236 1 }
237
238
239 /****************************************************************************
240 * *
241 * Function: delay_10ms *
C51 COMPILER V7.20 MAIN 05/28/2007 14:55:19 PAGE 5
242 * *
243 * Input: _10ms *
244 * Output: - *
245 * *
246 * Description: *
247 * *
248 * Time delay with a resolution of 10 ms. *
249 * *
250 ****************************************************************************/
251
252 void delay_10ms (uint _10ms)
253 {
254 1
255 1 RCAP2LH = RCAP2_10ms;
256 1 T2LH = RCAP2_10ms;
257 1 ET2 = 0; // Disable timer2 interrupt
258 1 T2CON = 0x04; // 16-bit auto-reload, clear TF2, start timer
259 1
260 1 while (_10ms--)
261 1 {
262 2 while (!TF2); //查询方式
263 2 TF2 = FALSE;
264 2 }
265 1 TR2 = FALSE; //完成指定延时任务,收工
266 1
267 1 }
268
269 void F020Config(void)
270 {
271 1 int i; // delay counter
272 1 WDTCN = 0x07; // Watchdog Timer Control Register
273 1 WDTCN = 0xDE; // Disable WDT
274 1 WDTCN = 0xAD;
275 1
276 1 OSCXCN = 0x67; // start external oscillator with
277 1 // 22.1184MHz crystal
278 1
279 1 for (i=0; i < 256; i++) ; // XTLVLD blanking interval (>1ms)
280 1
281 1 while (!(OSCXCN & 0x80)) ; // Wait for crystal osc. to settle
282 1
283 1 OSCICN = 0x88; // select external oscillator as SYSCLK
284 1 // source and enable missing clock
285 1 // detector
286 1 XBR0 = 0x07;
287 1 XBR1 = 0x04;
288 1 XBR2 = 0x44;
289 1 P0MDOUT = 0x05; // Output configuration for P0
290 1 P1MDOUT = 0x00; // Output configuration for P1
291 1 P2MDOUT = 0x00; // Output configuration for P2
292 1 P3MDOUT = 0x00; // Output configuration for P3
293 1 P74OUT = 0x00; // Output configuration for P4-7
294 1
295 1 P1MDIN = 0xFF; // Input configuration for P1
296 1
297 1 // P0.0 - TX0 (UART0), Open-Drain, Digital
298 1 // P0.1 - RX0 (UART0), Open-Drain, Digital
299 1 // P0.2 - SCK (SPI0), Open-Drain, Digital
300 1 // P0.3 - MISO (SPI0), Open-Drain, Digital
301 1 // P0.4 - MOSI (SPI0), Open-Drain, Digital
302 1 // P0.5 - NSS (SPI0), Open-Drain, Digital
303 1 // P0.6 - SDA (SMBus), Open-Drain, Digital
C51 COMPILER V7.20 MAIN 05/28/2007 14:55:19 PAGE 6
304 1 // P0.7 - SCL (SMBus), Open-Drain, Digital
305 1
306 1 // P1.0 - TX1 (UART1), Open-Drain, Digital
307 1 // P1.1 - RX1 (UART1), Open-Drain, Digital
308 1 // P1.2 - INT0 (Tmr0), Open-Drain, Digital
309 1
310 1 }
311
312
313 void test(void)
314 {
315 1 uchar cnt;
316 1 uint iq0; //延时系数
317 1 LED=0;
318 1 for(cnt=2;cnt>0;cnt--)
319 1 {
320 2 for(iq0=0xFFFF;iq0>0x00;iq0--);
321 2 }
322 1 LED=1;
323 1 }
324 void Timer_4_init(void) //系统时钟的12分频
325 { //做UART1的波特率发生器
326 1 T4CON = 0x34;
327 1 RCAP4L = 0xFA; //波特率9600
328 1 RCAP4H = 0xFF;
329 1 SCON1=0x50; //串口二的工作方式
330 1 }
331
332 void Uart_1_send(uchar cnt)
333 {
334 1
335 1 uchar q0;
336 1 EIE2&=0xBF; //禁止串口
337 1 SCON1&=0xEF; //REN1=0;
338 1 for(q0=0;q0<cnt;q0++)
339 1 {
340 2 SBUF1=databuf[q0];
341 2 while((SCON1&0x02)!=0x02);
342 2 // SCON1&=0xFD; //TI1=0;
343 2 SCON1=0x40; //为了清除标志位
344 2 }
345 1
346 1 }
347
348 void Uart1_int(void) interrupt 20 //串口中断程序
349 {
350 1 SCON1&=0xEF; //REN1=0; REN1=0; //不要接收到重复的数据,等数据处理完了再处理
351 1 SCON1&=0xFE; //RI1=0; //清空接收中断标志
352 1 keyvalue=SBUF1;
353 1
354 1 keyv_pro(); //键值处
355 1 SCON1|=0x10; //REN1=1;
356 1 }
357
358 void keyv_pro(void)
359 {
360 1 uchar i,key;
361 1 for(i=0;i<23;i++)
362 1 {
363 2 if(KEY_CHECK[i]==keyvalue)
364 2 break;
365 2 };
C51 COMPILER V7.20 MAIN 05/28/2007 14:55:19 PAGE 7
366 1 if(i==24)
367 1 return;
368 1 key=KEY_MAP[i];
369 1 switch(key)
370 1 {
371 2 case 1:
372 2 case 2:
373 2 case 3:
374 2 case 4:
375 2 case 5:
376 2 case 6:
377 2 case 7:
378 2 case 8:
379 2 case 9:
380 2 case 0: KEY_number(key);
381 2 break;
382 2 case 'r': To_mifs_read();
383 2 break;
384 2 case 'w': To_mifs_write();
385 2 break;
386 2 case 'a': To_mifs_add();
387 2 break;
388 2 case 'm': To_mifs_minus();
389 2 break;
390 2 default: break;
391 2 }
392 1 }
393
394 key_number(uchar key)
395 {
396 1 num_key=key;
397 1 To_mifs_read();
398 1 Uart_1_send(4);
399 1 }
400
401 void To_mifs_read()
402 {
403 1 mifs_read(num_key, databuf);
404 1 }
405
406 void To_mifs_write()
407 {
408 1 mifs_write(num_key, databuf);
409 1 }
410
411 void To_mifs_add()
412 {
413 1 mifs_increment(adr1,*value);
*** WARNING C214 IN LINE 413 OF MAIN.C: 'Argument': conversion: non-pointer to pointer
414 1 //mifs_value(PICC_INCREMENT,adrfrom,&value,adrto);
415 1 }
416
417 void To_mifs_minus(void)
418 {
419 1 mifs_decrement(adr1,*value);
*** WARNING C214 IN LINE 419 OF MAIN.C: 'Argument': conversion: non-pointer to pointer
420 1
421 1 }
422 /* 以后做一定的扩展
423 void To_mifs_value(void)
424 {
425 mifs_value(_mode,adrfrom,&value,adrto);
C51 COMPILER V7.20 MAIN 05/28/2007 14:55:19 PAGE 8
426 }
427 */
428
429
430 #pragma aregs
431
432
433
434 /***************************************************************************/
MODULE INFORMATION: STATIC OVERLAYABLE
CODE SIZE = 678 ----
CONSTANT SIZE = 66 ----
XDATA SIZE = ---- ----
PDATA SIZE = ---- ----
DATA SIZE = 32 7
IDATA SIZE = ---- ----
BIT SIZE = ---- 1
END OF MODULE INFORMATION.
C51 COMPILATION COMPLETE. 2 WARNING(S), 0 ERROR(S)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -