⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 lcd.lst

📁 Code C Serial with AT89s52
💻 LST
字号:
C51 COMPILER V7.06   LCD                                                                   02/12/2009 10:21:01 PAGE 1   


C51 COMPILER V7.06, COMPILATION OF MODULE LCD
OBJECT MODULE PLACED IN lcd.OBJ
COMPILER INVOKED BY: C:\Keil\C51\BIN\C51.EXE lcd.c BROWSE DEBUG OBJECTEXTEND

stmt level    source

   1          #include "AT89X52.H"
   2          #include "LCD.h"
   3          
   4          #define LCD_DELAY 30  //CHU Y KHONG DC DE LCD_delay re nham voi han LCD_delay
   5          #define LCD_en  P0_3
   6          #define LCD_rs  P0_2
   7          
   8          
   9          void delayms2(unsigned char time)
  10          {
  11   1              unsigned int j;
  12   1              unsigned char i;
  13   1              for (i=0;i<time;i++)
  14   1                      for (j=0;j<1200;j++);
  15   1      }
  16          //Ham tre cho LCD
  17          void LCD_delay()
  18          {
  19   1              unsigned char n;
  20   1              for(n=0;n<LCD_DELAY;n++);    
  21   1      }
  22          
  23          //Ham cho phep hien thi len LCD
  24          void LCD_enable()
  25          {
  26   1              LCD_en = 0;
  27   1          LCD_delay();
  28   1          LCD_en = 1; 
  29   1          LCD_delay();
  30   1              LCD_en = 0;
  31   1      }
  32          
  33          //ham xoa man hinh
  34          void LCD_clr()
  35          {
  36   1              LCD_command(0x01);
  37   1              delayms2(5);
  38   1      }
  39          
  40          //ham dua lenh len lcd
  41          void LCD_command(unsigned char command)
  42          {
  43   1          LCD_rs = 0;
  44   1          P0 = (P0 & 0x0F)|((command) & 0xF0);// P0 = (P0 & 0xF0)|((command>>4) & 0x0F);
  45   1          LCD_enable();
  46   1          P0 = (P0 & 0x0F)|(command<<4 & 0xF0);//P0 = (P0 & 0xF0)|(command & 0x0F);
  47   1          LCD_enable();
  48   1          LCD_delay();
  49   1      }
  50          
  51          //Ham viet ky tu len lcd
  52          void LCD_putc(unsigned char ascii)
  53          {
  54   1          LCD_rs = 1;
  55   1          P0 = (P0 & 0x0F)|((ascii) & 0xF0);//P0 = (P0 & 0xF0)|((ascii>>4) & 0x0F);
C51 COMPILER V7.06   LCD                                                                   02/12/2009 10:21:01 PAGE 2   

  56   1          LCD_enable();
  57   1          P0 = (P0 & 0x0F)|(ascii<<4 & 0xF0);//P0 = (P0 & 0xF0)|(ascii & 0x0F);
  58   1          LCD_enable();
  59   1          LCD_delay();
  60   1      }
  61          
  62          //Ham viet xau ky tu len lcd
  63          void LCD_puts(unsigned char *lcd_string)
  64          {
  65   1              while (*lcd_string) 
  66   1              {
  67   2                      LCD_putc(*lcd_string++);
  68   2              }
  69   1      }
  70          
  71          //Ham khoi tao LCD
  72          void LCD_init()
  73          {
  74   1          LCD_command(0x28);  //dung 4 duong du lieu,hien thi 2 dong do phan giai 5x7
  75   1              delayms2(1);
  76   1          LCD_command(0x0C);  //che do hien thi ko gach chan,con tro ko nhap nhay 
  77   1              delayms2(1);
  78   1          LCD_command(0x06);
  79   1              delayms2(1);
  80   1          LCD_command(0x01);   //Lenh xoa man hinh
  81   1              delayms2(1);
  82   1      }
  83          
  84          //Ham dat con tro LCD vao vi tri mong muon
  85          void LCD_row(unsigned char hang,unsigned char cot)
  86          { 
  87   1          char hangcot=0;
  88   1              if(hang==1)
  89   1              {
  90   2                      hangcot=0x80|cot;       
  91   2                      LCD_command(hangcot);
  92   2              }
  93   1              if(hang==2)
  94   1              {
  95   2                      hangcot=0xc0|cot;
  96   2                  LCD_command(hangcot);
  97   2              }
  98   1      }
  99          //ham hien thi mot so  integer len lcd
 100          /*void display_int(int number)
 101          {
 102                  int n1,n2,n3,n4,n22,n11;
 103                  n1=number/1000;         //chia lay phan nguyen
 104                  n11=number%1000;    //chhia lay phan du
 105          
 106                  n2=n11/100;
 107                  n22=n11%100;    
 108          
 109                  n3=n22/10;
 110          
 111                  n4=n22%10;
 112          
 113                  if((n1==0)&&(n2==0)&&(n3==0))
 114                          LCD_putc(n4+48);
 115                  else if((n1==0)&&(n2==0))
 116                  {
 117                          LCD_putc(n3+48);    //n3+48 la chuyen tu so n2 thanh ky tu so n2
C51 COMPILER V7.06   LCD                                                                   02/12/2009 10:21:01 PAGE 3   

 118                          LCD_putc(n4+48);
 119                  }
 120                  else if(n1==0)
 121                  {
 122                      LCD_putc(n2+48);
 123                          LCD_putc(n3+48);
 124                          LCD_putc(n4+48);
 125                  }
 126                  else
 127                  {
 128                          LCD_putc(n1+48);
 129                          LCD_putc(n2+48);
 130                          LCD_putc(n3+48);
 131                          LCD_putc(n4+48);
 132                  }
 133          
 134          }*/
 135          
 136          //ham hien thi mot so  integer len lcd
 137          void display_int(int number)
 138          {
 139   1              int n1,n2;
 140   1              n1=number/10;         //chia lay phan nguyen
 141   1              n2=number%10;    //chhia lay phan du
 142   1      
 143   1                      LCD_putc(n1+48);
 144   1                      LCD_putc(n2+48);
 145   1      
 146   1      }


MODULE INFORMATION:   STATIC OVERLAYABLE
   CODE SIZE        =    230    ----
   CONSTANT SIZE    =   ----    ----
   XDATA SIZE       =   ----    ----
   PDATA SIZE       =   ----    ----
   DATA SIZE        =   ----       3
   IDATA SIZE       =   ----    ----
   BIT SIZE         =   ----    ----
END OF MODULE INFORMATION.


C51 COMPILATION COMPLETE.  0 WARNING(S),  0 ERROR(S)

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -