如题,我用TLC2543测量电压值,但是我无论怎么在程序里改通道,都是只能读取的0通道值。程序如下
uint read(uchar port)
{
uchar i,al=0,ah=0;
unsigned long ad;
clock=0;
_cs=0;
port<<=4;
for(i=0;i<4;i++)
{
d_in=port&0x80;
clock=1;
clock=0;
port<<=1;
}
d_in=0;
for(i=0;i<8;i++)
{
clock=1;
clock=0;
}
_cs=1;
delay(5);
_cs=0;
for(i=0;i<4;i++)
{
clock=1;
ah<<=1;
if(d_out) ah|=0x01;
clock=0;
}
for(i=0;i<8;i++)
{
clock=1;
al<<=1;
if(d_out) al|=0x01;
clock=0;
}
_cs=1;
ad=(uint)ah;
ad<<=8;
ad|=al;
return(ad);
}
(原文件名:1.jpg)
一周热门 更多>