完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
你好!
我真的很新鲜,当谈到PSoC编程,我只有一些经验与ARDUNO从一些项目在过去。 我现在的项目是从MUPU-6050中读取原始值,这需要使用I2C。我以前从未使用过,并且我正在努力处理所有的新命令,以及如何/何时使用它们。 我目前所要做的就是读取原始数据并将它们保存在不同的数组中。 我已经附上了我做了这么远的一个示意图,但是此刻我在黑暗中有点绊倒。 Coputs6JPG 21 K 以上来自于百度翻译 以下为原文 Hi! I am really fresh when it comes to PSoC programming, I only have a little experience with arduino from some projects in the past. My project now is to read out the RAW-values from the MPU-6050, which requires the use of I2C. I have never used this before, and I am struggeling with all the new commands, and how/when to use them. All I want to do so far is to read the RAW-data and save them in different arrays. I have attached a schematic of what I've made this far, but I am kind of stumbling in the dark at the moment.
|
|
相关推荐
11个回答
|
|
代码(远未完成):
包括: 空主程序() { *将初始化/启动代码放在这里* UTIN WRDATA; UTIN RDDATA; UIT8状态; UIT8读取标志; UIT8断裂; UTIN 8; UIT8温度; LCD-CHARESTATE(); LCD-CHARILCISDISPLAY(); I2CY11START(); I2Cy11EnabLeIn();//允许中断,这是大多数I2C操作所必需的。 WrDATA=117;//RG数 UTIN SLaveAdvices=0x68; 定义WRB缓冲区大小(2U) UIT8 8 SAMPLE段[ WRB BuffelyStand ]; /*CyGloalActuable;*//*不注释此行以启用全局中断。*/ (;) { 状态=I2CY1IGrimeStEnScript(SLaveAdvor,I2Cy11WrreWest-XFelyMod); 虽然(统计)!= I2CY11MSTRYNNOX错误; If(状态=I2Cy11MSTRyNoEnror)/检查是否完成传输没有错误 { I2CY11MistRealWestBuf(SLaveLoad, (UTI8*)SAMPLE段, WRB缓冲区大小, I2Cy11MoDEi完全完成XFER); LCD-CHARAL PrimtScript(“无错误”); CyDelay(100); } } } /*[]文件结束*/ 以上来自于百度翻译 以下为原文 Code (far from done): #include void main() { /* Place your initialization/startup code here */ uint8 wrData; uint8 rdData; uint8 status; uint8 readFlag; uint8 breakp; uint8 masterStatus; uint8 temp; LCD_Char_Start(); LCD_Char_ClearDisplay(); I2C_1_Start(); I2C_1_EnableInt(); //Enables interrupt, which is required for most I2C operations. wrData = 117; //Reg number uint8 slaveAddress = 0x68; #define WR_BUFFER_SIZE (2u) uint8 sample_segment[WR_BUFFER_SIZE]; /* CyGlobalIntEnable; */ /* Uncomment this line to enable global interrupts. */ for(;;) { status = I2C_1_MasterSendStart(slaveAddress, I2C_1_WRITE_XFER_MODE); while (stats != I2C_1_MSTR_NO_ERROR); if(status == I2C_1_MSTR_NO_ERROR) // Check if transfer is completed without errors { I2C_1_MasterWriteBuf(slaveAddress, (uint8 *)sample_segment, WR_BUFFER_SIZE, I2C_1_MODE_COMPLETE_XFER); LCD_Char_PrintString("NO ERROR"); CyDelay(100); } } } /* [] END OF FILE */ |
|
|
|
欢迎来到PSOCS的迷人世界!
乍一看: I2C是中断驱动的,因此必须启用全局中断。 在这里上传完整的项目总是明智的,所以我们都可以看看。要做到这一点,在创建者“文件& GT;创建工作区束(最小)”,然后上传由此产生的档案。 对于新手来说,C语言和编程通常也是个问题。当项目增长时,它变得越来越复杂,所以当你早点开始把它分成更小的部分时,它会对你有所帮助。因此,您的主体()可能看起来像 主体() { 初始化硬件(); (永远) { Read MMP6050(); 写入文件(); } } 记住:一个(纽约)项目变得复杂。而且,一个函数“RealMp6060-()”可以很容易地在你的下一个项目中重新使用。 快乐编码 鲍勃 以上来自于百度翻译 以下为原文 Welcome in the fascinating world of PSoCs! At very first sight: The I2C is interrupt-driven, so you MUST enable global interrupts. It is always advisable to upload the complete project here, so that we all can have a look at. To do so, in Creator "File -> Create Workspace Bundle (minimal)" and then upload the resulting archive here. For newbees usually C-language and programming turns out to be a problem, too. When the project grows it becomes more and more complex, so when you start early to divide it into smaller pieces it will help you. so your main() may look something like main() { InitializeHardware(); while(forever) { ReadMPU6050(); WriteToLCD(); } } Remember: a(ny) project gets complicated. And: A function "ReadMPU6050()" can easily be re-used in your next project. Happy coding Bob |
|
|
|
假设你连接SCL SDA在加速,没有辅助连接
哪个没有拉柱? 也有一个创造者使用I2C可以修改或项目 看看。 我看到的不同的版本,在注释部分原理图切换SDA,SCL,检查你的 版本。最后我看到你写的I2C,但不是阅读加速?那是配置吗? 写缓冲区中的AcEL命令? 问候,Dana。 以上来自于百度翻译 以下为原文 Assumption made you connected SCL to SDA on accel, not the AUX connections which do not have pullups ? Also in Creator there is a working example project using I2C you can modify or look at. I see on schematic different verison in notes section switched SDA, SCL, check your version. Lastly I see you writing to I2C, but not reading the accel ? Was that config commands for the accel in the write buffer ? Regards, Dana. |
|
|
|
你好
也许有点晚了,但是我很重视的一个例子,我没有测试采用Cypress PSoC 4先锋套件MPU-6050。 汉恩·S·南切兹 I2C.Test.Cyrj.CaseVo.01.Zip 318 K 以上来自于百度翻译 以下为原文 Hello Maybe a little late, but I'm attaching an example that I did to test MPU-6050 using Cypress PSoC 4 Pionner Kit. Hernán Sánchez
|
|
|
|
非常感谢您与我们分享您的项目!
你正在用MPU6050建造任何真正的项目吗? 鲍勃 以上来自于百度翻译 以下为原文 Thank you very much for sharing your project with us! Are you building any real project with that MPU6050? Bob |
|
|
|
你好,
我尝试与PSoC 5 LP097和MPU 6050相同。我不明白为什么我没有观察到COM端口上的数据。在COM端口上没有显示数据。 背景: 我在Windows上使用超级终端(9600波特,使用COM2)。我已经连接了10K的每一个SDL和SCL引脚电阻。除了这些引脚,我使用了VCC和GND。其余的引脚没有连接到PSoC。我在这里附上了项目包供参考。请帮助。 GYY521.ZIP 525 K 以上来自于百度翻译 以下为原文 Hello, I am trying the same with PSoC 5 LP097 and MPU 6050. I do not understand as to why I observe no data on the COM port. There is no data displayed on the COM port. Background:
|
|
|
|
您的错误不在UART中,而是在您的I2C处理中。对于i2c_mastersendstart()和i2c_mastersendrestart()最后的参数指标后,读取或写入。使用I2C的定义const。H:i2c_read_xfer_mode,i2c_write_xfer_mode写i2c_ack_data当奴隶,i2c_nak_data。
线 I2C.MasksEntRestRead(MPU6050A DeVice地址,0x00); 应该读 i2c_mastersendrestart(mpu6050_device_address,i2c_read_xfer_mode); 记住大多数I2C API返回一个状态显示错误。最好检查直到程序生效。 鲍勃 以上来自于百度翻译 以下为原文 Your error is not in the UART, but in your I2C handling. The last parameter for I2C_MasterSendStart() and I2C_MasterSendRestart() is the indicator for following reads or writes. Use the defined const from I2C.h : I2C_READ_XFER_MODE, I2C_WRITE_XFER_MODE and when writing to slave I2C_ACK_DATA, I2C_NAK_DATA. The line I2C_MasterSendRestart(MPU6050_DEVICE_ADDRESS, 0x00); should read I2C_MasterSendRestart(MPU6050_DEVICE_ADDRESS, I2C_READ_XFER_MODE); Keep in mind that most I2C APIs return a status which indicates an error. Better check that until program works. Bob |
|
|
|
ncmza 发表于 2019-2-21 15:52 嗨,鲍伯, 我不明白如何读取寄存器“MPU6050SaaAcelxxOutuh”给出了所有的14个字节,包括温度。在Hehan-An N.N.切兹提供的代码中的传感器值。难道不应该接触到各个寄存器并尝试读出内容吗? 在你做出改变后,我观察到以下行为: 1。我可以从MPU6050寄存器读取字节,当我不连接用于SDA和SCL的上拉电阻。在连接上拉寄存器的情况下,命令“I2C.MasMeStEnScript(MPU6050A DeVice地址,I2CX Read EX-FEXYMODE)”在返回错误-I2CYMSTRYNOTYRADE中失败。在这种情况下不需要上拉电阻吗? 2。在读取一些随机字节(大约14×16或14×19)之后,从设备停止响应。命令“I2C.MistWrrestEngEnter字节(Reg)”失败,返回值为I2CyMSTRyRelyLBJNAK。 三。如何显示从寄存器读取到超级终端的值。我能看到的是一些随机字符写在终端上。 你能提供一些建议吗? 以上来自于百度翻译 以下为原文 Hi Bob, I do not understand how reading out the register "MPU6050_RA_ACCEL_XOUT_H" gives all the 14 bytes including the temp. sensor values in the code provided by Hernán Sánchez. Isn't it supposed to be reached out to individual registers and try reading out the content? And after making the changes suggested by you, I observe the following behaviour - 1. I am able to read the bytes from the MPU6050 registers, when I do not connect the PULLUP resistors for SDA and SCL. In case of PULL UP registers connected, the command - " I2C_MasterSendStart(MPU6050_DEVICE_ADDRESS, I2C_WRITE_XFER_MODE) " fails with a return error - I2C_MSTR_NOT_READY. Are pull up resistors not required in this case? 2. After reading some random bytes (approx. 14*16 or 14*19), the slave device stops responding. The command - " I2C_MasterWriteByte(reg)" fails with a return value - I2C_MSTR_ERR_LB_NAK. 3. How do I display the values read from the registers to the Hyperterminal. All I can see is some random characters being written on the terminal. Could you please provide some tips on this? |
|
|
|
你能发布你的实际项目状态吗?
鲍勃 以上来自于百度翻译 以下为原文 Can you post your actual project state, please. Bob |
|
|
|
好的,所以我做了一些改变我的代码处理I2C API的返回值,现在我能够从微处理器6050得到恒定的数据。但是,我接收的数据是完全零的。附加项目包以供参考。
邮编 251字节 Cyp521.Cyrjj.Access 01Y0.Zip 522.9 K 以上来自于百度翻译 以下为原文 OK, so I made some more changes to my code handling the return values from the I2C APIs, and now I am able to get constant data from the MPU 6050. However, the data I receive are completely zeroes. Attaching the project bundle for reference.
|
|
|
|
您将十六进制值转换为ASCII是不正确的。考虑一个函数时,使两个十六进制数字,简单地增加0x30不会转换。
你可以使用sprintf()转换和格式转换成一个缓冲,您可以发送到串口。不要忘记设置堆的大小来0x0200(设计范围的资源系统观)。 鲍勃 以上来自于百度翻译 以下为原文 Your conversion of hex values to ASCII is not correct. Consider that a uint8 keeps two hex digits, simply adding 0x30 will not convert them. You might use sprintf() to convert and format into a buffer which you can send to UART. Do not forget to set the heap size to 0x0200 (System view of design wide resources). Bob |
|
|
|
只有小组成员才能发言,加入小组>>
754个成员聚集在这个小组
加入小组2106 浏览 1 评论
1853 浏览 1 评论
3671 浏览 1 评论
请问可以直接使用来自FX2LP固件的端点向主机FIFO写入数据吗?
1788 浏览 6 评论
1536 浏览 1 评论
CY8C4025LQI在程序中调用函数,通过示波器观察SCL引脚波形,无法将pin0.4(SCL)下拉是什么原因导致?
572浏览 2评论
CYUSB3065焊接到USB3.0 TYPE-B口的焊接触点就无法使用是什么原因导致的?
424浏览 2评论
CX3连接Camera修改分辨率之后,播放器无法播出camera的画面怎么解决?
438浏览 2评论
386浏览 2评论
使用stm32+cyw43438 wifi驱动whd,WHD驱动固件加载失败的原因?
916浏览 2评论
小黑屋| 手机版| Archiver| 电子发烧友 ( 湘ICP备2023018690号 )
GMT+8, 2024-12-25 04:33 , Processed in 1.231675 second(s), Total 98, Slave 82 queries .
Powered by 电子发烧友网
© 2015 bbs.elecfans.com
关注我们的微信
下载发烧友APP
电子发烧友观察
版权所有 © 湖南华秋数字科技有限公司
电子发烧友 (电路图) 湘公网安备 43011202000918 号 电信与信息服务业务经营许可证:合字B2-20210191 工商网监 湘ICP备2023018690号