📄 adcuart.c
字号:
//********************************************************************
//
// Author : ADI - Apps www.analog.com/MicroConverter
//
// Date : 16 October 2003
//
// File : 847uart.c
//
// Hardware : ADuC845, ADuC847, ADuC848 (taking into account fact that the ADuC848 is a 16-bit ADC)
//
// Description : sample program that performs ADC conversions in
// continuous mode and sends results to a PC via the
// UART. Operates on the RTD (PT100) on the eval board
// via Ain1->Ain2 ADC inputs. The switches (S4) on the
// eval board must be set as follows to get this program
// working correctly...RTD AIN1, RTD AIN2, RTD REFIN+
// and RTD REFIN- must be set to ON. All other switches
// must be off.
//********************************************************************
#include <stdio.h>
#include <ioADUC847.h> //To use this with an ADuC847 or ADuC848, simply change the
//header file to <ioADUC847.h> or <ioADUC848>
#define LED P3_bit.T0
#pragma vector=0x33
__interrupt void ADC_int ()
{
LED ^= 1;
printf("%X%X%X\n\r",(int)ADC0H,(int)ADC0M,(int)ADC0L); //Remove ADC0L when using the ADuC848
ADCSTAT_bit.RDY0 = 0;
}
void main (void)
{
//Configure UART
T3CON = 0x83; //9600 Baud rate
T3FD = 0x12;
SCON = 0x52;
SCON_bit.TI = 1;
//CONFIGURE ADC AND START CONVERTING....
ICON = 0x01; //Turn on IEXC1 source to drive RTD.
SF = 0x20;
ADC0CON1 = 0x22; //Full Buffer, Unipolar, 80mV range.
ADC0CON2 = 0x4A; //Refin+/-, Ain1->Ain2
IE_bit.EADC = 1; //Enable ADC Interrupt
IE_bit.EA = 1; //Enable Global Interrupts
ADCMODE = 0x23; // continuous conversion on Main channel on main channel
//WAIT FOR INTERRUPTS....
while(1);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -