完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
我尝试使用从PSoC社区(MPU 6050——需要帮助读取传感器值)获取的代码之一,并根据社区提出的最新API推荐的更改。当我运行它时,它说MPU6050无法连接。我想知道在I2C和PSoC的专业人士能否帮助我解决这个问题。我在这里附上我的计划。
提前感谢: 阿波奥瓦 MPU6050 DKW PSoC修订版V2.CyWRK.SARVEVE01.ZIP 2兆字节 以上来自于百度翻译 以下为原文 I am trying to use one of the codes taken from PSOC community (MPU 6050 - Need help reading sensor values), and made the changes as recommended by latest API as suggested by the community. When I run it, it says that MPU6050 failed to connect. I wonder if someone pro at i2c and psoc could help me resolve that issue. I am attaching my project here. Thanks in advance: Apoorva |
|
相关推荐
5个回答
|
|
每个I2C API返回一个可以分析的状态。返回值!= 0表示一个错误,在适当的.h文件中发现的描述。
一些.h文件丢失,因此编译器很难找到声明和定义。 鲍勃 以上来自于百度翻译 以下为原文 Every I2C API returns a status which you can analyze. Values returned != 0 indicate an error, description found in the appropriate .h file. Some .h files are missing, so it is difficult to have the compiler find declarations and definitions. Bob |
|
|
|
ncmza 发表于 2018-11-1 15:54 鲍勃, 谢谢你的回复。 MpU6050库包含在项目中,所以我不确定哪一个.h文件丢失。代码编译并在UART上打印数字。只是这些读数在MPU6050中是不可用的。 在我下载文件的页面上,您回答了I2C API改变了。塞巴斯蒂安后来用下面的代码修改了那部分: 事业单位的旧代码 无效I2CeRADEnter(UIT88T DEVADDR,UIT88T RADADR,UIT88T长度,UIT88T*值){ UIT88T I=0; I2CYMPU6050AI2CMASTESTESTART(DEVADDR,I2CYMPU6050AI2CX Wrad EX-Felx模式); I2CYMPU6050II2CMASTEMWRITE字节(RADADR); I2CYMPU6050AI2CMASTESTEnReST(DeDADDR,I2CYMPU6050AI2CX Read x Felx模式); 而(i++lt;(长度-1)){ *值+++=I2CYMPU6050AI2CMASTRADEDALVEL字节(I2CYMPU6050AI2CYACKYDATA); } *值=I2CYMPU6050AI2CMASTRADESENTELL字节(I2CYMPU6050AI2CY-NAKYDATA); I2CYMPU6050AI2CMASTESTESTSTOP(); } 公共事业=新法规 无效I2CeRADEnter(UIT88T DEVADDR,UIT88T RADADR,UIT88T长度,UIT88T*值){ UIT88T I=0; I2CYMPU6050AI2CMASTESTESTART(DEVADDR,I2CYMPU6050AI2CX WrreEX-FelyMod,0); I2CYMPU6050AI2CMASTEMWRITE字节(RADADR,0); I2CYMPU6050AI2CMASTESTEnRead(DeDADDR,I2CYMPU6050AI2CYRADYXFEXY MODE,0); 而(i++lt;(长度-1)){ I2CYMPU6050AI2CSTMASTRADEQUALTELL(I2CYMPU6050II2CYACKY DATA,Value++,0); } I2CYMPU6050AI2CSTMASTRADEQUALTELL(I2CYMPU6050II2CYNKAL数据,值,0); I2CYMPU6050AI2CMASTESTONSTOP(0); } 事业单位 恐怕这部分代码会影响阅读部分。你能帮帮我吗? 最好的, 阿波奥瓦 以上来自于百度翻译 以下为原文 Bob, Thanks for replying. The MPU6050 library is included in the project-- so i am not sure which .h files are missing. The code compiles, and prints numbers on the UART. Just that readings are not available the MPU6050. On the page from where I downloaded the file, you had replied that i2c API changed. Sebastian later modified that part with the following piece of the code: =============================old code=========================================== void I2CReadBytes(uint8_t devAddr, uint8_t regAddr, uint8_t length, uint8_t *value) { uint8_t i=0; I2C_MPU6050_I2CMasterSendStart(devAddr, I2C_MPU6050_I2C_WRITE_XFER_MODE); I2C_MPU6050_I2CMasterWriteByte(regAddr); I2C_MPU6050_I2CMasterSendRestart(devAddr, I2C_MPU6050_I2C_READ_XFER_MODE); while (i++ < (length-1)) { *value++ = I2C_MPU6050_I2CMasterReadByte(I2C_MPU6050_I2C_ACK_DATA); } *value = I2C_MPU6050_I2CMasterReadByte(I2C_MPU6050_I2C_NAK_DATA); I2C_MPU6050_I2CMasterSendStop(); } =============================new code=========================================== void I2CReadBytes(uint8_t devAddr, uint8_t regAddr, uint8_t length, uint8_t *value) { uint8_t i=0; I2C_MPU6050_I2CMasterSendStart(devAddr, I2C_MPU6050_I2C_WRITE_XFER_MODE,0); I2C_MPU6050_I2CMasterWriteByte(regAddr,0); I2C_MPU6050_I2CMasterSendRestart(devAddr, I2C_MPU6050_I2C_READ_XFER_MODE,0); while (i++ < (length-1)) { I2C_MPU6050_I2CMasterReadByte(I2C_MPU6050_I2C_ACK_DATA,value++,0); } I2C_MPU6050_I2CMasterReadByte(I2C_MPU6050_I2C_NAK_DATA,value,0); I2C_MPU6050_I2CMasterSendStop(0); } =============================================================================== I am afraid that this the part of the code that is affecting the reading part. Could you please help me? Best, Apoorva |
|
|
|
你好,
请从第三方博客测试这个特定代码。 山姆的博客:从MPU-6050获得滚动、俯仰和偏航 这只能与旧版本的创建者一起工作。首先,如果项目在老版本的创建者中工作得很好,这样我们就可以确认它不是一个硬件问题。 谢谢, 希马 以上来自于百度翻译 以下为原文 Hello, Kindly test this particular code from a third party blog. Sam's Blog : Getting Roll, Pitch and Yaw from MPU-6050 This would work only with old version of Creator. First try if the project is working fine in the older version of Creator so that we can confirm its not a hardware issue. Thanks, Hima |
|
|
|
谢谢,Hima。实际上,这是旧代码,I2C协议从那时起就发生了变化。PSoC4.1在编译此代码时抛出错误。 我发现了错误的原因。SCL和SDA之间的上拉电阻没有被正确地连接,这就是通信被卡住了。 最好的, 阿波奥瓦 以上来自于百度翻译 以下为原文 Thanks, Hima. Actually, this is the old code, and i2c protocol has changed since then. PSOC4.1 throws error while compiling this code. I found the reason for the error. The pull-up resistance between SCL and SDA wasn't connected properly, which was communication was stuck. Best, Apoorva |
|
|
|
zhuo85 发表于 2018-11-1 16:32 简单解XD 有时很难找到错误和问题… 以上来自于百度翻译 以下为原文 Simple solution XD It's hard to find bugs and issues sometimes... |
|
|
|
只有小组成员才能发言,加入小组>>
751个成员聚集在这个小组
加入小组2063 浏览 1 评论
1822 浏览 1 评论
3630 浏览 1 评论
请问可以直接使用来自FX2LP固件的端点向主机FIFO写入数据吗?
1758 浏览 6 评论
1507 浏览 1 评论
CY8C4025LQI在程序中调用函数,通过示波器观察SCL引脚波形,无法将pin0.4(SCL)下拉是什么原因导致?
501浏览 2评论
CYUSB3065焊接到USB3.0 TYPE-B口的焊接触点就无法使用是什么原因导致的?
352浏览 2评论
CX3连接Camera修改分辨率之后,播放器无法播出camera的画面怎么解决?
408浏览 2评论
353浏览 2评论
使用stm32+cyw43438 wifi驱动whd,WHD驱动固件加载失败的原因?
850浏览 2评论
小黑屋| 手机版| Archiver| 电子发烧友 ( 湘ICP备2023018690号 )
GMT+8, 2024-11-19 07:45 , Processed in 1.263966 second(s), Total 108, Slave 91 queries .
Powered by 电子发烧友网
© 2015 bbs.elecfans.com
关注我们的微信
下载发烧友APP
电子发烧友观察
版权所有 © 湖南华秋数字科技有限公司
电子发烧友 (电路图) 湘公网安备 43011202000918 号 电信与信息服务业务经营许可证:合字B2-20210191 工商网监 湘ICP备2023018690号