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

📄 adc842.lst

📁 ADUC842 C程序集,包括ADC,DAC,PLL,PWM,WDT等程序.
💻 LST
字号:
C51 COMPILER V5.50,  ADC842                                                                17/10/03  17:58:00  PAGE 1   


DOS C51 COMPILER V5.50, COMPILATION OF MODULE ADC842
OBJECT MODULE PLACED IN ADC842.OBJ
COMPILER INVOKED BY: C:\ADUC\BIN\C51.EXE ADC842.C DB

stmt level    source

   1          //adc842.c
   2          /*
   3          Author: Eckart Hartmann Date:17/10/2003
   4          Description of Software: 
   5          	This program demonstrates the <A HREF="/mcc/softw/842/adc/Adc842D.html">SAR ADC</A> functions. 
   6          	; <A HREF="/mcc/softw/842/adc/Adc842Cfg.html">AdcCfg()</A>, <A HREF="/mcc/softw/842/adc/Adc842Go.html">Ad
             -cGo()</A>,
   7          	; <A HREF="/mcc/softw/842/adc/Adc842Bsy.html">AdcBsy()</A>, <A HREF="/mcc/softw/842/adc/Adc842Rd.html">Ad
             -cRd()</A>
   8          	; <A HREF="/mcc/softw/842/adc/Adc842Cal.html">AdcCal()</A> and <A HREF="/mcc/softw/842/adc/Adc842Get.html
             -">AdcGet()</A>.
   9          	Software communicates with a terminal at 9600 baud. Program shows 
  10          	help screen with a command list. Then continuous conversions are 
  11          	started and displayed. While measurements are output the user can 
  12          	issue single key commands to change settings. 
  13          	Also included are a help and wait option.
  14          Development progress: <A HREF="/mcc/softw/842/adc/Adc842Df.html">Adc842.df</A>
  15          */
  16          //#include"..\kei842.h"	//;<A HREF="/mcc/softw/842/Kei842Sfr.html">SFR definition file</A>.
  17          #include"..\lib842.h"	//;<A HREF="/mcc/softw/842/Lib842H.html">Function and variable declaration file</A>.
  18          #include<stdio.h>	//"stdio.h"
  19          #include<ctype.h>	//"ctype.h"
  20          #include<stdlib.h>	//"stdlib.h"
  21          
  22          void PrintHelp(void);
  23          
  24          void main(void)
  25          	{
  26   1      	char 	c1;		//Temporary variable.
  27   1      	char	cXRef;		//External ref flag ('R' pressed).
  28   1      	char	cGain;		//Gain calibration flag ('G' pressed).
  29   1      	char	cSys;		//System calibration flag ('S' pressed).
  30   1      	int	piV[14];	//Conversion results.
  31   1      
  32   1      	cXRef = 0;
  33   1      
  34   1      	UrtCfg(0x33,0x832d);	//<A HREF="/mcc/softw/834/urt/Urt834Cfg.html">UrtCfg</A> configures UART.
  35   1      	printf("%04x \n",AdcRd());
  36   1      	AdcCfg(0x0ac);
  37   1      	AdcGet(0);
  38   1      
  39   1      	PrintHelp();
  40   1      
  41   1      	while(1)
  42   1      		{
  43   2       		if(UrtBsy()&1)		//If key pressed.
  44   2        			{	// Act on command.
  45   3        			while((c1 = _getkey())=='w');	//Wait if 'w'.
  46   3          			if(c1=='s' || c1=='S' || c1=='g' || c1=='G')
  47   3            				{	//Calibrate.
  48   4      	    			if(c1=='s')		cSys = 0;      				
  49   4             				else if(c1=='S')	cSys = 1;      				
  50   4             				else if(c1=='g')	cGain = 0;      				
  51   4             				else if(c1=='G')	cGain = 1; 
  52   4             		     		AdcCal(4*cSys+2*cGain+1);
  53   4             	      			while(AdcBsy())	printf(".");
  54   4              		      	}
  55   3              	        if(c1=='r' || c1=='R')
  56   3              			{	
C51 COMPILER V5.50,  ADC842                                                                17/10/03  17:58:00  PAGE 2   

  57   4       	       			if(c1=='r')	cXRef = 0;
  58   4       	       			else	cXRef = 1;
  59   4      	       		        AdcCfg(0x80+0x40*cXRef);
  60   4      				}
  61   3      			else if(c1=='h')	PrintHelp();
  62   3            			}
  63   2             		for(c1=0; c1<11;c1++)
  64   2       			{
  65   3         			if(c1==6)	c1 = 8;
  66   3         			AdcGo(c1,1);
  67   3           			while(AdcBsy())	printf(".");
  68   3      			piV[c1] = AdcRd();     
  69   3      //  			piV[c1] = AdcGet(c1);
  70   3      //			printf("%05d ",piV[c1]*6);
  71   3      			printf("%05d ",piV[c1]);
  72   3        			}
  73   2          		printf(" %c%c%c\n",cSys?'S':'s',cGain?'G':'g',
  74   2           			cXRef?'R':'r');
  75   2       	}	}
  76          
  77          void PrintHelp(void)
  78          	{
  79   1      	printf("To change settings during conversions press one of:\n");
  80   1      	printf("\t s for internal calibration.\n");
  81   1      	printf("\t S for system calibration.\n");
  82   1      	printf("\t g for zero calibration.\n");
  83   1      	printf("\t G for gain calibration.\n");
  84   1      	printf("\t r for internal reference.\n");
  85   1      	printf("\t R for external reference.\n");
  86   1      	printf("\t w to wait.\n");
  87   1      	printf("\t h for this help screen.\n");
  88   1      	printf("\tResults line will show 12 measured values in hex format\n");
  89   1      	printf("\tplus  s or S, g or G and r or R depending on selection.\n");
  90   1      	printf("Press a key to end help.\n\n");
  91   1      	_getkey();
  92   1      	}
  93          	


MODULE INFORMATION:   STATIC OVERLAYABLE
   CODE SIZE        =    449    ----
   CONSTANT SIZE    =    433    ----
   XDATA SIZE       =   ----    ----
   PDATA SIZE       =   ----    ----
   DATA SIZE        =      2      32
   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 + -