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

📄 adcpin.c

📁 Example codes for ADuC8xx CPU family
💻 C
字号:
/*;********************************************************************
;
; Author        : ADI - Apps            www.analog.com/MicroConverter
;
; Date          : April 2002
;
; File          : ADCpin.asm
;
; Hardware      : ADuC832
;
; Description   : Performs hardware pin driven ADC conversions and
;                 outputs results on UART.  Continuously flashes
;                 LED (independently of ADC routine) at approximately
;                 5Hz (assuming an 2.097152 MHz Mclk).
;		
;*********************************************************************/

#include<stdio.h>
#include<aduc832.h>
void DELAY(int);		// function prototype

void adc_int() interrupt 6{
	printf("%02BX%02BX\n",ADCDATAH,ADCDATAL);
	return;
			  }


sbit LED = 0x0B4;               // P3.4

void main(void)
{
int CHAN = 0;

/*set up UART */
T3CON = 0x082;
T3FD = 0x02D;
SCON   = 0x052;

/*PRECONFIGURE...*/

ADCCON1 = 0x080;		// power up ADC
ADCCON2 = CHAN;			// select channel to convert

/*LAUNCH CONTINUOUS CONVERSIONS...*/

EA = 1;              		// enable interrupts
EADC = 1;		        // enable ADC interrupt
ADCCON1 |= 0x01;		// enable hardware CONVST pin

/*CONTINUE WITH OTHER CODE...*/

for(;;)
{
LED ^= 1;
DELAY(1700);
}

/*
 the micro is free to continue with other tasks (flashing the LED in
 this case) while the ADC is converting, synchronously to the
 external CONVST pin.  results are being handled by the ADC
 interrupt service routine.*/
}

void DELAY(int length)
{
while (length >=0)
    length--;
}

⌨️ 快捷键说明

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