ads1110

[复制链接]
2290|3
 楼主| liulicau 发表于 2007-10-17 13:38 | 显示全部楼层 |阅读模式
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;ISendByte(0x94,0x8c);<br />&nbsp;&nbsp;&nbsp;&nbsp;DelayNS(10);<br />&nbsp;&nbsp;&nbsp;&nbsp;I2C_ReadNByte(0x94,1,0x00,data_buf1,0x02);<br />&nbsp;&nbsp;&nbsp;&nbsp;DelayNS(10);<br />&nbsp;&nbsp;&nbsp;&nbsp;adc_value1=data_buf1[0]&lt&lt8||data_buf1[1];<br />&nbsp;&nbsp;&nbsp;&nbsp;if(data_buf1[1]||0x80==1)<br />&nbsp;&nbsp;&nbsp;&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;adc_value1=~adc_value1+1;<br />&nbsp;&nbsp;&nbsp;&nbsp;}<br />&nbsp;&nbsp;&nbsp;&nbsp;adc_value1=(adc_value1*2.048)/(32767*1);<br />&nbsp;&nbsp;&nbsp;&nbsp;DelayNS(10);<br />大家帮我看看程序这样写有什么问题吗?
ayb_ice 发表于 2007-10-17 13:57 | 显示全部楼层

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

这里逻辑混乱。。。<br />if(data_buf1[1]&nbsp;||&nbsp;0x80==1)<br />程序严重不规范,可读性极差。。。
 楼主| liulicau 发表于 2007-10-17 14:21 | 显示全部楼层

修改

&nbsp;&nbsp;&nbsp;&nbsp;if(data_buf1[1]&&0x80==0x80)<br />&nbsp;&nbsp;&nbsp;改成这样了,可以吗?
 楼主| liulicau 发表于 2007-10-17 16:17 | 显示全部楼层

lpc2138中I2C器件ads1110的读写

ISendByte(0x94,0x8c);<br />DelayNS(10);<br />I2C_ReadNByte(0x94,ONE_BYTE_SUBA,0x00,data_buf1,0x03);<br />DelayNS(10);<br />ISendByte(0x96,0x8c);<br />DelayNS(10);<br />I2C_ReadNByte(0x96,ONE_BYTE_SUBA,0x00,data_buf2,0x03);<br />DelayNS(10);<br />ISendByte(0x98,0x8c);<br />DelayNS(10);<br />I2C_ReadNByte(0x98,ONE_BYTE_SUBA,0x00,data_buf3,0x03);<br />DelayNS(10);<br />ISendByte(0x9a,0x8c);<br />DelayNS(10);<br />I2C_ReadNByte(0x9a,ONE_BYTE_SUBA,0x00,data_buf4,0x03);<br />if(UART0_GetByte()==0x55)<br />{<br />&nbsp;&nbsp;&nbsp;&nbsp;UART0_SendByte(data_buf1[2]);<br />&nbsp;&nbsp;&nbsp;&nbsp;DelayNS(10);<br />&nbsp;&nbsp;&nbsp;&nbsp;UART0_SendByte(data_buf2[2]);<br />&nbsp;&nbsp;&nbsp;&nbsp;DelayNS(10);<br />&nbsp;&nbsp;&nbsp;&nbsp;UART0_SendByte(data_buf3[2]);<br />&nbsp;&nbsp;&nbsp;&nbsp;DelayNS(10);<br />&nbsp;&nbsp;&nbsp;&nbsp;UART0_SendByte(data_buf4[2]);<br />&nbsp;&nbsp;&nbsp;&nbsp;DelayNS(10);<br />}<br />本来读回的值应该是写进去的控制字0x8c,为什么显示的是两个FF呢?
您需要登录后才可以回帖 登录 | 注册

本版积分规则

14

主题

28

帖子

1

粉丝
快速回复 在线客服 返回列表 返回顶部