完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
|
我们的设备挂了一个i2c的传感器,psoc6当master,通过以下的示例代码来读写传感器的寄存器
{ cy_stc_scb_i2c_master_xfer_config_t transfer; uint8_t readBuffer [5UL]; uint8_t writeBuffer[2UL] = {0U, 5U}; /* Configure write transaction */ transfer.slaveAddress = 0x08U; transfer.buffer = writeBuffer; transfer.bufferSize = sizeof(writeBuffer); transfer.xferPending = true; /* Do not generate Stop condition at the end of transaction */ /* Initiate write transaction. * The Start condition is generated to begin this transaction. */ (void) Cy_SCB_I2C_MasterWrite(SCB3, transfer, i2cContext); /* Wait for transaction completion */ while (0UL != (CY_SCB_I2C_MASTER_BUSY Cy_SCB_I2C_MasterGetStatus(SCB3, i2cContext))) { } /* Configure read transaction */ transfer.buffer = readBuffer; transfer.bufferSize = sizeof(readBuffer); transfer.xferPending = false; /* Generate Stop condition the end of transaction */ /* Initiate read transaction. * The ReStart condition is generated to begin this transaction because * previous transaction was completed without Stop. */ (void) Cy_SCB_I2C_MasterRead(SCB3, transfer, i2cContext); /* Wait for transaction completion */ while (0UL != (CY_SCB_I2C_MASTER_BUSY Cy_SCB_I2C_MasterGetStatus(SCB3, i2cContext))) { } } 但调试中发现有很大概率在下面的代码中死循环,while (0UL != (CY_SCB_I2C_MASTER_BUSY Cy_SCB_I2C_MasterGetStatus(SCB3, i2cContext))) { } 请问这是啥原因呢?是i2c初始化没做好?还是i2c总线上有冲突?(但总线上我就挂了一个设备)谢谢! |
|
相关推荐
1个回答
|
|
|
根据你说的这个现象,会不会跟你连接的GSENSOR有关系,你可以仔细按下他的技术手册,对于初始化是不是需要一个上电的稳定时间之类的。
|
|
|
|
|
你正在撰写答案
如果你是对答案或其他答案精选点评或询问,请使用“评论”功能。
【瑞萨RA6E2】瑞萨E2S软件安装过程,等待过程玩下97_e2 studio_ZGZZ
234 浏览 0 评论
514 浏览 0 评论
【原创】【RA4M2-SENSOR开发板评测】低功耗+USB综合测试
826 浏览 0 评论
1366 浏览 2 评论
814 浏览 0 评论
【youyeetoo X1 windows 开发板体验】少儿AI智能STEAM积木平台
16911 浏览 31 评论
/9
小黑屋| 手机版| Archiver| 电子发烧友 ( 湘ICP备2023018690号 )
GMT+8, 2025-12-3 05:02 , Processed in 0.630447 second(s), Total 72, Slave 54 queries .
Powered by 电子发烧友网
© 2015 bbs.elecfans.com
关注我们的微信
下载发烧友APP
电子发烧友观察
版权所有 © 湖南华秋数字科技有限公司
电子发烧友 (电路图) 湘公网安备 43011202000918 号 电信与信息服务业务经营许可证:合字B2-20210191

淘帖
512