完善资料让更多小伙伴认识你,还能领取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有关系,你可以仔细按下他的技术手册,对于初始化是不是需要一个上电的稳定时间之类的。
|
|
|
|
你正在撰写答案
如果你是对答案或其他答案精选点评或询问,请使用“评论”功能。
7 浏览 0 评论
26 浏览 1 评论
基于瑞萨FPB-RA4E2智能床头灯项目——1编译环境搭建与点亮驱动ws2812全彩LED
13 浏览 0 评论
嵌入式学习-飞凌嵌入式ElfBoard ELF 1板卡-LCD显示图片编程示例之介绍mmap
644 浏览 0 评论
《DNESP32S3使用指南-IDF版_V1.6》第二章 常用的C语言知识点
1000 浏览 0 评论
【youyeetoo X1 windows 开发板体验】少儿AI智能STEAM积木平台
11770 浏览 31 评论
小黑屋| 手机版| Archiver| 电子发烧友 ( 湘ICP备2023018690号 )
GMT+8, 2024-11-24 09:43 , Processed in 0.617210 second(s), Total 76, Slave 58 queries .
Powered by 电子发烧友网
© 2015 bbs.elecfans.com
关注我们的微信
下载发烧友APP
电子发烧友观察
版权所有 © 湖南华秋数字科技有限公司
电子发烧友 (电路图) 湘公网安备 43011202000918 号 电信与信息服务业务经营许可证:合字B2-20210191 工商网监 湘ICP备2023018690号