请教24位AD 单片机ADUC845 读数不对,是哪里出错了?
#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 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 = 0x00;
rawValue.Byte = (unsigned char)ADC0H;
rawValue.Byte = (unsigned char)ADC0M;
rawValue.Byte = (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);
}
请用过此芯片的帮忙看看,谢谢! 仔细研究手册,答案都在里面 dz46316740 发表于 2019-1-19 19:27
仔细研究手册,答案都在里面
好的,谢谢!
dz46316740 发表于 2019-1-19 19:27
仔细研究手册,答案都在里面
你好在吗?我的配置看手册是没问题啊,为什么一直读出的电压不对? ADI中文论坛发帖。若是仪器仪表应用,新设计建议换用性价比更好的ADuCM36x
页:
[1]