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

📄 adcmain.lst

📁 这是单片机C51典型应用设计代码
💻 LST
字号:
C51 COMPILER V6.14g  ADCMAIN                                                               07/15/2001 19:26:27 PAGE 1   


C51 COMPILER V6.14g, COMPILATION OF MODULE ADCMAIN
OBJECT MODULE PLACED IN adcMain.OBJ
COMPILER INVOKED BY: C:\Keil\C51\BIN\C51.EXE adcMain.c DEBUG OBJECTEXTEND

stmt level    source

   1          /*------------------------------------------------------------------------------
   2          adcMain.c : Sample Program that demonstrates the A to D converter of the 
   3          following microcontrollers
   4          
   5          Infineon SAB 80C537
   6          
   7          Copyright (c) 1988-2001 Keil Elektronik GmbH and Keil Software, Inc.
   8          All rights reserved.
   9          --------------------------------------------------------------------------*/
  10          
  11          #include <stdio.h>
  12          
  13          
  14          
  15          sfr ADCON0  = 0xD8;
  16          sfr ADCON1 = 0xDC;
  17          sfr ADDAT  = 0xD9;
  18          sfr DAPR   = 0xDA;
  19          
  20          sfr S0CON   = 0x98;
  21          sfr TMOD   = 0x89;
  22          sfr TH1    = 0x8D;
  23          sbit TR1    = 0x8E;
  24          sbit TI0     = 0x99;
  25          
  26          /*------------------------------------------------------------------------------
  27          Read_ADC( unsigned char ): reads an analog signal from the received unsigned
  28          char and returns the converted value
  29          ------------------------------------------------------------------------------*/
  30          unsigned char Read_ADC( unsigned char channel )
  31          {
  32   1      	ADCON1 &= ~0x0F;				//Prepare channel selector	
  33   1      	ADCON1 |= 0x0F & channel;	//Set input channel
  34   1      
  35   1      	DAPR  = 0x00;				//Setting Vgnd and Vref to 0 and 5
  36   1      								//This starts the conversion process.
  37   1      
  38   1      	while( ADCON0 & 0x10 );		//Loop till busy flag is cleared
  39   1      	return( (unsigned char) ADDAT );
  40   1      }
  41          
  42          /*------------------------------------------------------------------------------
  43          main() : Outputs the digital conversion of channels 0 - 11.
  44          ------------------------------------------------------------------------------*/
  45          void main( void )
  46          {
  47   1      	unsigned char i;
  48   1      	
  49   1      	S0CON  = 0x50;		        /* SCON: mode 1, 8-bit UART, enable rcvr      */
  50   1          TMOD |= 0x20;               /* TMOD: timer 1, mode 2, 8-bit reload        */
  51   1          TH1   = 221;                /* TH1:  reload value for 1200 baud @ 16MHz   */
  52   1          TR1   = 1;                  /* TR1:  timer 1 run                          */
  53   1          TI0   = 1;                  /* TI:   set TI to send first char of UART    */
  54   1      
  55   1         	while(1)
C51 COMPILER V6.14g  ADCMAIN                                                               07/15/2001 19:26:27 PAGE 2   

  56   1      	{
  57   2      		for( i = 0; i < 12; i++)
  58   2      		{
  59   3      			printf("Channel %u = %4u\n",(unsigned) i, (unsigned)Read_ADC(i) );
  60   3      		}
  61   2      	}
  62   1      }
  63          
  64          


MODULE INFORMATION:   STATIC OVERLAYABLE
   CODE SIZE        =     71    ----
   CONSTANT SIZE    =     18    ----
   XDATA SIZE       =   ----    ----
   PDATA SIZE       =   ----    ----
   DATA SIZE        =   ----       1
   IDATA SIZE       =   ----    ----
   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 + -