打印

ads1110

[复制链接]
1571|3
手机看帖
扫描二维码
随时随地手机跟帖
跳转到指定楼层
楼主
liulicau|  楼主 | 2007-10-17 13:38 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
         ISendByte(0x94,0x8c);
    DelayNS(10);
    I2C_ReadNByte(0x94,1,0x00,data_buf1,0x02);
    DelayNS(10);
    adc_value1=data_buf1[0]<<8||data_buf1[1];
    if(data_buf1[1]||0x80==1)
    {
        adc_value1=~adc_value1+1;
    }
    adc_value1=(adc_value1*2.048)/(32767*1);
    DelayNS(10);
大家帮我看看程序这样写有什么问题吗?

相关帖子

沙发
ayb_ice| | 2007-10-17 13:57 | 只看该作者

if(data_buf1[1]||0x80==1)...

这里逻辑混乱。。。
if(data_buf1[1] || 0x80==1)
程序严重不规范,可读性极差。。。

使用特权

评论回复
板凳
liulicau|  楼主 | 2007-10-17 14:21 | 只看该作者

修改

    if(data_buf1[1]&&0x80==0x80)
   改成这样了,可以吗?

使用特权

评论回复
地板
liulicau|  楼主 | 2007-10-17 16:17 | 只看该作者

lpc2138中I2C器件ads1110的读写

ISendByte(0x94,0x8c);
DelayNS(10);
I2C_ReadNByte(0x94,ONE_BYTE_SUBA,0x00,data_buf1,0x03);
DelayNS(10);
ISendByte(0x96,0x8c);
DelayNS(10);
I2C_ReadNByte(0x96,ONE_BYTE_SUBA,0x00,data_buf2,0x03);
DelayNS(10);
ISendByte(0x98,0x8c);
DelayNS(10);
I2C_ReadNByte(0x98,ONE_BYTE_SUBA,0x00,data_buf3,0x03);
DelayNS(10);
ISendByte(0x9a,0x8c);
DelayNS(10);
I2C_ReadNByte(0x9a,ONE_BYTE_SUBA,0x00,data_buf4,0x03);
if(UART0_GetByte()==0x55)
{
    UART0_SendByte(data_buf1[2]);
    DelayNS(10);
    UART0_SendByte(data_buf2[2]);
    DelayNS(10);
    UART0_SendByte(data_buf3[2]);
    DelayNS(10);
    UART0_SendByte(data_buf4[2]);
    DelayNS(10);
}
本来读回的值应该是写进去的控制字0x8c,为什么显示的是两个FF呢?

使用特权

评论回复
发新帖 我要提问
您需要登录后才可以回帖 登录 | 注册

本版积分规则

14

主题

28

帖子

1

粉丝