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

📄 et.lst

📁 Electronic Timer for controlling device
💻 LST
📖 第 1 页 / 共 3 页
字号:
C51 COMPILER V8.08   ET                                                                    03/21/2009 19:03:01 PAGE 1   


C51 COMPILER V8.08, COMPILATION OF MODULE ET
OBJECT MODULE PLACED IN et.OBJ
COMPILER INVOKED BY: C:\Keil\C51\BIN\C51.EXE et.c BROWSE DEBUG OBJECTEXTEND

line level    source

   1          /***************************************************************/
   2          /******** Program Description : Electronic Timer Program *******/
   3          /***************** Programmer : Amit Kumar Das *****************/
   4          /*************** Program Date : 21st March 2009 ****************/
   5          /*************** Program Time : 05:30 PM ***********************/
   6          /************ Microcontroller : AT89S52 ************************/
   7          /******** Operating Frequency : 12.0MHz ************************/
   8          /***************************************************************/      
   9          
  10          #include <reg51.h>
  11          #include <string.h>
  12          
  13          sbit rs = P2^7;     // declare P2.7 as rs pin
  14          sbit en = P2^5;     // declare p2.5 as enable pin
  15          sbit rw = P2^6;     // declare p2.6 as read/write pin
  16          sbit b = P0^7;      // busy flag 
  17          
  18          sbit outbit = P2^0; // ouput for relay
  19          sbit start = P3^3;
  20          
  21          sbit tenmin = P1^0;
  22          sbit twentymin = P1^1;
  23          sbit thirtymin = P1^2;
  24          sbit fortymin = P1^3;
  25          sbit fiftymin = P1^4;
  26          sbit sixtymin = P1^5;
  27          sbit nintymin = P1^6;
  28          sbit onetwentymin = P1^7;
  29          sbit onefiftymin = P3^0;
  30          sbit oneeightymin = P3^1;
  31          
  32          void writecmd(unsigned char a);  // function to send command to LCD
  33          void writedat(unsigned char b);  // function to send data to LCD
  34          void busy();                     // function to check LCD is busy or not
  35          void writestr(unsigned char *s); // function to write string on LCD
  36          void MSDelay(unsigned int);              // delay function
  37          
  38          void writecmd(unsigned char a)
  39          {
  40   1       busy();   // check for LCD is busy or not
  41   1       rs = 0;   // clear rs pin for command
  42   1       rw = 0;   // clear rw pin to write
  43   1       P0 = a;   // send command character
  44   1       en = 1;   // strob LCD
  45   1       en = 0;
  46   1      }
  47          void writedat(unsigned char b)
  48          {
  49   1       busy();   // check for LCD is busy or not
  50   1       rs = 1;   // set rs pin for data
  51   1       rw = 0;   // clear rw pin to write
  52   1       P0 = b;   // send data character
  53   1       en = 1;   // strob LCD
  54   1       en = 0; 
  55   1      }
