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

📄 家电控制系统.lst

📁 VB作上位机,通过跟51单片机通讯,控制家用电器电源的通断
💻 LST
📖 第 1 页 / 共 2 页
字号:
C51 COMPILER V7.06   家_缈刂芲_蚠                                                          03/25/2009 22:37:00 PAGE 1   


C51 COMPILER V7.06, COMPILATION OF MODULE 家_缈刂芲_蚠
OBJECT MODULE PLACED IN 家电控制系统.OBJ
COMPILER INVOKED BY: C:\Keil\C51\BIN\C51.EXE 家电控制系统.c BROWSE DEBUG OBJECTEXTEND

stmt level    source

   1          #include <reg51.h>
   2          #include <math.h>
   3          #include <stdlib.h>
   4          #include <intrins.h>
   5          
   6          #define uchar unsigned char
   7          #define uint unsigned int
   8          //typedef unsigned char uchar;
   9          //typedef unsigned int uint;
  10          
  11          sbit LCD_RS = P1^0;             
  12          sbit LCD_RW = P1^1;
  13          sbit LCD_EN = P1^2;
  14          sbit LED = P1^6;//数据传输指示
  15          sbit LED1=P1^0;
  16          sbit LED2=P1^1;
  17          sbit LED3=P1^2;
  18          sbit LED4=P1^3;
  19          sbit LED5=P1^4;
  20          sbit LED6=P1^5;
  21          sbit LED7=P1^6;
  22          sbit LED8=P1^7;
  23          
  24          
  25          
  26          
  27          
  28          uchar RST=0;
  29          static count;
  30          static value=0;
  31          uchar p;
  32          uchar flag=0;
  33          
  34                  
  35          char data  mode[20]={"INPUT:          "};
  36          
  37          uchar code dis1[] = {"andy is the best!!"};    //预留要显示的内容
  38          uchar code dis2[] = {"happy new year!!"};      //预留要显示的内容
  39          /******************************************************************
  40          /*
  41          /*复位代码
  42          /*
  43          /******************************************************************/
  44          void soft_reset(void)
  45          {
  46   1         ((void (code *) (void)) 0x0000) ();
  47   1      }
  48          /*******************************************************************/
  49          /*                                                                                                        
             -                          */
  50          /* 延时子程序                                                                                             
             -                     */
  51          /*                                                                                                        
             -                          */
  52          /*******************************************************************/
