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.

ADS8328的问题

读寄存器值和读量测值都为0,如果有的话能不能发一份代码例程给我,我的邮箱是XCS175@163.com,谢谢!

  • xie

    是不是读写时序不对?对照手册的figure1~6,看一下时序吧

  • Seasat Liu~谢谢你的回复,那个时序图我也看了很多遍了,但是始终没找出问题所在

    下面这几段是我的程序,有空的话请帮我分析一下有没什么地方写错了,谢谢!

    void write_com(uchar com)  

    {

      uchar w_temp,i=4;

      SPI_CS=0;

      w_temp=com;

      while(i--)

      {

        SPI_CLK=1;

    _nop_();

    SPI_IN=(bit)(w_temp&0x80);

    _nop_();

    SPI_CLK=0;

    _nop_();

    w_temp<<=1;

       }

    SPI_CS=1;

    }

    void write_cfr(uint datcfr)  

    {

      uchar i=12;  

      uint w_temp;

      SPI_CS=0;

      w_temp=datcfr;

      while(i--)

      {

        SPI_CLK=1;

    _nop_();

    SPI_IN=(bit)(w_temp&0x8000);

    _nop_();

    SPI_CLK=0;

    _nop_();

    w_temp<<=1;

       }

    SPI_CS=1;

    }

    void config()

    {

      write_com(0xe0);

      write_cfr(0xcbf0);

    }

    uint read_8328()

    {

      uchar i=17;  

      uint w_temp;

      SPI_CS=0;

      while(i--)

      {

        if(i==1)

    {

       SPI_CLK=1;

       _nop_();

       SPI_CLK=0;

    _nop_();

       flag_tag=SPI_OUT;

    _nop_();

    SPI_CLK=1;

       _nop_();

    break;

    }

        SPI_CLK=1;

    _nop_();

    SPI_CLK=0;

    _nop_();

    w_temp=SPI_OUT&0x0001;

    _nop_();

    SPI_CLK=1;

    _nop_();

    w_temp<<=1;

       }

    SPI_CS=1;

    return w_temp;

    }

    uint read_CRF()

    {

      uchar i=16;  

      uint w_temp;

      SPI_CS=0;

      SPI_CLK=1;

      _nop_();

      while(i--)

      {    

    SPI_CLK=0;

    _nop_();

    w_temp=SPI_OUT&0x0001;

    _nop_();

    SPI_CLK=1;

    _nop_();

    w_temp<<=1;

       }

    SPI_CS=1;

    return w_temp;

    }