adcsingl.c

来自「8051试验程序 基础教材」· C语言 代码 · 共 60 行

C
60
字号
/*********************************************************************

 Author        : ADI - Apps            www.analog.com/MicroConverter

 Date          : October 2003

 File          : ADCsingl.c

 Hardware      : ADuC841

 Description   : Performs repeated single ADC conversions and moves
                 results to UART.

		
*********************************************************************/

#include<stdio.h>
#include<ioaduc841.h>

#define adcled P3_bit.P33
#define LED P3_bit.P34		//P3.4 drives red LED on eval board

#pragma vector = ADCI_int
__interrupt void adc_int(){
	LED=1;
	printf("\n%02BX%02BX\n",ADCDATAH,ADCDATAL);
	return;
}
void DELAY(int);			// Function prototype
void main(void)
{
int  CHAN=0;

/* Set up UART */
T3CON = 0x086;
T3FD = 0x08;
SCON   = 0x052;

/* PRECONFIGURE...*/

ADCCON1 = 0x08C;      // power up ADC /32 + 4 acq clock
ADCCON2 = CHAN;				// select channel to convert
IE_bit.EA	= 1;				// enable interrupts
IE_bit.EADC	= 1;				// enable ADC interrupt

/* PERFORM REPEATED SINGLE CONVERSIONS...*/

for(;;)
{
ADCCON2_bit.SCONV = 1;				// Perform single conversion
while (LED==0){}
LED=0;
}

}




⌨️ 快捷键说明

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