C51 COMPILER V8.08   ET                                                                    03/21/2009 19:03:01 PAGE 2   

  56          void busy()
  57          {
  58   1       en = 0;   // disable display
  59   1       P0 = 0xFF;  // configur P0 as input
  60   1       rs = 0;   // clear rs pin for command
  61   1       rw = 1;   // set rw pin to read
  62   1       while(b==1)
  63   1       {
  64   2        en=0;   // strob LCD till P0.7 is 1
  65   2        en=1;
  66   2       }
  67   1       en=0;
  68   1      }
  69          void writestr(unsigned char *s)
  70          {
  71   1       unsigned char l,i;
  72   1       l = strlen(s);               // get the length of string
  73   1       for(i=1;i<l;i++)
  74   1       {
  75   2        writedat(*s);              // write every char one by one
  76   2        s++;  
  77   2       }
  78   1      }
  79             
  80          void MSDelay(unsigned int itime)
  81          
  82                  {
  83   1                      unsigned int i,j;
  84   1                      for(i=0;i<itime;i++)
  85   1                      for(j=0;j<1275;j++);
  86   1              }
  87                   
  88          void main(void)
  89          
  90           {
  91   1              P0=0x00;                     // P0 and P2 as output ports
  92   1              P2=0x00;                                         // LCD controls output
  93   1                      P1=0xFF;                                         
  94   1                      P3=0xFF;
  95   1                      writecmd(0x38);              // initialize 5X7 matrix LCD
  96   1              writecmd(0x0E);    
  97   1              writecmd(0x82);                          // move cursor to first line 2nd pos
  98   1                      writecmd(0x01);              // clear memory and home cursor
  99   1              writestr("Electronic Timer ");  // write message in first line  
 100   1                      writecmd(0xC1);              // clear memory and home cursor
 101   1              writestr("Initializing.. ");  // write message in first line  
 102   1                      MSDelay(500);
 103   1      here:   writecmd(0x01);
 104   1                      writecmd(0x82);
 105   1                      writestr("Enter Time: ");
 106   1                      
 107   1        while(1)
 108   1        {
 109   2      
 110   2        while(tenmin==1)
 111   2         {
 112   3            writecmd(0xC3);
 113   3                writestr("10 Minutes ");
 114   3         if(start==1)
 115   3         {
 116   4         outbit=1;
 117   4         writecmd(0x01);
C51 COMPILER V8.08   ET                                                                    03/21/2009 19:03:01 PAGE 3   

 118   4         writecmd(0x82);
 119   4         writestr("Time Left: ");
 120   4         goto ten;
 121   4         }
 122   3         else goto here;        
 123   3         }
 124   2         while(twentymin==1)
 125   2         {
 126   3            writecmd(0xC3);
 127   3                writestr("20 Minutes ");
 128   3         if(start==1)
 129   3         {
 130   4         outbit=1;
 131   4         writecmd(0x01);
 132   4         writecmd(0x82);
 133   4         writestr("Time Left: ");
 134   4         goto twenty;
 135   4         }
 136   3         else goto here;        
 137   3         }
 138   2        while(thirtymin==1)
 139   2         {
 140   3            writecmd(0xC3);
 141   3                writestr("30 Minutes ");
 142   3         if(start==1)
 143   3         {
 144   4         outbit=1;
 145   4         writecmd(0x01);
 146   4         writecmd(0x82);
 147   4         writestr("Time Left: ");
 148   4         goto thirty;
 149   4         }
 150   3         else goto here;        
 151   3         }
 152   2        while(fortymin==1)
 153   2         {
 154   3            writecmd(0xC3);
 155   3                writestr("40 Minutes ");
 156   3         if(start==1)
 157   3         {
 158   4         outbit=1;
 159   4         writecmd(0x01);
 160   4         writecmd(0x82);
 161   4         writestr("Time Left: ");
 162   4         goto forty;
 163   4         }
 164   3         else goto here;        
 165   3         }
 166   2         while(fiftymin==1)
 167   2         {
 168   3            writecmd(0xC3);
 169   3                writestr("50 Minutes ");
 170   3         if(start==1)
 171   3         {
 172   4         outbit=1;
 173   4         writecmd(0x01);
 174   4         writecmd(0x82);
 175   4         writestr("Time Left: ");
 176   4         goto fifty;
 177   4         }
 178   3         else goto here;        
 179   3         }
C51 COMPILER V8.08   ET                                                                    03/21/2009 19:03:01 PAGE 4   

 180   2         while(sixtymin==1)
 181   2         {
 182   3            writecmd(0xC3);
 183   3                writestr("60 Minutes ");
 184   3         if(start==1)
 185   3         {
 186   4         outbit=1;
 187   4         writecmd(0x01);
 188   4         writecmd(0x82);
 189   4         writestr("Time Left: ");
 190   4         goto sixty;
 191   4         }
 192   3         else goto here;        
 193   3         }
 194   2         while(nintymin==1)
 195   2         {
 196   3            writecmd(0xC3);
 197   3                writestr("90 Minutes ");
 198   3         if(start==1)
 199   3         {
 200   4         outbit=1;
 201   4         writecmd(0x01);
 202   4         writecmd(0x82);
 203   4         writestr("Time Left: ");
 204   4         goto ninty;
 205   4         }
 206   3         else goto here;        
 207   3         }
 208   2         while(onetwentymin==1)
 209   2         {
 210   3            writecmd(0xC3);
 211   3                writestr("120 Minutes ");
 212   3         if(start==1)
 213   3         {
 214   4         outbit=1;
 215   4         writecmd(0x01);
 216   4         writecmd(0x82);
 217   4         writestr("Time Left: ");
 218   4         goto onetwenty;
 219   4         }
 220   3         else goto here;        
 221   3         }
 222   2         while(onefiftymin==1)
 223   2         {
 224   3            writecmd(0xC3);
 225   3                writestr("150 Minutes ");
 226   3         if(start==1)
 227   3         {
 228   4         outbit=1;
 229   4         writecmd(0x01);
 230   4         writecmd(0x82);
 231   4         writestr("Time Left: ");
 232   4         goto onefifty;
 233   4         }
 234   3         else goto here;        
 235   3         }
 236   2         while(oneeightymin==1)
 237   2         {
 238   3            writecmd(0xC3);
 239   3                writestr("180 Minutes ");
 240   3         if(start==1)
 241   3         {
C51 COMPILER V8.08   ET                                                                    03/21/2009 19:03:01 PAGE 5   

 242   4         outbit=1;
 243   4         writecmd(0x01);
 244   4         writecmd(0x82);
 245   4         writestr("Time Left: ");
 246   4         goto oneeighty;
 247   4         }
 248   3         else goto here;        
 249   3         }
 250   2      
 251   2       oneeighty: writecmd(0xC1);              
 252   2                  writestr("180 Minutes "); 
 253   2                      MSDelay(500);
 254   2                              writecmd(0xC1);              
 255   2                  writestr("179 Minutes "); 
 256   2                      MSDelay(500);

⌨️ 快捷键说明

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