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

📄 ii.lst

📁 完整的电波钟源码,采用MSC51单片机,C语言编写的高质量程序!
💻 LST
📖 第 1 页 / 共 2 页
字号:
C51 COMPILER V7.06   II                                                                    09/11/2008 17:46:03 PAGE 1   


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

stmt level    source

   1          #include "c8051F330.h"  
   2          #include "define.h"  
   3          
   4          #ifndef         IIC_C
   5          #define         IIC_C
   6          #endif
   7          
   8          #include <math.h>
   9          #define MaxPress 1100 //1100Hpa
  10          #define DELAY10US 2
  11          
  12          long float MiddleData1;
  13          long float MiddleData2;
  14          long float MiddleData3;
  15          long float MiddleData4;
  16          //function declaration
  17          
  18          void IIC_ReadCalData(void);
  19          void ReadTemperaturePreesureAD(void);
  20          unsigned int IIC_ReadTempretureAD(void);
  21          unsigned int IIC_ReadPressureAD(void);
  22          void CalculatePressTemp(void);
  23          void CalculateAltitude(void);
  24          
  25          void IIC_ReadCalData(void);
  26          unsigned char IIC_ReadByte(void);
  27          void IIC_WriteByte( unsigned char);
  28          void IIC_Start(void);
  29          void IIC_Stop(void);
  30          void IIC_ACK(void);
  31          void IIC_NoAck(void);
  32          void IIC_SDA_HIGH(void);
  33          void IIC_SDA_LOW(void);
  34          void IIC_SCL_HIGH(void);
  35          void IIC_SCL_LOW(void);
  36          void IIC_XCLR_LOW(void);
  37          void IIC_XCLR_HIGH(void);
  38          void SysDelay2ms(unsigned int);
  39          void SysDelay(unsigned int);
  40          
  41           unsigned int xdata C1 ;
  42           unsigned int xdata C2 ;
  43           unsigned int xdata C3 ;
  44           unsigned int xdata C4 ;
  45           unsigned int xdata C5 ;
  46           unsigned int xdata C6 ;
  47           unsigned int xdata C7 ;
  48           unsigned char xdata AA;
*** WARNING C231 IN LINE 48 OF II.C: 'AA': redefinition
  49           unsigned char xdata BB ;
*** WARNING C231 IN LINE 49 OF II.C: 'BB': redefinition
  50           unsigned char xdata CC ;
*** WARNING C231 IN LINE 50 OF II.C: 'CC': redefinition
  51           unsigned char xdata DD ;
