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

📄 text1.lst

📁 用于单片机驱动LCD1602显示
💻 LST
字号:
C51 COMPILER V8.05a   TEXT1                                                                05/18/2009 14:43:44 PAGE 1   


C51 COMPILER V8.05a, COMPILATION OF MODULE TEXT1
OBJECT MODULE PLACED IN Text1.OBJ
COMPILER INVOKED BY: C:\Keil\C51\BIN\C51.EXE Text1.c BROWSE DEBUG OBJECTEXTEND

line level    source

   1          #include <reg51.h> 
   2          #include <absacc.h> 
   3          #include <stdio.h>
   4          #define LCD_EN_PORT     PORTC 
   5          #define LCD_RW_PORT     PORTC 
   6          #define LCD_RS_PORT     PORTC 
   7          #define LCD_DATA_PORT   PORTA 
   8          #define LCD_DATA_DDR    DDRA 
   9          #define LCD_DATA_PIN    PINA 
  10          
  11          //LCD的 r/w 脚直接接 GND 
  12          #define LCD_EN          0x80    //portd7         out 
  13          #define LCD_RS          0x40    //portc6         out 
  14          #define LCD_DATA        0xF0    //porta 4/5/6/7    out 
  15          
  16          /*-------------------------------------------------------------------------------------------------- 
  17          Public function prototypes 
  18          --------------------------------------------------------------------------------------------------*/ 
  19          void LCD_init          (void); 
  20          void LCD_en_write      (void); 
  21          void LCD_write_char    (unsigned command,unsigned ddata); 
  22          void LCD_set_xy        (unsigned char x, unsigned char y); 
  23          void LCD_write_string (unsigned char X,unsigned char Y,unsigned char *s); 
  24          void delay_nus         (unsigned int n); 
  25          void delay_nms         (unsigned int n); 
  26          
  27          
  28          void LCD_init(void)        //液晶初始化 
  29          { 
  30   1      delay_nms(15); 
  31   1      DDRA |= LCD_DATA;    // 数据为输出 
*** ERROR C202 IN LINE 31 OF TEXT1.C: 'DDRA': undefined identifier
  32   1      DDRC |= LCD_RS | LCD_EN;   //置位RS.EN 
*** ERROR C202 IN LINE 32 OF TEXT1.C: 'DDRC': undefined identifier
  33   1      
  34   1      LCD_write_char(0x28,0);   //4位显示 
  35   1      LCD_write_char(0x0c,0);   //显示开 
  36   1      LCD_write_char(0x01,0);   //清屏 
  37   1      
  38   1      delay_nms(60); 
  39   1      } 
  40          
  41          void LCD_write_string(unsigned char X,unsigned char Y,unsigned char *s) 
  42          { 
  43   1      LCD_set_xy( X, Y ); //写地址 
  44   1          
  45   1      while (*s) { 
  46   2           LCD_write_char( 0, *s ); 
  47   2          s ++; 
  48   2      } 
  49   1      } 
  50             
  51          void LCD_set_xy( unsigned char x, unsigned char y )   //写地址函数 
  52          { 
  53   1      unsigned char address; 
C51 COMPILER V8.05a   TEXT1                                                                05/18/2009 14:43:44 PAGE 2   

  54   1      
  55   1      if (y == 0) 
  56   1          address = 0x80 + x; 
  57   1      else 
  58   1          address = 0xc0 + x; 
  59   1             
  60   1      LCD_write_char(address, 0 ); 
  61   1      } 
  62          
  63          void LCD_en_write(void)   //液晶使能 
  64          { 
  65   1         LCD_EN_PORT |= LCD_EN; 
*** ERROR C202 IN LINE 65 OF TEXT1.C: 'PORTC': undefined identifier
  66   1         delay_nus(1); 
  67   1         LCD_EN_PORT &= ~LCD_EN; 
*** ERROR C202 IN LINE 67 OF TEXT1.C: 'PORTC': undefined identifier
  68   1      } 
  69          void LCD_write_char(unsigned command,unsigned ddata)// 写数据 
  70          { 
  71   1      unsigned command_temp,data_temp; 
  72   1      
  73   1      command_temp = command; 
  74   1      data_temp = ddata; 
  75   1      delay_nus(16); 
  76   1      
  77   1      if(command == 0) { 
  78   2          LCD_RS_PORT |= LCD_RS;   //RS=1 
*** ERROR C202 IN LINE 78 OF TEXT1.C: 'PORTC': undefined identifier
  79   2          LCD_DATA_PORT &= 0X0f; 
*** ERROR C202 IN LINE 79 OF TEXT1.C: 'PORTA': undefined identifier
  80   2          LCD_DATA_PORT |= data_temp & 0xf0;   //写高四位 
*** ERROR C202 IN LINE 80 OF TEXT1.C: 'PORTA': undefined identifier
  81   2          
  82   2          LCD_en_write(); 
  83   2          
  84   2          data_temp = data_temp << 4;   
  85   2          LCD_DATA_PORT &= 0X0f; 
*** ERROR C202 IN LINE 85 OF TEXT1.C: 'PORTA': undefined identifier
  86   2          LCD_DATA_PORT |= data_temp & 0xF0;    //写低四位 
*** ERROR C202 IN LINE 86 OF TEXT1.C: 'PORTA': undefined identifier
  87   2          
  88   2          LCD_en_write(); 
  89   2      } 
  90   1      else { 
  91   2          LCD_RS_PORT &= ~LCD_RS;    //RS=0 
*** ERROR C202 IN LINE 91 OF TEXT1.C: 'PORTC': undefined identifier
  92   2          LCD_DATA_PORT &= 0X0f; 
*** ERROR C202 IN LINE 92 OF TEXT1.C: 'PORTA': undefined identifier
  93   2          LCD_DATA_PORT |= command_temp & 0xF0; //写高四位 
*** ERROR C202 IN LINE 93 OF TEXT1.C: 'PORTA': undefined identifier
  94   2          
  95   2          LCD_en_write(); 
  96   2          
  97   2          command_temp = command_temp << 4; 
  98   2          LCD_DATA_PORT &= 0x0F; 
*** ERROR C202 IN LINE 98 OF TEXT1.C: 'PORTA': undefined identifier
  99   2          LCD_DATA_PORT |= command_temp & 0xF0;   //写低四位 
*** ERROR C202 IN LINE 99 OF TEXT1.C: 'PORTA': undefined identifier
 100   2          
 101   2          LCD_en_write(); 
 102   2         } 
 103   1      } 
