PCF8591求助!!!

xinyu791 2014-01-16 01:47:55
高手给看一下,pcf8591读取AD转换数值

//channel设为0x01还是0x41????

unsigned int ReadAD_Channel(unsigned int Channel ){

unsigned int Data;

Start();
Send( WriteAddress ); //发送写地址
Send( Channel ); //发送读控制字
Start();
Send( ReadAddress ) ) //发送读地址
Data = ReceiveChar(); //读一个char
Stop();
return Data; //返回值
}

1.我设置为0x01时得到的数字量不正常,而0x41却正确??需要允许模拟输出??
2.IIC总线在读数据时一定要用“伪写”吗??有无其它方法??
...全文
251 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
Binzo 2014-01-20
  • 打赏
  • 举报
回复
引用
1.我设置为0x01时得到的数字量不正常,而0x41却正确??需要允许模拟输出?? 2.IIC总线在读数据时一定要用“伪写”吗??有无其它方法??
1 不需要。 2 看你单片机硬件支不支持IIC,看手册。
xinyu791 2014-01-17
  • 打赏
  • 举报
回复
一楼,刚试了连续接收两次,第二次输出的是0。 用0x00,0x01,0x02,0x03,小于128输出正常,128到255输出值全为240。 (我接在电位器上0—5v连续可调)
mangoalx 2014-01-16
  • 打赏
  • 举报
回复
If the auto-increment mode is desired in applications where the internal oscillator is used, the analog output enable flag must be set in the control byte (bit 6). This allows the internal oscillator to run continuously, by this means preventing conversion errors resulting from oscillator start-up delay. The A/D converter uses the successive approximation conversion technique. The on-chip D/A converter and a high-gain comparator are used temporarily during an A/D conversion cycle. 不过你似乎不是这种情况。datasheet说每次读操作会触发一次转换,同时发送上一次转换的结果。你可以连读两次试试,或许第二次结果就对了。

27,375

社区成员

发帖
与我相关
我的任务
社区描述
硬件/嵌入开发 单片机/工控
社区管理员
  • 单片机/工控社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