树莓派I2C修改传输速率及兼容repeated start iic设备
2016-05-05 18:13
309 查看
1,修改传输速率
默认状态下传输速率为100khz,使用如下命令查看:sudo cat /sys/module/i2c_bcm2708/parameters/baudrate
你会看到显示100000,表示为100khz。
修改步骤如下:
1,sudo nano /boot/config.txt
2,在打开的文件中添加一行dtparam=i2c1_baudrate=50000(假设我们将其设置为50khz).
3,sudo
reboot
打开后重新查看 你会发现速率已经改为50000了。
2,树莓派修改iic协议让其兼容repeated start i2c设备,让此类设备可以正常运行。
我在使用MMA7660FC这个三轴加速度传感器时就碰到这样的问题,开始软件写的没有问题,但是怎么弄 xyz轴数据都一样,困扰了很久终于发现树莓派iic协议不支持这样的iic设备。
mma7660fc数据手册中这样说:
MMA7660FC is read using it’s internally stored register address as address pointer, the same way the
stored register address
is used as address pointer for a write. The pointer generally auto-increments after each data byte is read using the same rules
as for a write. Thus, a read is initiated by first configuring the device’s register address by performing a write (Figure 12) followed
by a repeated start. The Master Write address is 1001 1001 (0x99). The master can now read ''n' consecutive bytes from it, with
the first data byte being read from the register addressed by the initialized register address.
接下来怎么改变让其兼容呢?
步骤如下:
1:sudo su-
2:echo -n 1 > /sys/module/i2c_bcm2708/parameters/combined
3:exit
这样你会发现文件combined中的 N 变成了 Y
接下来你就可以使用repeated start 类型的Iic设备了。
参考英文如下:
Using:
Raspberry Pi 2 Model B
Python 2.7
python-smbus
i2c-tools
I was having problems with a device that required combined (repeated start) mode operation to
work. After flailing around for a couple of days (getting smarter about I2C, Python, R-Pi and Linux), I found the information on this site:
http://ciaduck.blogspot.com/
Lastly, the MPL3115A2 requires a proper repeated start command in it's I2C communication. Raspberry
Pi doesn't do this out of the box, but there is a kernel module that can be enabled to make it perform repeated start correctly. Run the following commands to enable repeated start on the Pi:
sudo su -
echo -n 1 > /sys/module/i2c_bcm2708/parameters/combined
exit
More details about the repeated start problem can be found here:
viewtopic.php?f=44&t=15840&start=25
After setting the contents of the file from “N” to “Y”, my device started working, with the scope
showing that the Stop command was no longer being issued in the middle of the read_word_data(addr, cmd) instruction.
相关文章推荐
- POJ 2251 Dungeon Master(三维简单广搜)
- Spark集群搭建与测试
- 添加Pods后,import无提示的解决办法
- 点分十进制IP校验、转换,掩码校验
- 如何调整Linux系统为正确时区
- u-boot移植2:支持 nandflash 的读写
- 提高scroll性能
- objective-C之NSTimer
- PHP面试(二)
- 职业生涯人物访谈作业格式
- Android 编程下 Touch 事件的分发和消费机制
- CString中find_first_of和find_last_of()函数
- Android EditText的设置
- android弱引用和软应用的详解
- 如何使用Markdown编辑器写博客
- Win10系统开启Linux Bash命令行
- 【排序算法】——冒泡排序算法
- Spark定制班第3课:通过案例对SparkStreaming 透彻理解三板斧之三:解密SparkStreaming运行机制和架构进阶之Job和容错
- apache的common项目如何导入eclipse中
- 整数分解成不同加数的最大乘积