C51 COMPILER V8.05a   TEXT1                                                                05/18/2009 14:43:44 PAGE 3   

 104          
 105          
 106          
 107          int main(void) 
 108          { 
 109   1      
 110   1      LCD_init(); 
 111   1      
 112   1      LCD_write_string(0,0,"Hello,AVR WORLD!!!"); 
 113   1      LCD_write_string(0,1,"hitro@tom.com"); 
 114   1      
 115   1      while(1); 
 116   1      
 117   1      } 
 118              /*----------------------------------------------------------------------- 
 119          延时函数 
 120          系统时钟:8M 
 121          -----------------------------------------------------------------------*/ 
 122          void delay_1us(void)                  //1us延时函数 
 123             { 
 124   1          asm("nop"); 
 125   1         } 
 126          
 127          void delay_nus(unsigned int n)        //N us延时函数 
 128             { 
 129   1          unsigned int i=0; 
 130   1          for (i=0;i<n;i++) 
 131   1          delay_1us(); 
 132   1         } 
 133             
 134          void delay_1ms(void)                  //1ms延时函数 
 135             { 
 136   1          unsigned int i; 
 137   1          for (i=0;i<1356;i++); 
 138   1         } 
 139             
 140          void delay_nms(unsigned int n)        //N ms延时函数 
 141             { 
 142   1          unsigned int i=0; 
 143   1          for (i=0;i<n;i++) 
 144   1          delay_1ms(); 
 145   1         } 

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

⌨️ 快捷键说明

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