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

📄 1602c.lst

📁 是时钟与温度传感器的例子
💻 LST
字号:
C51 COMPILER V7.20   1602C                                                                 05/13/2007 18:18:43 PAGE 1   


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

line level    source

   1          //采用单独口线方式驱动液晶
   2          #include <AT89X51.H>
*** WARNING C318 IN LINE 2 OF 1602C.c: can't open file 'AT89X51.H'
   3          #include <ABSACC.H>
   4          #include <INTRINS.H>
   5          #include "DS1302.H"
*** ERROR C202 IN LINE 18 OF DS1302.H: 'P1': undefined identifier
*** ERROR C202 IN LINE 19 OF DS1302.H: 'P1': undefined identifier
*** ERROR C202 IN LINE 20 OF DS1302.H: 'P1': undefined identifier
*** ERROR C202 IN LINE 21 OF DS1302.H: 'ACC': undefined identifier
*** ERROR C202 IN LINE 22 OF DS1302.H: 'ACC': undefined identifier
*** ERROR C202 IN LINE 51 OF DS1302.H: 'ACC': undefined identifier
*** ERROR C202 IN LINE 54 OF DS1302.H: 'DS1302_IO': undefined identifier
*** ERROR C202 IN LINE 55 OF DS1302.H: 'DS1302_CLK': undefined identifier
*** ERROR C202 IN LINE 56 OF DS1302.H: 'DS1302_CLK': undefined identifier
*** ERROR C202 IN LINE 57 OF DS1302.H: 'ACC': undefined identifier
*** ERROR C202 IN LINE 66 OF DS1302.H: 'ACC': undefined identifier
*** ERROR C202 IN LINE 67 OF DS1302.H: 'ACC7': undefined identifier
*** ERROR C202 IN LINE 68 OF DS1302.H: 'DS1302_CLK': undefined identifier
*** ERROR C202 IN LINE 69 OF DS1302.H: 'DS1302_CLK': undefined identifier
*** ERROR C202 IN LINE 71 OF DS1302.H: 'ACC': undefined identifier
*** ERROR C202 IN LINE 76 OF DS1302.H: 'DS1302_RST': undefined identifier
*** ERROR C202 IN LINE 77 OF DS1302.H: 'DS1302_CLK': undefined identifier
*** ERROR C202 IN LINE 78 OF DS1302.H: 'DS1302_RST': undefined identifier
*** ERROR C202 IN LINE 81 OF DS1302.H: 'DS1302_CLK': undefined identifier
*** ERROR C202 IN LINE 82 OF DS1302.H: 'DS1302_RST': undefined identifier
*** ERROR C202 IN LINE 88 OF DS1302.H: 'DS1302_RST': undefined identifier
*** ERROR C202 IN LINE 89 OF DS1302.H: 'DS1302_CLK': undefined identifier
*** ERROR C202 IN LINE 90 OF DS1302.H: 'DS1302_RST': undefined identifier
*** ERROR C202 IN LINE 93 OF DS1302.H: 'DS1302_CLK': undefined identifier
*** ERROR C202 IN LINE 94 OF DS1302.H: 'DS1302_RST': undefined identifier
   6          
   7          
   8          #define lcd_data_port P0
   9          #define lcd_RS  P2_0    
  10          #define lcd_RW  P2_1    
  11          #define lcd_E   P2_2            
  12          #define busy P0_7
  13          
  14          //extern void Get_temperarue(void);
  15          //extern uchar DataH,DataL;
  16          //xtern unsigned long Data;//ds18b20数据
  17          unsigned char TempBuffer[6];
  18          
  19          
  20          
  21          /*----------------------------------函数声明------------------------------------------*/
  22          void lcd_init(void);
  23          void lcd_write_command(unsigned char command,unsigned char wait_en);
  24          void lcd_write_data(unsigned char char_data);
  25          void wait_enable(void);
  26          void display_a_char(unsigned char position,unsigned char char_data);
  27          void display_a_string(unsigned char col,unsigned char *ptr);
  28          void delay_1ms(void);
  29          void delay_nms(unsigned int n);
