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

📄 adccont.c

📁 8051试验程序 基础教材
💻 C
字号:
/* Author        : ADI - Apps            www.analog.com/MicroConverter

 Date          : May 2002

 File          : ADCcont.c

 Hardware      : ADuC831

 Description   : Performs ADC conversions in continuous mode at a
                 rate of 40KSPS (assuming an 11.0592 Mclk).
                 Outputs ADC results via UART.  Continuously
                 flashes LED.
                 All rate calculations assume an 11.0592MHz Mclk. */

#include<stdio.h>
#include<ioaduc831.h>

#define LED P3_bit.P34

void DELAY(int length);

#pragma vector = adci
__interrupt void adc_int()
{
	printf("%02BX%02BX\n",ADCDATAH,ADCDATAL);
	return;
}

void main(void)
{
	int CHAN = 0;

	T3CON = 0x085;
	T3FD = 0x08;
	SCON = 0x052;

	/* PRECONFIGURE... */

	ADCCON1 = 0x080;	// power up ADC /16 + 1 acq clock
	ADCCON2 = CHAN;		// select channel to convert

	/*LAUNCH CONTINUOUS CONVERSIONS...*/

	IE_bit.EA = 1;		// enable interrupts
	IE_bit.EADC = 1;	// enable ADC interrupt
	ADCCON2_bit.CCONV = 1;	// begin continuous conversions

	/* CONTINUE WITH OTHER CODE... */
	
	for (;;){
		DELAY(2);
		LED ^= 1;	// blink (complement) the LED
	}

	// the micro is free to continue with other tasks (flashing the LED in
	// this case) while the ADC is continuously converting, and 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 + -