C51 COMPILER V7.06   家_缈刂芲_蚠                                                          03/25/2009 22:37:00 PAGE 2   

  53          
  54          void delay(int ms)
  55          {                           
  56   1         int i;
  57   1         while(ms--)
  58   1         {  
  59   2           for(i = 0; i< 250; i++)
  60   2           {
  61   3            _nop_();
  62   3            _nop_();
  63   3            _nop_();
  64   3            _nop_();
  65   3           }
  66   2         }
  67   1      }
  68          
  69          /*******************************************************************/
  70          /*                                                                                                        
             -                          */
  71          /*检查LCD忙状态                                                                                           
             -                  */
  72          /*lcd_busy为1时,忙,等待。lcd-busy为0时,闲,可写指令与数据。                                      */
  73          /*                                                                                                        
             -                          */
  74          /*******************************************************************/
  75          
  76          bit lcd_busy()
  77          {                          
  78   1          bit result;
  79   1          LCD_RS = 0;
  80   1          LCD_RW = 1;
  81   1          LCD_EN = 1;
  82   1          _nop_();
  83   1          _nop_();
  84   1          _nop_();
  85   1          _nop_();
  86   1           result = (bit)(P0&0x80);
  87   1          LCD_EN = 0;
  88   1          return result; 
  89   1      }
  90          
  91          /*******************************************************************/
  92          /*                                                                                                        
             -                          */
  93          /*写指令数据到LCD                                                                                         
             -                 */
  94          /*RS=L,RW=L,E=高脉冲,D0-D7=指令码。                                                                   *
             -/
  95          /*                                                                                                        
             -                           */
  96          /*******************************************************************/
  97          
  98          void lcd_wcmd(uchar cmd)
  99          {                          
 100   1         while(lcd_busy());
 101   1          LCD_RS = 0;
 102   1          LCD_RW = 0;
 103   1          LCD_EN = 0;
 104   1          _nop_();
 105   1          _nop_(); 
 106   1          P0 = cmd;
 107   1          _nop_();
C51 COMPILER V7.06   家_缈刂芲_蚠                                                          03/25/2009 22:37:00 PAGE 3   

 108   1          _nop_();
 109   1          _nop_();
 110   1          _nop_();
 111   1          LCD_EN = 1;
 112   1          _nop_();
 113   1          _nop_();
 114   1          _nop_();
 115   1          _nop_();
 116   1          LCD_EN = 0;  
 117   1      }
 118          
 119          /*******************************************************************/
 120          /*                                                                                                        
             -                          */
 121          /*写显示数据到LCD                                                                                         
             -                 */
 122          /*RS=H,RW=L,E=高脉冲,D0-D7=数据。                                                                     *
             -/
 123          /*                                                                                                        
             -                          */
 124          /*******************************************************************/
 125          
 126          void lcd_wdat(uchar dat) 
 127          {                          
 128   1         while(lcd_busy());
 129   1          LCD_RS = 1;
 130   1          LCD_RW = 0;
 131   1          LCD_EN = 0;
 132   1          P0 = dat;
 133   1          _nop_();
 134   1          _nop_();
 135   1          _nop_();
 136   1          _nop_();
 137   1          LCD_EN = 1;
 138   1          _nop_();
 139   1          _nop_();
 140   1          _nop_();
 141   1          _nop_();
 142   1          LCD_EN = 0; 
 143   1      }
 144          
 145          /*******************************************************************/
 146          /*                                                                                                        
             -                          */
 147          /*  设定显示位置                                                                                          
             -                    */
 148          /*                                                                                                        
             -                          */
 149          /*******************************************************************/
 150          
 151          void lcd_pos(uchar pos)
 152          {                          
 153   1         lcd_wcmd(pos|0x80);      //数据指针=80+地址变量
 154   1      }
 155          
 156          /*******************************************************************/
 157          /*                                                                                                        
             -                          */
 158          /*  LCD初始化设定                                                                                         
             -                  */
 159          /*                                                                                                        
             -                          */
C51 COMPILER V7.06   家_缈刂芲_蚠                                                          03/25/2009 22:37:00 PAGE 4   

 160          /*******************************************************************/
 161          
 162          void lcd_init()
 163          { 
 164   1          delay(15);                     //等待LCD电源稳定        
 165   1          lcd_wcmd(0x38);          //16*2显示,5*7点阵,8位数据
 166   1          delay(5);
 167   1          lcd_wcmd(0x38);         
 168   1          delay(5);
 169   1          lcd_wcmd(0x38);         
 170   1          delay(5);
 171   1      
 172   1          lcd_wcmd(0x0c);          //显示开,关光标
 173   1          delay(5);
 174   1          lcd_wcmd(0x06);          //移动光标
 175   1          delay(5);
 176   1          lcd_wcmd(0x01);          //清除LCD的显示内容
 177   1          delay(5);
 178   1      }
 179          
 180          /*******************************************************************/
 181          /*                                                                                                        
             -                          */
 182          /*  清屏子程序                                                                                            
             -                     */
 183          /*                                                                                                        
             -                          */
 184          /*******************************************************************/
 185          
 186          void lcd_clr()
 187          {
 188   1          lcd_wcmd(0x01);          //清除LCD的显示内容
 189   1          delay(5);
 190   1      }
 191          
 192          /*******************************************************************/
 193          /*                                                                                                        
             -                          */
 194          /*  闪动子程序                                                                                            
             -                     */
 195          /*                                                                                                        
             -                          */
 196          /*******************************************************************/
 197          
 198          void flash()
 199          {
 200   1          delay(200);                     //控制停留时间
 201   1          lcd_wcmd(0x08);            //关闭显示
 202   1          delay(50);                    //延时
 203   1          lcd_wcmd(0x0c);            //开显示
 204   1          delay(200);
 205   1          lcd_wcmd(0x08);            //关闭显示
 206   1          delay(50);                     //延时
 207   1          lcd_wcmd(0x0c);            //开显示
 208   1          //delay(200);                       

⌨️ 快捷键说明

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