C51 COMPILER V7.20   1602C                                                                 05/13/2007 18:18:43 PAGE 2   

  30          void initial(void);
  31          void IntToStr(unsigned int t, unsigned char *str);
  32          ReadTemperature(void);
  33          //显示的字符串
  34          unsigned char str1[]="D tebnucee wendu";
  35          unsigned char str2[]="T mehongfe     ";
  36          
  37          //unsigned char str1[]="-----@good@-----";
  38          //unsigned char str2[]="--  wangshu  ---";
  39          //unsigned char count=0;
  40          
  41          /*------------------------------------主函数-------------------------------------------*/
  42          void main(void)
  43          {  
  44   1                unsigned int i,a;  
  45   1               SYSTEMTIME CurrentTime;
  46   1           //P2=0x00;
  47   1               //delay_nms(100);
  48   1           lcd_init();       //液晶初始化
  49   1               Initial_DS1302();//启动时钟芯片
  50   1               
  51   1               
  52   1      // display_a_char(5,'d');       //该函数显示单个字符,5表示显示的位置(0-31)
  53   1      
  54   1      
  55   1        //do
  56   1         for(;;)
  57   1         {    
  58   2      
  59   2             
  60   2              i=ReadTemperature(); //读温度
  61   2              a=i;
  62   2      
  63   2              IntToStr(i,TempBuffer);
  64   2      
  65   2              //Get_temperarue();
  66   2              DS1302_GetTime(&CurrentTime);
  67   2                      DateToStr(&CurrentTime);
  68   2                      TimeToStr(&CurrentTime);
  69   2                      str1[2]=CurrentTime.DateString[0];
  70   2              str1[3]=CurrentTime.DateString[1];
  71   2              str1[4]=CurrentTime.DateString[2];
  72   2                  str1[5]=CurrentTime.DateString[3];
  73   2              str1[6]=CurrentTime.DateString[4];
  74   2              str1[7]=CurrentTime.DateString[5];
  75   2                      str1[8]=CurrentTime.DateString[6];
  76   2              str1[9]=CurrentTime.DateString[7];
  77   2      
  78   2                      
  79   2      
  80   2      
  81   2                  str2[2]=CurrentTime.TimeString[0];
  82   2              str2[3]=CurrentTime.TimeString[1];
  83   2              str2[4]=CurrentTime.TimeString[2];
  84   2                  str2[5]=CurrentTime.TimeString[3];
  85   2              str2[6]=CurrentTime.TimeString[4];
  86   2              str2[7]=CurrentTime.TimeString[5];
  87   2                      str2[8]=CurrentTime.TimeString[6];
  88   2              str2[9]=CurrentTime.TimeString[7];
  89   2                      //str2[13]=Data/100+48;
  90   2              //str2[14]=(Data%100)/10+48;
  91   2              //str2[15]=(Data%100)%10+48;
C51 COMPILER V7.20   1602C                                                                 05/13/2007 18:18:43 PAGE 3   

  92   2      
  93   2                      str2[11]=TempBuffer[0];
  94   2              str2[12]=TempBuffer[1];
  95   2              str2[13]=TempBuffer[2];
  96   2                      str2[14]=TempBuffer[3]; 
  97   2                      str2[15]=TempBuffer[4]; 
  98   2                  display_a_string(0,str1);   //0表示显示在第一行
  99   2              display_a_string(1,str2);//1表示显示在第二行
 100   2                  delay_nms(1000);
 101   2                      //while(1);
 102   2        }
 103   1             //while(1)       ;
 104   1             //P0=0xff;
 105   1      
 106   1      }
 107           
 108          /*------------------------------------液晶驱动函数-------------------------------------*/
 109          //液晶初始化
 110          void lcd_init(void)
 111          {lcd_write_command(0x38,0);//显示模式设置三次(此时不管lcd空闲与否)
 112   1       delay_nms(5);
 113   1       lcd_write_command(0x38,0);
 114   1       delay_nms(5);
 115   1       lcd_write_command(0x38,0);
 116   1       delay_nms(5);
 117   1       
 118   1       lcd_write_command(0x38,1);//显示模式设置(从此之后均需lcd空闲)
 119   1       lcd_write_command(0x08,1);//显示关闭
 120   1       lcd_write_command(0x01,1);//显示清屏
 121   1       lcd_write_command(0x06,1);//显示光标移动设置
 122   1       lcd_write_command(0x0c,1);//显示开及光标设置
 123   1      }
 124          
 125          //写指令函数: E=高脉冲 RS=0 RW=0
 126          void lcd_write_command(unsigned char command,unsigned char wait_en)//command为指令,wait_en指定是否要检测L
             -CD忙信号
 127          {if(wait_en)wait_enable();//若wait_en为1,则要检测LCD忙信号,等待其空闲
 128   1       lcd_RS=0;//RS=0
*** ERROR C202 IN LINE 128 OF 1602C.C: 'P2_0': undefined identifier
 129   1       lcd_RW=0;//RW=0
*** ERROR C202 IN LINE 129 OF 1602C.C: 'P2_1': undefined identifier
 130   1       lcd_data_port=command;
*** ERROR C202 IN LINE 130 OF 1602C.C: 'P0': undefined identifier
 131   1       lcd_E=0;//E=0,下面给LCD一个高脉冲
*** ERROR C202 IN LINE 131 OF 1602C.C: 'P2_2': undefined identifier
 132   1       _nop_();
 133   1       lcd_E=1;//E=1
*** ERROR C202 IN LINE 133 OF 1602C.C: 'P2_2': undefined identifier
 134   1       _nop_();
 135   1       lcd_E=0;//重设E=0
*** ERROR C202 IN LINE 135 OF 1602C.C: 'P2_2': undefined identifier
 136   1      }
 137          
 138          //写数据函数: E =高脉冲 RS=1 RW=0
 139          void lcd_write_data(unsigned char char_data)
 140          {wait_enable();//等待LCD空闲
 141   1       lcd_data_port=char_data;
*** ERROR C202 IN LINE 141 OF 1602C.C: 'P0': undefined identifier
 142   1       lcd_RS=1;//RS=1
*** ERROR C202 IN LINE 142 OF 1602C.C: 'P2_0': undefined identifier
 143   1       lcd_RW=0;//RW=0
*** ERROR C202 IN LINE 143 OF 1602C.C: 'P2_1': undefined identifier
C51 COMPILER V7.20   1602C                                                                 05/13/2007 18:18:43 PAGE 4   

 144   1       lcd_E=0;//E=0,下面给LCD一个高脉冲
*** ERROR C202 IN LINE 144 OF 1602C.C: 'P2_2': undefined identifier
 145   1       _nop_();
 146   1       lcd_E=1;//E=1
*** ERROR C202 IN LINE 146 OF 1602C.C: 'P2_2': undefined identifier
 147   1       _nop_();
 148   1       lcd_E=0;//重设E=0
*** ERROR C202 IN LINE 148 OF 1602C.C: 'P2_2': undefined identifier
 149   1      }
 150          
 151          //正常读写操作之前必须检测LCD控制器状态:E=1 RS=0 RW=1;DB7: 0 LCD控制器空闲,1 LCD控制器忙。
 152          //检测忙信号,等待LCD空闲函数
 153          void wait_enable(void)
 154          {
 155   1        lcd_RS=0;//RS=0
*** ERROR C202 IN LINE 155 OF 1602C.C: 'P2_0': undefined identifier
 156   1        lcd_RW=1;//RW=1
*** ERROR C202 IN LINE 156 OF 1602C.C: 'P2_1': undefined identifier
 157   1        lcd_E=1;//E=1 
*** ERROR C202 IN LINE 157 OF 1602C.C: 'P2_2': undefined identifier
 158   1        _nop_();
 159   1      //  while(busy);  //等待LCD_DB7为0
 160   1        delay_nms(1);
 161   1        lcd_E=0;//E=0
*** ERROR C202 IN LINE 161 OF 1602C.C: 'P2_2': undefined identifier
 162   1      }
 163          
 164          //指定位置显示一个字符:第一行位置0~15,第二行16~31
 165          //显示一个字符函数
 166          void display_a_char(unsigned char position,unsigned char char_data)//参数position指定位置0~31,char_data为

⌨️ 快捷键说明

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