📄 sky_main.lst
字号:
-g);
250 void HzDisplay(unsigned char *page_num, unsigned char page_y_in, unsigned char col_x_in,bit flag);
251 void Display_Line(unsigned char num, unsigned char page_y_in, unsigned char len,bit flag);
252 void Second_moudel(void);
253 void Display_Save(UINT8 row,UINT8 col);
254 void Timer0_Init(void);
255 void CPUInitial(void);
256 void Num_Display(UINT8 num, unsigned char page_y_in, unsigned char col_x_in,bit flag);
257 void SingleCmd(unsigned char c);
C51 COMPILER V6.14 SKY_MAIN 12/30/2004 22:34:59 PAGE 6
258 void SingleData(UINT8 col,unsigned char c);
259 void LcdWaitBusy(void);
260 void Contral8255(UINT8 num,bit flag);
261 void Beep1(UINT8 num);
262 void LedContral(UINT8 num,bit flag);
263 UINT8 KeyScan(void);
264 void ClearWatchDog(void);
265
266 sbit ISDA=P2^6;
267 sbit ISCL=P2^7;
268 sbit Led1=P1^2;
269 sbit Led2=P1^3;
270 sbit Led3=P1^4;
271 sbit Led4=P1^5;
272 sbit Led5=P1^6;
273 sbit Led6=P1^7;
274
275 bit EEPROMByteWrite0(UINT16 addr,UINT8 value);
276 UINT8 EEPROMByteRead0(UINT16 addr1);
277 void I2cSentByte();
278 void I2cStart(void);
279 void I2cStop(void);
280 extern void _nop_ (void);
281 data UINT8 c,BeepFlag=0;
282 bit ack;
283 bit Contralflag=0;
284 data UINT8 Luopencloseflag[15];
285 data UINT8 count1;
286 bit changflag=1;
287
288
289 bit EEPROMByteWrite0(UINT16 addr,UINT8 value)
290 {
291 1 I2cStart();
292 1 c=0xa0;
293 1 I2cSentByte();
294 1 if (ack==0)
295 1 return(0);
296 1 c=addr>>8;
297 1 I2cSentByte();
298 1 if (ack==0)
299 1 return(0);
300 1 c=addr;
301 1 I2cSentByte();
302 1 if (ack==0)
303 1 return(0);
304 1 c=value;
305 1 I2cSentByte();
306 1 if (ack==0)
307 1 return(0);
308 1 I2cStop();
309 1 Delay1(50);
310 1 return(1);
311 1 }
312
313 UINT8 EEPROMByteRead0(UINT16 addr1)
314 {
315 1 UINT8 bytedata,j;
316 1 I2cStart();
317 1 c=0xa0;
318 1 I2cSentByte();
319 1 if (ack==0)
C51 COMPILER V6.14 SKY_MAIN 12/30/2004 22:34:59 PAGE 7
320 1 return(0);
321 1 c=addr1>>8;
322 1 I2cSentByte();
323 1 if (ack==0)
324 1 return(0);
325 1 c=addr1;
326 1 I2cSentByte();
327 1 if (ack==0)
328 1 return(0);
329 1 I2cStart();
330 1 c=0xa1;
331 1 I2cSentByte();
332 1 if (ack==0)
333 1 return(0);
334 1 ISDA=1;
335 1 for (j=0;j<8;j++)
336 1 {
337 2 _nop_();
338 2 ISCL=0;
339 2 _nop_();
340 2 _nop_();
341 2 _nop_();
342 2 _nop_();
343 2 _nop_();
344 2 ISCL=1;
345 2 _nop_();
346 2 _nop_();
347 2 _nop_();
348 2 _nop_();
349 2 bytedata<<=1;
350 2 if (ISDA)
351 2 bytedata|=0x01;
352 2 _nop_();
353 2 _nop_();
354 2
355 2 }
356 1 ISCL=0;
357 1 _nop_();
358 1 _nop_();
359 1 _nop_();
360 1 _nop_();
361 1 ISCL=1;
362 1 I2cStop();
363 1 return (bytedata);
364 1 }
365
366 void I2cStart(void)
367 {
368 1 ISDA=1;
369 1 ISCL=1;
370 1 _nop_();
371 1 _nop_();
372 1 _nop_();
373 1 ISDA=0;
374 1 _nop_();
375 1 _nop_();
376 1 _nop_();
377 1 ISCL=0;
378 1 _nop_();
379 1 _nop_();
380 1 }
381
C51 COMPILER V6.14 SKY_MAIN 12/30/2004 22:34:59 PAGE 8
382 void I2cStop(void)
383 {
384 1 ISDA=0;
385 1 ISCL=1;
386 1 _nop_();
387 1 _nop_();
388 1 _nop_();
389 1 _nop_();
390 1 _nop_();
391 1 ISDA=1;
392 1 _nop_();
393 1 _nop_();
394 1 _nop_();
395 1 _nop_();
396 1 ISCL=0;
397 1 }
398
399 void I2cSentByte()
400 {
401 1 data UINT8 temp1,temp2;
402 1 for(temp1=0;temp1<8;temp1++)
403 1 {
404 2 temp2=c &0x80;
405 2 if(temp2==0x80)
406 2 ISDA=1;
407 2 else
408 2 ISDA=0;
409 2 c<<=1;
410 2 _nop_();
411 2 _nop_();
412 2 _nop_();
413 2 _nop_();
414 2 ISCL=1;
415 2 _nop_();
416 2 _nop_();
417 2 _nop_();
418 2 _nop_();
419 2 _nop_();
420 2 _nop_();
421 2 _nop_();
422 2 _nop_();
423 2 ISCL=0;
424 2 _nop_();
425 2 _nop_();
426 2 _nop_();
427 2 _nop_();
428 2 _nop_();
429 2 _nop_();
430 2 _nop_();
431 2 _nop_();
432 2
433 2 }
434 1 _nop_();
435 1 _nop_();
436 1 ISDA=1;
437 1 _nop_();
438 1 _nop_();
439 1 _nop_();
440 1 _nop_();
441 1 ISCL=1;
442 1 _nop_();
443 1 _nop_();
C51 COMPILER V6.14 SKY_MAIN 12/30/2004 22:34:59 PAGE 9
444 1 _nop_();
445 1 _nop_();
446 1 if(ISDA==1)
447 1 ack=0;
448 1 else
449 1 ack=1;
450 1 ISCL=0;
451 1 _nop_();
452 1 _nop_();
453 1 _nop_();
454 1 _nop_();
455 1 _nop_();
456 1
457 1 }
458 void InitLcd(void)
459 {
460 1 LCD_DATA = 0;
461 1 LCD_DI = 0;
462 1 LCD_RW = 0;
463 1 LCD_E = 0;
464 1 LCD_CS1 = 0;
465 1 LCD_CS2 = 0;
466 1 SingleCmd(DISPLAY_OFF); /* Display OFF */
467 1 SingleCmd(START_LINE);
468 1 SingleCmd(X_ADRESS);
469 1 SingleCmd(Y_ADRESS);
470 1 SingleCmd(DISPLAY_ON); /* Display ON */
471 1 }
472
473
474 /*-------------------------------------------------------------------------------
475 Send datas to the LCD
476 LcdDataWrite (U8 u8Data)
477 u8Data = data to send to the LCD
478 -------------------------------------------------------------------------------*/
479 void SingleData(UINT8 col,UINT8 c)
480 {
481 1 LCD_E=0;
482 1 LCD_DI=0;
483 1 LCD_RW=1;
484 1 if(col<64)
485 1 {
486 2 LCD_CS1=1;
487 2 }
488 1 else
489 1 {
490 2 LCD_CS2=1;
491 2 }
492 1 LcdWaitBusy(); /* wait until LCD not busy */
493 1 LCD_DI = 1; /* Data mode */
494 1 LCD_RW = 0; /* write mode */
495 1 LCD_DATA = c; /* outbyte */
496 1 Delay1(1);
497 1 LCD_E = 1; /* Strobe */
498 1 Delay1(2);
499 1 LCD_E = 0;
500 1 Delay1(3);
501 1 LCD_CS1=0;
502 1 LCD_CS2=0;
503 1 }
504
505 /*-------------------------------------------------------------------------------
C51 COMPILER V6.14 SKY_MAIN 12/30/2004 22:34:59 PAGE 10
506 Send instruction to the LCD
507 LcdDataWrite (U8 u8Instruction)
508 u8Instruction = Instructino to send to the LCD
509 -------------------------------------------------------------------------------*/
510 void SingleCmd(UINT8 c)
511 {
512 1 LCD_E=0;
513 1 LCD_DI=0;
514 1 LCD_RW=1;
515 1 LCD_CS1=1;
516 1 LCD_CS2=1;
517 1 LcdWaitBusy (); /* wait until LCD not busy */
518 1 LCD_DI = 0; /* Instruction mode */
519 1 LCD_RW = 0; /* Write mode */
520 1 LCD_E = 1; /* Strobe */
521 1 Delay1(2);
522 1 LCD_DATA = c;/* outbyte */
523 1 Delay1(3);
524 1 LCD_E = 0;
525 1 Delay1(5);
526 1 LCD_CS1=0;
527 1 LCD_CS2=0;
528 1 }
529
530 void LcdWaitBusy (void)
531 {
532 1 LCD_DATA=0xFF; /* set LCD_DATA port in input mode */
533 1
534 1 LCD_DI = 0; /* Instruction mode */
535 1 LCD_RW = 1; /* Read mode */
536 1 LCD_E = 1; /* strobe */
537 1 Delay1(1);
538 1 LCD_E = 0;
539 1 while ( LCD_DATA & 0x7f == 0x80); /* mask the other status bits and test the BUSY bit */
540 1 }
541
542 void clearRAM(UINT8 startp,UINT8 endp)
543 {
544 1 data UINT8 u8Page,u8Column;
545 1
546 1 for (u8Page = startp; u8Page < endp; u8Page++)
547 1 {
548 2 SetRAMAddr(u8Page,0x00);
549 2 for (u8Column = 0; u8Column < 128; u8Column++)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -