MEGA48 两通道AD采样输出的是同一通道的数据原因

前两天用MEGA48PA测试程序,发现两个AD通道数据是一样的。搜到一个帖子https://bbs.csdn.net/topics/330077433看了也没解决,最后翻DATASHEET找到原因了。按着改了一下还真解决了。

DATASHEET里有下面这句话:
 If the result is left adjusted and no more than 8-bit precision is required, it is sufficient to read ADCH. Otherwise,ADCL must be read first, then ADCH, to ensure that the content of the Data Registers belongs to the same conversion. Once ADCL is read, ADC access to Data Registers is blocked. This means that if ADCL has been read, and a conversion completes before ADCH is read, neither register is updated and the result from the conversion is lost. When ADCH is read, ADC access to the ADCH and ADCL Registers is re-enabled.
意思就是需要先读取 ADCL的值再读取 ADCH的值,才可以刷新。 如果反过来 后读 ADCL,其实是第二次刷新的值。在读取 ADCH之前,里面的值是锁定不变的。

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值