如下程序怎么也读不到ad转换的结果。请大虾拔刀相助 提供一个max192和单片机的接口例程
int ReadMax192Ad(unsigned char channel) //channel [0--7] { unsigned char CtrByte;//START SEL2 SEL1 SEL0 UNI/BIP SGL/DIF PD1 PD0 int adcode=0; CtrByte=0x8e; CtrByte=(CtrByte&~(0x7<<4))|(channel<<4);
CS_MAX192=0; //chip enable DelayUs(180); //delay SPIRW(CtrByte); DelayUs(40); adcode=SPIRW(0x00)<<3; DelayUs(40); adcode=adcode+SPIRW(0x00)>>5; DelayUs(180); CS_MAX192=1;//chip disable return adcode;
} |