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

📄 main.lst

📁 Energy meter To measure the voltage and current
💻 LST
字号:
C51 COMPILER V8.12   MAIN                                                                  03/07/2009 00:48:39 PAGE 1   


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

line level    source

   1          #include <REG51.H>
   2          #include <stdio.h>
   3          #include <string.h>
   4          #include <intrins.h>
   5          #include <float.h>
   6          #include <math.h>
   7          #include <ADC.c>
   8          #include <LCD.c>
   9          
  10          
  11          #define UnitPrice 2
  12          sbit DevEnable =P3^1;
  13          sbit Freq       = P2^0;
  14          
  15          //********************Globel Variable*************************
  16          
  17          const char Pass[6]={"123456"} ;
  18          static unsigned char DelayCount;
  19          bit TickFlg=0;
  20          static unsigned int BalanceAmt;
  21          static unsigned int PrepaidBalance;
  22          static float UsedPower;
  23          static unsigned char PrepidPower;
  24          static float Voltage;
  25          static float Current;
  26          float temp;
  27          
  28          //***************************************************************
  29          
  30          //                      Function Decleration
  31          
  32          //***************************************************************
  33          
  34          void itoa(unsigned int value  ,unsigned char *string);
  35          unsigned char ReadFreq();
  36          
  37          //***************************************************************
  38          
  39          //                      Timer 1 Interrupt routine
  40          
  41          //***************************************************************
  42          void timer1_ISR (void) interrupt 3
  43          {
  44   1              TH1 = 0xC3;              /* Reload TL1 to count 100 clocks */
  45   1              TL1 = 0x50;
  46   1              TF1=0;
  47   1              DelayCount++;
  48   1              if(DelayCount==20)
  49   1              {
  50   2                      DelayCount=0;
  51   2                      TickFlg=1;
  52   2                      temp=((Voltage*Current)/60);
  53   2                      UsedPower+=(temp*.002);
  54   2                      if(UsedPower>=1)
  55   2                      {
C51 COMPILER V8.12   MAIN                                                                  03/07/2009 00:48:39 PAGE 2   

  56   3                              BalanceAmt-= (unsigned char )UsedPower;
  57   3                              UsedPower=0;
  58   3                      }
  59   2              }
  60   1      }
  61          
  62          //***************************************************************
  63          
  64          //                      Serial Port initialization for 9600 baud
  65          
  66          //***************************************************************
  67          
  68          void SerInit()
  69          {
  70   1              TMOD |=0x20;
  71   1              TH1=-3;
  72   1              SCON=0x50;
  73   1              TR1=1;
  74   1              TI=1;
  75   1      }
  76          //***************************************************************
  77          
  78          //                      Timer1 initialization for 50 mS
  79          
  80          //***************************************************************
  81           void Timer1Init()
  82           {
  83   1              TMOD = 0x10;  /* Set Mode (8-bit timer with reload) */
  84   1              TH1 = 0x3C;              /* Reload TL1 to count 100 clocks */
  85   1              TL1 = 0xAF;
  86   1              ET1 = 1;                      /* Enable Timer 1 Interrupts */
  87   1              EA = 1;                                         /* Global Interrupt Enable */
  88   1       }
  89          
  90           //***************************************************************
  91          
  92          //                      Processor Variable initialization
  93          
  94          //***************************************************************
  95          void ProcessorInit()
  96          {
  97   1              DelayCount=0;
  98   1              TickFlg=0;
  99   1              BalanceAmt=0;
 100   1              UsedPower=0;
 101   1              PrepidPower=0;
 102   1              Voltage=0;
 103   1              Current=0;
 104   1              PrepaidBalance=0;
 105   1              DevEnable=0;    
 106   1      }
 107          
 108          //***************************************************************
 109          
 110          //                      Delay for 1 MS
 111          
 112          //***************************************************************
 113          
 114          void Delay_MS(unsigned int value)
 115          {
 116   1              unsigned int x,y;
 117   1              for(x=0;x<1000;x++)
C51 COMPILER V8.12   MAIN                                                                  03/07/2009 00:48:39 PAGE 3   

 118   1                      for(y=0;y<value;y++);
 119   1      }       
 120          //***************************************************************
 121          
 122          //                      Main
 123          
 124          //***************************************************************
 125                  unsigned char Ascii[5];
 126          void main()                                                                                                                      
 127          {
 128   1              unsigned char Read=0;
 129   1              unsigned char ReadKeypad=0;
 130   1              unsigned char Temp[7];
 131   1              unsigned char Count=0;
 132   1              bit Passcheck=0;
 133   1              bit PassOKFlg=0;
 134   1              bit EnterRSFlg=0;
 135   1      //      unsigned int Money;
 136   1              unsigned int Temp1;
 137   1      
 138   1              bit KeyReadFlag=0;
 139   1      //      SerInit();
 140   1              ProcessorInit();
 141   1      //      Timer1Init();
 142   1              lcd_init();
 143   1              lcd_com(15); // first line
 144   1              lcd_puts("DIGITAL ENERGY");
 145   1              lcd_com(0xC5);     //second line
 146   1              lcd_puts("METER");
 147   1              Delay_MS(100);
 148   1              lcd_com(0x1);
 149   1              lcd_com(0x2);
 150   1              lcd_com(0x0C);
 151   1              lcd_com(0x80);
 152   1              lcd_puts("VOL    V");
 153   1      
 154   1              lcd_com(0xC0);
 155   1              lcd_puts("CUR     A");
 156   1      
 157   1              lcd_com(0xC8);
 158   1              lcd_puts("FREQ");
 159   1              while(1)
 160   1              {
 161   2                      ADDA=0;
 162   2                      AddressLatch();
 163   2                      Start();
 164   2                      delay(1);
 165   2                      EOCCheck();
 166   2                      Read=ReadADC();
 167   2                      temp=Read;
 168   2                      temp=(temp*.0196)*46;
 169   2                      Voltage=temp;
 170   2                      Temp1=temp;
 171   2                      itoa(Temp1 ,Ascii);
 172   2      //              lcd_com(0x84); // first line
 173   2      //              lcd_puts("   ");                                        
 174   2                      lcd_com(0x84); // first line
 175   2                      lcd_puts(Ascii);
 176   2                      temp=0;
 177   2                      Temp1=0;
 178   2                      Read=0;
 179   2                      delay(1);
C51 COMPILER V8.12   MAIN                                                                  03/07/2009 00:48:39 PAGE 4   

 180   2                      delay(1);
 181   2                      delay(1);
 182   2      
 183   2                      ADDA=1;
 184   2                      AddressLatch();
 185   2                      Start();
 186   2                      delay(1);
 187   2                      EOCCheck();
 188   2                      Read=ReadADC();
 189   2                      temp=Read;
 190   2                      temp=(temp*.0196)*2;
 191   2                      Current=temp;
 192   2                      Temp1=temp*10;
 193   2                      itoa(Temp1 ,Ascii);     
 194   2                      lcd_com(0xC4); // first line
 195   2                      lcd_putc(Ascii[1]);
 196   2                      lcd_puts(".");
 197   2                      lcd_putc(Ascii[2]);
 198   2                      temp=0;
 199   2                      Temp1=0;
 200   2                      Read=0;
 201   2      
 202   2                      delay(1);
 203   2                      delay(1);
 204   2                      delay(1);
 205   2        ReadFreq();
 206   2                      
 207   2              }
 208   1      }
