能不能先看看这个代码,那个关于串口的代码写的太烂了,贴出了怕大家鄙视的厉害。这个是AD的程序,也有问题,但是好歹比较靠谱。我想用TLC2543采集信号,再用数码管显示出来。结果吧,数码管显示的及其不稳定,我本来以为是延时时间太长,现在把延时时间调整到最小,可是依然还是不稳定,而且,当通道0输入0时候,本来数码管该显示0000,但是就一直跳到。大家能帮忙看看这代码的问题吗?不胜感激啊
#include
#include
#include
#define uchar unsigned char
#define uint unsigned int
sbit AD_CLOCK=P3^3;
sbit AD_IN=P3^7;
sbit AD_OUT=P3^5;
sbit AD_CS=P3^6;
uchar table[10]={0xc0,0xf9,0xa4,0xb0,
0x99,0x92,0x82,0xf8,
0x80,0x90} ;
static const uchar ad_channel_select[]=
{0x08,0x18,0x28,0x38,0x48,0x58,0x68,0x78,0x88,
0x98,0xa8
};
uint ad2543(uchar chunnel_select)
{ uint din,j;
uchar dout,i;
din=0;
dout=ad_channel_select[chunnel_select];
for(j=0;j