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

📄 analog.lst

📁 cp2200网卡的tcp/ip源程序( 包含驱动),十分难得哦
💻 LST
字号:
C51 COMPILER V7.50   ANALOG                                                                08/03/2006 09:24:02 PAGE 1   


C51 COMPILER V7.50, COMPILATION OF MODULE ANALOG
OBJECT MODULE PLACED IN Analog.OBJ
COMPILER INVOKED BY: C:\Keil750\C51\BIN\c51.exe Analog.c DB OE

line level    source

   1          //-----------------------------------------------------------------------------
   2          // Copyright (c) 2002 Jim Brady
   3          // Do not use commercially without author's permission
   4          // Last revised August 2002
   5          // Net ANALOG.C
   6          //
   7          // This module handles the analog inputs which are external temperature
   8          // sensor, the on-chip temperature sensor, and operating voltage.
   9          //-----------------------------------------------------------------------------
  10          #include <string.h>
  11          //#include <stdlib.h>
  12          #include "C8051f.h"
  13          #include "net.h"
  14          #include "analog.h"
  15          
  16          extern char xdata text[];
  17          UINT idata cpu_temperature, air_temperature, cpu_voltage;
  18          UCHAR idata mux_select;
  19          
  20          sfr16 ADC0     = 0xbe;                 // ADC0 data
  21          
  22          //--------------------------------------------------------------------------
  23          // Initialize the A/D converter
  24          // 
  25          //--------------------------------------------------------------------------
  26          void init_adc(void)
  27          {
  28   1              ADC0CN = 0x81;                      // ADC0 enabled; normal tracking
  29   1                                              // mode; ADC0 conversions are initiated 
  30   1                                              // on write to AD0BUSY; ADC0 data is
  31   1                                              // left-justified
  32   1              REF0CN = 0x07;                      // enable temp sensor, on-chip VREF,
  33   1                                              // and VREF output buffer
  34   1              mux_select = MUX_CPU_TEMP;                      // CPU on-chip temp sensor
  35   1              AMX0SL = MUX_CPU_TEMP;  
  36   1      
  37   1         ADC0CF = (SYSCLK/2500000) << 3;     // ADC conversion clock = 2.5MHz
  38   1       //  ADC0CF |= 0x01;                     // PGA gain = 2
  39   1         EIE2 &= ~0x02;                      // disable ADC0 EOC interrupt
  40   1         EIE1 &= ~0x04;                      // disable ADC0 window compare interrupt
  41   1      }
  42          
  43          
  44          
  45          //--------------------------------------------------------------------------
  46          // This function is a little state machine which reads one analog
  47          // inputs at a time, out of the 3 possible inputs
  48          //  1. On-chip temperature
  49          //  2. External air temperature
  50          //  3. CPU operating voltage
  51          //--------------------------------------------------------------------------
  52          void read_analog_inputs(void)
  53          {
  54   1              ULONG idata temp_long;
  55   1      
C51 COMPILER V7.50   ANALOG                                                                08/03/2006 09:24:02 PAGE 2   

  56   1          AD0INT = 0;                      // clear conversion complete indicator
  57   1          AD0BUSY = 1;                     // initiate conversion
  58   1          while (AD0INT == 0);             // wait for conversion complete
  59   1              switch (mux_select)
  60   1              {
  61   2                      case MUX_CPU_TEMP:
  62   2                      temp_long = ADC0*2 - 42380;
  63   2                          temp_long= (temp_long * 100L) / 156;
  64   2                              cpu_temperature=temp_long;
  65   2                              AMX0SL = MUX_CPU_VOLTS;         // Select AIN1 for next read
  66   2                              mux_select = MUX_CPU_VOLTS;
  67   2                      break;
  68   2      
  69   2                      case MUX_CPU_VOLTS:
  70   2                              temp_long = ADC0;
  71   2                              temp_long = 24*temp_long/655;
  72   2                              cpu_voltage = temp_long;
  73   2                              AMX0SL = MUX_AIR_TEMP;          // Select on-chip temp sensor
  74   2                              mux_select = MUX_AIR_TEMP;
  75   2                      break;
  76   2      
  77   2                      case MUX_AIR_TEMP:
  78   2                              temp_long = ADC0;
  79   2                              temp_long = 24*temp_long/655;
  80   2                              air_temperature = temp_long;
  81   2                              AMX0SL = MUX_CPU_TEMP;   
  82   2                              mux_select = MUX_CPU_TEMP;
  83   2                      break;
  84   2      
  85   2                      default:
  86   2                              AMX0SL = MUX_CPU_TEMP;
  87   2                              mux_select = MUX_CPU_TEMP;
  88   2                      break;
  89   2              }
  90   1      }
  91           
  92          
  93           


MODULE INFORMATION:   STATIC OVERLAYABLE
   CODE SIZE        =    250    ----
   CONSTANT SIZE    =   ----    ----
   XDATA SIZE       =   ----    ----
   PDATA SIZE       =   ----    ----
   DATA SIZE        =   ----    ----
   IDATA SIZE       =      7       4
   BIT SIZE         =   ----    ----
END OF MODULE INFORMATION.


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

⌨️ 快捷键说明

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