求一个AD转换加上RS232的单片机串口通信程序

现在急需一个AD转换加上RS232的单片机串口通信程序,AD芯片是AD0804,单片机是STC89C52,急求!!!有哪位大神帮忙解决一下,万分感谢。

用STC12C5201AD单片机就可以了,16脚的!

#include <STC12C5A60S2_H.h>
#include <string.h>
#include <stdio.h>
#include <absacc.h>
#include <intrins.h>
#define uchar unsigned char
#define uint unsigned int
#define ADC_FLAG 0x10
#define ADC_START 0x08
uchar datt1=0;
void delay(uint z)
{
uint x,y;
for(x=z;x>0;x--)
for(y=250;y>0;y--);
}
uchar GetADCResult(uchar ch)
{
ADC_CONTR =0x80 | ch | ADC_START;
_nop_();
_nop_();
_nop_();
_nop_();
while (!(ADC_CONTR & ADC_FLAG));
ADC_CONTR &= ~ADC_FLAG;

return ADC_RES;
}
void Txbyte(unsigned char i)
{
ES=0;TI=0;SBUF=i;
while(!TI);
TI=0;ES=1;
}
void Serial_Int(void) interrupt 4
{
if(RI==1)
{
RI=0;
}

void LcmInit( void )
{
SCON=0X50; //串口方式1,允许接收
TMOD=0X20; //定时器1 定时方式2 T0 is mode 1
TH1=0xfd; // t1 // 9600
TL1=0xfd;
PCON|=0x00;
TR1=1; //启动定时器
REN=1;
ES = 1; //开串口中断
EA = 1; //开总中断
CLK_DIV = 0x01;
ADC_RES = 0;
ADC_CONTR=0x80;
}
void Main( void )
{
LcmInit();
while(1)
{
delay(10);
dat1=GetADCResult(0);
Txbyte(dat1);
}
}
温馨提示:答案为网友推荐,仅供参考
第1个回答  2012-05-27
你既然用stc单片机,建议选一个带AD的,很多的,10位AD.用0804也行啊麻烦,仿真可以,还有串口,也可以的 可以交流
建议 去 我的领地 5d6d 的 proteus 论坛看看

那里有很多 单片机仿真实例,包括仿真图 和 源码
搜 5d6d 和 proteus 2个关键词
第2个回答  2012-05-26
你既然用stc单片机,建议选一个带AD的,很多的,10位AD.用0804也行啊麻烦,仿真可以,还有串口,也可以的 可以交流
第3个回答  2012-05-26
建议 去 我的领地 5d6d 的 proteus 论坛看看

那里有很多 单片机仿真实例,包括仿真图 和 源码
搜 5d6d 和 proteus 2个关键词