📄 lcd.lst
字号:
465 1 cur_x += 2;
466 1 if(cur_x == 8) LCD_clr();
467 1 else
468 1 {
469 2 cur_y = LCD_Y_DISP_STA_PIX;
470 2 cur_ic = LCD_IC1;
471 2
472 2 set_pg_addr(cur_x,LCD_IC1);
473 2 set_y_addr(cur_y,LCD_IC1);
474 2 }
475 1 }
476
477 /*
478 ********************************************************************************
479 * Function Name : clr_eol
480 * Description : clear to end of line
481 * Parameter : none
482 * Return : none
483 ********************************************************************************
484 */
485 static void clr_eol(void)
486 {
487 1 unsigned char i;
488 1
C51 COMPILER V8.02 LCD 05/08/2008 13:16:16 PAGE 9
489 1 if(cur_ic == LCD_IC1)
490 1 {
491 2 for(i = 0;i < (64 - cur_y);i++) wr_dat(0x00,cur_ic);
492 2
493 2 set_pg_addr(cur_x + 1,cur_ic);
494 2 set_y_addr(cur_y,cur_ic);
495 2
496 2 for(i = 0;i < (64 - cur_y);i++) wr_dat(0x00,cur_ic);
497 2
498 2 cur_y = 64;
499 2 cur_ic = LCD_IC2;
500 2 }
501 1 set_pg_addr(cur_x,cur_ic);
502 1 set_y_addr(cur_y & 0xBF,cur_ic);
503 1
504 1 for(i = 0;i < (LCD_Y_DISP_STP_PIX - cur_y);i++) wr_dat(0x00,cur_ic);
505 1
506 1 set_pg_addr(cur_x + 1,cur_ic);
507 1 set_y_addr(cur_y & 0xBF,cur_ic);
508 1
509 1 for(i = 0;i < (LCD_Y_DISP_STP_PIX - cur_y);i++) wr_dat(0x00,cur_ic);
510 1
511 1 cur_y = LCD_Y_DISP_STP_PIX;
512 1 }
513
514 /*
515 ********************************************************************************
516 * Function Name : disp_logo
517 * Description : display Ambition Tech Comm Ltd.Co logo
518 * Parameter : none
519 * Return : none
520 ********************************************************************************
521 */
522 /*static void disp_logo(void)
523 {
524 unsigned char i;
525
526 cur_y = 0;
527 set_y_addr(cur_y,cur_ic);
528
529 for(i = 0;i < 32;i += 2)
530 {
531 wr_dat(logo[i],cur_ic);
532 cur_y ++;
533 }
534
535 cur_y -= 16;
536 set_pg_addr(cur_x + 1,cur_ic);
537 set_y_addr(cur_y,cur_ic);
538
539 for(i = 0;i < 32;i += 2)
540 {
541 wr_dat(logo[i + 1],cur_ic);
542 cur_y ++;
543 }
544
545 set_pg_addr(cur_x,cur_ic);
546 }*/
547
548 /*
549 ********************************************************************************
550 * Function Name : disp_cur
C51 COMPILER V8.02 LCD 05/08/2008 13:16:16 PAGE 10
551 * Description : display cursor at last of character
552 * Parameter : none
553 * Return : none
554 ********************************************************************************
555 */
556 /*static void disp_cur(void)
557 {
558 unsigned char i;
559 set_pg_addr(cur_x + 1,cur_ic);
560 for(i = 0;i < LCD_FONT_WIDTH;i ++) wr_dat(0x80,cur_ic);
561 set_pg_addr(cur_x,cur_ic);
562 set_y_addr(cur_y,cur_ic);
563 }*/
564
565 /*
566 ********************************************************************************
567 * Function Name : wt_rdy
568 * Description : wait specified chip ready
569 * Parameter : cs, bit type, sepecify which chip is to write.
570 * can be set LCD_IC1 or LCD_IC2, other value is not permitted.
571 * Return : none
572 ********************************************************************************
573 */
574 static void wt_rdy(bit cs)
575 {
576 1 while(rd_inst(cs) & 0x80); /* BF is bit7 of status register, 1 busy */
577 1 }
578
579 /*
580 ********************************************************************************
581 * Function Name : wr_dat
582 * Description : write one byte data to specified chip of LCD
583 * Parameter : dat, unsigned char type, data will be written.
584 * cs, bit type, sepecify which chip is to write.
585 * can be set LCD_IC1 or LCD_IC2, other value is not permitted.
586 * Return : none
587 ********************************************************************************
588 */
589 static void wr_dat(unsigned char dat,bit cs)
590 {
591 1 unsigned char i;
592 1
593 1 LCD_E = 0; /* E period time 1000ns(min) */
594 1 LCD_RW = 0; /* set to write operation */
595 1 LCD_DI = 1; /* write data */
596 1 if(cs == LCD_IC1) LCD_CS1 = 1; /* select chip to operate */
597 1 else LCD_CS2 = 1;
598 1 for(i = 0;i < 25;i++); /* address setup time 140ns(min) */
599 1 /* E low level period 450ns(min) */
600 1 LCD_E = 1;
601 1 LCD_DAT = dat;
602 1 for(i = 0;i < 25;i++); /* data setup time 200ns(min) */
603 1 /* E high level period 450ns(min) */
604 1 LCD_E = 0; /* E fall edge latch the data into DR */
605 1 /* address hold time 10ns(min) */
606 1 /* data hold time 20ns(min) */
607 1 if(cs == LCD_IC1) LCD_CS1 = 0; /* deselect chip */
608 1 else LCD_CS2 = 0;
609 1
610 1 for(i = 0;i < 15;i++);
611 1 }
612
C51 COMPILER V8.02 LCD 05/08/2008 13:16:16 PAGE 11
613 /*
614 ********************************************************************************
615 * Function Name : wr_inst
616 * Description : write one byte instruction to specified chip of LCD
617 * Parameter : inst, unsigned char type, instruction will be written.
618 * cs, bit type, sepecify which chip is to write.
619 * can be set LCD_IC1 or LCD_IC2, other value is not permitted.
620 * Return : none
621 ********************************************************************************
622 */
623 static void wr_inst(unsigned char inst,bit cs)
624 {
625 1 unsigned char i;
626 1
627 1 LCD_E = 0; /* E period time 1000ns(min) */
628 1 LCD_RW = 0; /* set to write operation */
629 1 LCD_DI = 0; /* write instruction */
630 1 if(cs == LCD_IC1) LCD_CS1 = 1; /* select chip to operate */
631 1 else LCD_CS2 = 1;
632 1 for(i = 0;i < 25;i++); /* address setup time 140ns(min) */
633 1 /* E low level period 450ns(min) */
634 1 LCD_E = 1;
635 1 LCD_DAT = inst;
636 1 for(i = 0;i < 25;i++); /* data setup time 200ns(min) */
637 1 /* E high level period 450ns(min) */
638 1 LCD_E = 0; /* E fall edge latch the instruction into IR*/
639 1 /* address hold time 10ns(min) */
640 1 /* data hold time 20ns(min) */
641 1 if(cs == LCD_IC1) LCD_CS1 = 0; /* deselect chip */
642 1 else LCD_CS2 = 0;
643 1
644 1 for(i = 0;i < 15;i++);
645 1 }
646
647 /*
648 ********************************************************************************
649 * Function Name : rd_inst
650 * Description : read one byte instruction from specified chip of LCD
651 * Parameter : cs, bit type, sepecify which chip is to write.
652 * can be set LCD_IC1 or LCD_IC2, other value is not permitted.
653 * Return : unsigned char type, status register value will be returned.
654 ********************************************************************************
655 */
656 static unsigned char rd_inst(bit cs)
657 {
658 1 unsigned char i,inst;
659 1
660 1 P4MDOUT = 0x00; /* set LCD data port open-drain output */
661 1 LCD_DAT = 0xFF; /* set LCD data port input */
662 1
663 1 LCD_E = 0; /* E period time 1000ns(min) */
664 1 LCD_RW = 1; /* set to read operation */
665 1 LCD_DI = 0; /* read instruction */
666 1 if(cs == LCD_IC1) LCD_CS1 = 1; /* select chip to operate */
667 1 else LCD_CS2 = 1;
668 1 for(i = 0;i < 25;i++); /* address setup time 140ns(min) */
669 1 /* E low level period 450ns(min) */
670 1 LCD_E = 1;
671 1 for(i = 0;i < 40;i++); /* data delay time 320ns(max) */
672 1 /* E high level period 450ns(min) */
673 1 inst = LCD_DAT; /* read data when E is high */
674 1 LCD_E = 0; /* address hold time 10ns(min) */
C51 COMPILER V8.02 LCD 05/08/2008 13:16:16 PAGE 12
675 1 /* data hold time 20ns(min) */
676 1 if(cs == LCD_IC1) LCD_CS1 = 0; /* deselect chip */
677 1 else LCD_CS2 = 0;
678 1
679 1 P4MDOUT = 0xFF; /* set LCD data port push-pull output */
680 1
681 1 for(i = 0;i < 15;i++);
682 1
683 1 return inst;
684 1 }
MODULE INFORMATION: STATIC OVERLAYABLE
CODE SIZE = 1500 ----
CONSTANT SIZE = 32 ----
XDATA SIZE = 3 56
PDATA SIZE = ---- ----
DATA SIZE = ---- ----
IDATA SIZE = ---- ----
BIT SIZE = 1 10
END OF MODULE INFORMATION.
C51 COMPILATION COMPLETE. 0 WARNING(S), 0 ERROR(S)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -