|
#include <stdio.h>
#include <ADuC845.h>
sbit LED = P2^4;
#define Byte3 0
#define Byte2 1
#define Byte1 2
#define Byte0 3
typedef union LONGDATA{ // Access LONGDATA as an
unsigned long result; // unsigned long variable or
unsigned char Byte[4]; // 4 unsigned byte variables
}LONGDATA;
void ADC_int () interrupt 6
{
static LONGDATA rawValue;
unsigned long mV;
LED ^= 1;
printf("\n\n");
// printf("%bX%bX%bX",ADC0H,ADC0M,ADC0L);
rawValue.Byte[Byte3] = 0x00;
rawValue.Byte[Byte2] = (unsigned char)ADC0H;
rawValue.Byte[Byte1] = (unsigned char)ADC0M;
rawValue.Byte[Byte0] = (unsigned char)ADC0L;
mV = rawValue.result*2500/ 16777216; // 24 位AD
printf("%6ld",mV);
RDY0 = 0;
}
void main (void)
{
P2=0XFF;
//Configure UART
T3CON = 0x83; //9600 Baud rate
T3FD = 0x12;
SCON = 0x52;
//CONFIGURE ADC AND START CONVERTING....
SF = 0x200;
ADC0CON1 = 0x27; //单端,双BUF,2.56V最大量程
ADC0CON2 = 0x46; //外+2.5V参考电源 , 第7通道
EADC = 1; //Enable ADC Interrupt
EA = 1; //Enable Global Interrupts
ADCMODE = 0x23; // 连续转换
//WAIT FOR INTERRUPTS....
while(1);
}
请用过此芯片的帮忙看看,谢谢! |
阿莫论坛20周年了!感谢大家的支持与爱护!!
知道什么是神吗?其实神本来也是人,只不过神做了人做不到的事情 所以才成了神。 (头文字D, 杜汶泽)
|