*** WARNING C231 IN LINE 51 OF II.C: 'DD': redefinition
C51 COMPILER V7.06   II                                                                    09/11/2008 17:46:03 PAGE 2   

  52           unsigned int xdata D1 ;
  53           unsigned int xdata D2 ;
  54           long float xdata DUT;
  55           long float xdata OFF;
  56           long float xdata SENS;
  57          long float xdata X;
  58          //long float xdata Press;
  59          //long float xdata Temp;
  60          //long xdata  Altitude;
  61          
  62          
  63          const long code Tab_BasicAltitude[80]={-6983,-6201,-5413,-4620,-3820,-3015,-2203,1385,-560, 270, //0.1m
  64          // 1100 1090 1080 1070 1060 1050 1040 1030 1020 1010 //hpa
  65          1108, 1953, 2805, 3664, 4224, 5403, 6284, 7172, 8068, 8972,
  66          // 1000 990 980 970 960 950 940 930 920 910 //hpa
  67          9885, 10805,11734,12671,13617,14572,15537,16510,17494,18486,
  68          // 900 890 880 870 860 850 840 830 820 810//hpa
  69          19489,20502,21526,22560,23605,24662,25730,26809,27901,29005,
  70          // 800 790 780 770 760 750 740 730 720 710//hpa
  71          30121,31251,32394,33551,34721,35906,37106,38322,39553,40800,
  72          // 700 690 680 670 660 650 640 630 620 610//hpa
  73          42060,43345,44644,45961,47296,48652,50027,51423,52841,54281,
  74          // 600 590 580 570 560 550 540 530 520 510//hpa
  75          55744,57231,58742,60280,61844,63436,65056,66707,68390,70105,
  76          // 500 490 480 470 460 450 440 430 420 410//hpa
  77          71854,73639,75461,77323,79226,81172,83164,85204,87294,89438};
  78          // 400 390 380 370 360 350 340 330 320 310//hpa
  79          /*
  80          void main(void)
  81          {SysDelay2ms(50);
  82          IIC_ReadCalData( );
  83          while(1)
  84          {ReadTemperaturePreesureAD();
  85          CalculatePressTemp( );
  86          CalculateAltitude( );
  87          SysDelay2ms(300);
  88          }
  89          }*/
  90          U8 Test_Ack(Void)
  91          {
  92   1       U8 Test;
  93   1       SCL=0;
  94   1       SDA=1;
  95   1       DelayUs(2);
  96   1      SCL=1;
  97   1       DelayUs(3);
  98   1       Test=P0&0x02;
  99   1       SCL=0;
 100   1       DelayUs(3);
 101   1        return Test;//返回0表示收到应答
 102   1      }       
 103          //**********************************
 104          //function: calculate power for 2
 105          //**********************************
 106          long int Get2_x(unsigned char i)
 107          {
 108   1       long int uiData;
 109   1      uiData=2;
 110   1      i=i-1;
 111   1      while(i)
 112   1      {
 113   2      uiData <<= 1;
C51 COMPILER V7.06   II                                                                    09/11/2008 17:46:03 PAGE 3   

 114   2      i--;
 115   2      }
 116   1      return uiData;
 117   1      }
 118          //**********************************
 119          //function:calculate press and temperature
 120          //input :D1,D2,C1---C7,AA,BB,CC,DD
 121          //output :Press, unit: 0.01hpa
 122          // temp, unit: 0.1℃
 123          //**********************************
 124          
 125          void CalculatePressTemp(void)
 126          {
 127   1      //long float MiddleData1;
 128   1      //long float MiddleData2;
 129   1      //long float MiddleData3;
 130   1      //long float MiddleData4;
 131   1      //calculate the DUT value
 132   1      if(D2<C5)
 133   1      {
 134   2      //DUT = D2-C5-((D2-C5)/Get2_x(7))*((D2-C5)/Get2_x(7))*BB/Get2_x(CC);
 135   2        MiddleData1 = (long)D2-C5;
 136   2        MiddleData2 = MiddleData1*MiddleData1/16384;
 137   2        MiddleData3 = MiddleData2*BB;
 138   2       MiddleData4 = Get2_x(CC);// MiddleData4 = Get2_x(CC);//(CC);
 139   2       MiddleData4 = MiddleData3/MiddleData4;
 140   2       DUT = MiddleData1 - MiddleData4; //MiddleData4 = MiddleData3/MiddleData4;
 141   2        //DUT = MiddleData1-MiddleData4;
 142   2      }
 143   1      else
 144   1      {
 145   2      //DUT = D2-C5-((D2-C5)/Get2_x(7))*((D2-C5)/Get2_x(7))*AA/Get2_x(C);
 146   2      MiddleData1 = D2-C5;
 147   2      MiddleData2 = MiddleData1*MiddleData1/16384;
 148   2      MiddleData3 = MiddleData2*AA;
 149   2      MiddleData4 = Get2_x(CC);
 150   2      MiddleData4 = MiddleData3/MiddleData4;
 151   2      DUT = MiddleData1 - MiddleData4;
 152   2      }
 153   1      //calculate the OFF value
 154   1      //OFF = (C2+(C4-1024)*DUT/Get2_x(14))*4;
 155   1      MiddleData1 = (long)C4-1024;
 156   1      MiddleData2 = Get2_x(14);
 157   1      MiddleData3 = DUT*MiddleData1;
 158   1      MiddleData4 = MiddleData3/MiddleData2;
 159   1      MiddleData4 = (long)C2+MiddleData4;
 160   1      OFF = MiddleData4*4;
 161   1      
 162   1      //calculate the SENS value
 163   1      //SENS = C1+C3*DUT/Get2_x(10);
 164   1      MiddleData1 = (long)C3*DUT;
 165   1      MiddleData2 = Get2_x(10);
 166   1      MiddleData3 = MiddleData1/MiddleData2;
 167   1      SENS = C1+MiddleData3;
 168   1      
 169   1      //calculate the X value
 170   1      //X = SENS*(D1-7168)/Get2_x(14)-OFF;
 171   1      MiddleData1 = Get2_x(14);
 172   1      MiddleData2 = (long)D1-7168;
 173   1      MiddleData3 = MiddleData2*SENS;
 174   1      MiddleData4 = MiddleData3/MiddleData1;
 175   1      X = MiddleData4-OFF;
C51 COMPILER V7.06   II                                                                    09/11/2008 17:46:03 PAGE 4   

 176   1      
 177   1      //calculate the Press value,have two decimal fraction
 178   1      //Press = X*100/Get2_x(5)+C7*10;
 179   1      MiddleData1 = X*100;
 180   1      MiddleData2 = Get2_x(5);
 181   1      MiddleData3 = MiddleData1/MiddleData2;
 182   1      MiddleData4 = C7*10;
 183   1      Press = MiddleData3+MiddleData4;
 184   1      
 185   1      //calculate the Temperature value
 186   1      Temp = 250+DUT*C6/Get2_x(16)-DUT/Get2_x(DD);
 187   1      }
 188          //**********************************************
 189          //function:calculate altitude
 190          //input :Press value
 191          //output :Altitude, unit:0.1m
 192          //**********************************************
 193          void CalculateAltitude(void)
 194          {
 195   1      char ucCount;
 196   1      unsigned int uiBasicPress;
 197   1      unsigned int uiBiasTotal;
 198   1      unsigned int uiBiasPress;
 199   1      unsigned int uiBiasAltitude;
 200   1      for( ucCount=0; ; ucCount++ )
 201   1      {
 202   2      uiBasicPress = MaxPress-(ucCount*10);
 203   2      if(uiBasicPress < (int)(Press/100)) break;
 204   2      }
 205   1      uiBiasTotal = Tab_BasicAltitude[ucCount] - Tab_BasicAltitude[ucCount-1];
 206   1      uiBiasPress = Press - (long)(uiBasicPress*100);
 207   1      uiBiasAltitude = (long)uiBiasTotal * uiBiasPress/1000;
 208   1      Altitude = Tab_BasicAltitude[ucCount] - uiBiasAltitude;
 209   1      ucCount = abs(Altitude % 10); // four lose and five up
 210   1      if(Altitude < 0)
 211   1      {
 212   2      if(ucCount > 4)
 213   2      Altitude -= 10-ucCount;
 214   2      else
 215   2      Altitude += ucCount;
 216   2      }
 217   1      else
 218   1      {
 219   2      if(ucCount > 4)
 220   2      Altitude += 10-ucCount;
 221   2      else
 222   2      Altitude -= ucCount;
 223   2      }
 224   1      }
 225          
 226          //========================================================
 227          void IIC_ReadCalData(void)
 228          {
 229   1      unsigned char ucValue;
 230   1      //do{
 231   1      IIC_Start();
 232   1      IIC_WriteByte(0xa0);
 233   1      //SysDelay(DELAY10US);
 234   1        //}
 235   1      //while(!(Test_Ack()==0)); 
 236   1      IIC_WriteByte(16);
 237   1        SysDelay(DELAY10US);
C51 COMPILER V7.06   II                                                                    09/11/2008 17:46:03 PAGE 5   

 238   1      // Test_Ack();
 239   1      IIC_Start();
 240   1      IIC_WriteByte(0xa1);
 241   1      SysDelay(DELAY10US);
 242   1      //Test_Ack();
 243   1      ucValue = IIC_ReadByte();
 244   1      IIC_ACK();
 245   1      C1=ucValue;
 246   1      ucValue = IIC_ReadByte();
 247   1      IIC_ACK();
 248   1      C1 <<= 8;
 249   1      C1 |= ucValue;
 250   1      
 251   1      ucValue = IIC_ReadByte();
 252   1      IIC_ACK();
 253   1      C2=ucValue;
 254   1      ucValue = IIC_ReadByte();
 255   1      IIC_ACK();
 256   1      C2 <<= 8;
 257   1      C2 |= ucValue;
 258   1      
 259   1      ucValue = IIC_ReadByte();
 260   1      IIC_ACK();
 261   1      C3=ucValue;
 262   1      ucValue = IIC_ReadByte();
 263   1      IIC_ACK();
 264   1      C3 <<= 8;
 265   1      C3 |= ucValue;
 266   1      
 267   1      
 268   1      ucValue = IIC_ReadByte();
 269   1      IIC_ACK();
 270   1      C4=ucValue;
 271   1      ucValue = IIC_ReadByte();
 272   1      IIC_ACK();
 273   1      C4 <<= 8;
 274   1      C4 |= ucValue;
 275   1      
 276   1      ucValue = IIC_ReadByte();
 277   1      IIC_ACK();
 278   1      C5=ucValue;
 279   1      ucValue = IIC_ReadByte();
 280   1      IIC_ACK();
 281   1      C5 <<= 8;
 282   1      C5 |= ucValue;
 283   1      
 284   1      ucValue = IIC_ReadByte();
 285   1      IIC_ACK();
 286   1      C6=ucValue;
 287   1      ucValue = IIC_ReadByte();
 288   1      IIC_ACK();
 289   1      C6 <<= 8;
 290   1      C6 |= ucValue;
 291   1      
 292   1      ucValue = IIC_ReadByte();
 293   1      IIC_ACK();
 294   1      C7=ucValue;
 295   1      ucValue = IIC_ReadByte();
 296   1      IIC_ACK();
 297   1      C7 <<= 8;
 298   1      C7 |= ucValue;
 299   1      
C51 COMPILER V7.06   II                                                                    09/11/2008 17:46:03 PAGE 6   

 300   1      ucValue = IIC_ReadByte();
 301   1      IIC_ACK();
 302   1      AA=ucValue;
 303   1      ucValue = IIC_ReadByte();
 304   1      IIC_ACK();
 305   1      BB= ucValue;
 306   1      
 307   1      ucValue = IIC_ReadByte();
 308   1      IIC_ACK();
 309   1      CC=ucValue;
 310   1      ucValue = IIC_ReadByte();
 311   1      IIC_NoAck();
 312   1      IIC_Stop();
 313   1      DD= ucValue;
 314   1      }
 315          //===============================================
 316          void MCLKOn(void)

⌨️ 快捷键说明

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