This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

ADS8344 驱动求助


#include<stc12C5A60S2.h>
#define  uchar unsigned char
#define  uint unsigned int

sbit ADS_CS   = P2^3;
sbit ADS_DCLK = P2^1;
sbit ADS_DIN  = P2^4;
sbit ADS_BUSY = P3^5;
sbit ADS_DOUT = P2^0;

// (MSB)                                  (LSB) 
// BIT7 BIT6 BIT5 BIT4 BIT3   BIT2   BIT1 BIT0
//  S    A2   A1   A0   —    SGL/DIF  PD1  PD0
void ads_com(uchar ads_comchar)
{
    uchar i=0;
    for (i=8; i>0; i--)
    {
        ADS_DIN  = ads_comchar&0x80;//取最高位
        ADS_DCLK = 0;
        ADS_DCLK = 1;
        ads_comchar<<=1;//左移数据
    }
}

// (MSB)        (LSB) 
// BIT15 ...... BIT0
uint ads_dat(void)
{
    uint ads_datword = 0;
    uchar i=0;
    for (i=16; i>0; i--)
    {
        ads_datword<<=1;//左移数据
        ADS_DCLK = 0;
        if(ADS_DOUT==1) ads_datword = ads_datword|0x01;//最低位或
        ADS_DCLK = 1;
    }
    return(ads_datword);
}

void main()
{
    uint ADS_DataWord = 0;
   
 
    ADS_CS   = 1;
    ADS_DCLK = 0;
   
    ADS_CS   = 0;
    //  S    A2   A1   A0   —    SGL/DIF  PD1  PD0
    //  1    0    0    0    —       1      1    1
    ads_com(0x87);//10000111 输入控制命令
    ADS_DCLK = 0;
    ADS_DCLK = 1;
    while(ADS_BUSY == 1);
    ADS_DataWord = ads_dat();
   
    ADS_CS   = 1;
    while(1);
}

 

能否解释 如何读取DOUT 串行输出