*** WARNING C280 IN LINE 130 OF MAIN.C: 'Temp': unreferenced local variable
 209          
 210          //***************************************************************
 211          
 212          //                      Integer to Ascii Conversion
 213          
 214          //***************************************************************
 215           void itoa(unsigned int value  ,unsigned char *string)
 216          {
 217   1      
 218   1              if(value<10)
 219   1              {
 220   2      
 221   2                              string[2]='\0';
 222   2                              string[1]=((value%10)+0x30);
 223   2                              value=value/10;
 224   2                              string[0]=((value%10)+0x30);
 225   2      
 226   2              }
 227   1              else if(value<100)
 228   1              {
 229   2                              string[3]='\0';
 230   2                              string[2]=((value%10)+0x30);
 231   2                              value=value/10;
 232   2                              string[1]=((value%10)+0x30);
 233   2                              string[0]=0x30;
 234   2              }
 235   1              else if(value<1000)
 236   1              {
 237   2      
 238   2                      string[3]='\0';
 239   2                      string[2]=((value%10)+0x30);
 240   2                      value=value/10;
C51 COMPILER V8.12   MAIN                                                                  03/07/2009 00:48:39 PAGE 5   

 241   2                      string[1]=((value%10)+0x30);
 242   2                      value=value/10;
 243   2                      string[0]=((value%10)+0x30);
 244   2      
 245   2              }
 246   1              else if(value<10000)
 247   1              {
 248   2                      string[4]='\0';
 249   2                      string[3]=((value%10)+0x30);
 250   2                      value=value/10;
 251   2                      string[2]=((value%10)+0x30);
 252   2                      value=value/10;
 253   2                      string[1]=((value%10)+0x30);
 254   2                      value=value/10;
 255   2                      string[0]=((value%10)+0x30);
 256   2              }
 257   1      }
 258          
 259          
 260          
 261          unsigned char ReadFreq()
 262          {
 263   1              unsigned char Pre=0;
 264   1              unsigned char Current=0;
 265   1              unsigned int Count=0;
 266   1      
 267   1              if(Freq)
 268   1              {
 269   2                      Pre     =Current;
 270   2                      Current=1;      
 271   2              }
 272   1              else 
 273   1              {
 274   2                      Pre     =Current;
 275   2                      Current=0;                      
 276   2              }
 277   1      
 278   1              if(Pre==0&&Current==1)
 279   1              {
 280   2                      while(Freq!=0)  
 281   2                      {
 282   3                              Count++;
 283   3                      }
 284   2                      while(Freq==0)
 285   2                      {
 286   3                              Count++;
 287   3                      }
 288   2      
 289   2                       Count=Count;
 290   2                              lcd_com(0xCC);
 291   2                              itoa(Count,Ascii);      
 292   2                              lcd_puts(Ascii);        
 293   2              }
 294   1      }
*** WARNING C173 IN LINE 294 OF MAIN.C: missing return-expression
 295          


MODULE INFORMATION:   STATIC OVERLAYABLE
   CODE SIZE        =   1439    ----
   CONSTANT SIZE    =     47    ----
   XDATA SIZE       =   ----    ----
C51 COMPILER V8.12   MAIN                                                                  03/07/2009 00:48:39 PAGE 6   

   PDATA SIZE       =   ----    ----
   DATA SIZE        =     33      22
   IDATA SIZE       =   ----    ----
   BIT SIZE         =      2       4
END OF MODULE INFORMATION.


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

⌨️ 快捷键说明

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