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

📄 adc_10bits.lst

📁 ateml 10位AD 通用程序
💻 LST
字号:
C51 COMPILER V7.10   ADC_10BITS                                                            06/09/2004 15:33:02 PAGE 1   


C51 COMPILER V7.10, COMPILATION OF MODULE ADC_10BITS
OBJECT MODULE PLACED IN adc_10bits.OBJ
COMPILER INVOKED BY: C:\KEIL\C51\BIN\C51.EXE adc_10bits.c BROWSE DEBUG OBJECTEXTEND TABS(3)

line level    source

   1          /**
   2           * @file $RCSfile: Adc_10bits.c,v $
   3           *
   4           * Copyright (c) 2004 Atmel.
   5           *
   6           * Please read file license.txt for copyright notice.
   7           *
   8           * @brief This file is an example to use Adc.
   9           *
  10           * This file can be parsed by Doxygen for automatic documentation
  11           * generation.
  12           * Put here the functional description of this file within the software
  13           * architecture of your program.
  14           *
  15           * @version $Revision: 1.0 $ $Name:  $
  16           */
  17          
  18          /* @section  I N C L U D E S */
  19          #include "t89c51cc01.h"
  20          
  21          unsigned int value_converted=0x0000;/* converted value */
  22          unsigned int value_AN6=0x0000;      /* converted AN6 value */
  23          unsigned int value_AN7=0x0000;      /* converted AN7 value */
  24          bit end_of_convertion=0;            /* software flag */
  25          
  26          /**
  27           * FUNCTION_PURPOSE:this function setup Adc with channel 6 and 7 and start 
  28           * 8bits convertion.
  29           * FUNCTION_INPUTS:void
  30           * FUNCTION_OUTPUTS:void
  31           */
  32          void main(void)
  33          {
  34   1      ADCF = 0xC0;                        /* configure channel P1.6(AN6) and P1.7(AN7) for ADC */
  35   1      
  36   1      /* init prescaler for adc clock */
  37   1      /* Fadc = Fperiph/(2*(32-PRS)), PRS -> ADCLK[4:0] */
  38   1        ADCLK = 0x06;                     /* Fosc = 16 MHz, Fadsc = 153.8khz */
  39   1      
  40   1      ADCON = 0x20;                       /* Enable the ADC */
  41   1      
  42   1      
  43   1      EA = 1;                             /* enable interrupts */
  44   1      EADC = 1;                           /* enable ADC interrupt */
  45   1      while(1)
  46   1      {
  47   2         ADCON &= ~0x07;                  /* Clear the channel field ADCON[2:0] */
  48   2         ADCON |= 0x06;                   /* Select channel 6 */
  49   2         ADCON &= ~0x40;                  /* standard mode */
  50   2         ADCON |= 0x08;                   /* Start conversion */
  51   2      
  52   2         while(!end_of_convertion);       /* wait end of convertion */
  53   2         end_of_convertion=0;             /* clear software flag */
  54   2         value_AN6=value_converted;       /* save converted value */
  55   2      
C51 COMPILER V7.10   ADC_10BITS                                                            06/09/2004 15:33:02 PAGE 2   

  56   2      
  57   2         ADCON &= ~0x07;                  /* Clear the channel field ADCON[2:0] */
  58   2         ADCON |= 0x07;                   /* Select channel 7 */
  59   2         ADCON &= ~0x40;                  /* standard mode */
  60   2         ADCON |= 0x08;                   /* Start conversion */
  61   2      
  62   2         while(!end_of_convertion);       /* wait end of convertion */
  63   2         end_of_convertion=0;             /* clear software flag */
  64   2         value_AN7=value_converted;       /* save converted value */
  65   2      
  66   2      }
  67   1      }
  68          
  69          
  70          /**
  71           * FUNCTION_PURPOSE:Adc interrupt, save ADDH ans ADDL into an unsigned int
  72           * FUNCTION_INPUTS:void
  73           * FUNCTION_OUTPUTS:void
  74           */
  75          void it_Adc(void) interrupt 8
  76          {
  77   1      ADCON &= ~0x10;                     /* Clear the End of conversion flag */
  78   1      value_converted = ADDH<<2;          /* save 8 msb bits */
  79   1      value_converted |= (ADDL & 0x03);   /* save 2 lsb bits */
  80   1      end_of_convertion=1;                /* set flag */
  81   1      }
  82          


MODULE INFORMATION:   STATIC OVERLAYABLE
   CODE SIZE        =    104    ----
   CONSTANT SIZE    =   ----    ----
   XDATA SIZE       =   ----    ----
   PDATA SIZE       =   ----    ----
   DATA SIZE        =      6    ----
   IDATA SIZE       =   ----    ----
   BIT SIZE         =      1    ----
END OF MODULE INFORMATION.


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

⌨️ 快捷键说明

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