Cypress技术william hill官网
直播中

郑盼

7年用户 212经验值
私信 关注
[问答]

PSOC BLE-4和MPU-6050之间的I2C通信错误

我尝试使用从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)

王琳

2018-11-1 17:09:18
每个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
举报

郑盼

2018-11-1 17:26:41
引用: ncmza 发表于 2018-11-1 15:54
每个I2C API返回一个可以分析的状态。返回值!= 0表示一个错误,在适当的.h文件中发现的描述。
一些.h文件丢失,因此编译器很难找到声明和定义。
鲍勃

鲍勃,
谢谢你的回复。
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
举报

鲁玉萍

2018-11-1 17:35:40
你好,
请从第三方博客测试这个特定代码。
山姆的博客:从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
举报

郑盼

2018-11-1 17:47:32
引用: 60user67 发表于 2018-11-1 16:20
你好,
请从第三方博客测试这个特定代码。
山姆的博客:从MPU-6050获得滚动、俯仰和偏航

谢谢,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
举报

更多回帖

发帖
×
20
完善资料,
赚取积分