完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
你好,
如何从主从I2C主机读取更多的256字节?主从式I2C都使用PSoC 3。 从I2C子地址地址大小(位)=16位。 Type的结构 { Uti16STAT;/*R/W变量*// uTUN16CMD;/*R/W变量*// UTIN 16伏[ 3 ]〔3〕;/*R/W变量*// UIT1616 STR [6U];/*只读到I2C*/ EZI2CZ RIGS; EZI2CL RESADI2CREGS; I2CYUDBJMSTMASTRADBUFF()函数:从从属设备自动读取数据的整个缓冲区。我们不能使用这个函数来读取单个数组数据或特定位置的结构。 我们尝试下面的代码,但无法提供正确的数据。 I2CuUDbMMMistCurrStaseUs(); CyDelay(2); I2CuUDbMyMaultRead Bufff(EZI2CySLaveEdAdDR,(UTIN 8*)和;Redi2Curgs.Valts〔0〕,SIZEOF(Redi2Curs.Vults(0)),I2CuUdBMMMODEYRESULTEXXFER; 当(02= =(I2CuUdBMMGestStaseUs)和;I2CuUdBMyMSTATOR-RDY-CMPLT)时 { } I2CuUDbMyMaultRead Bufff(EZI2CySLaveEdAdDR,(UTIN 8*)和;Redi2Curgs.Valts〔1〕,SIZEOF(Redi2Curs.Vults(1)),I2CuUdBMMMODEYRESULTEXXFER; 当(02= =(I2CuUdBMMGestStaseUs)和;I2CuUdBMyMSTATOR-RDY-CMPLT)时 { } LCDA PrimtIn 16(Redi2Curgs.Valts〔0〕〔0〕); LCDA PrimtIn 16(Redi2Curgs.Valts〔0〕〔1〕); LCDA PrimtIn 16(Redi2Curgs.Valts〔0〕〔2〕); 它只通过下面的代码工作。我们需要从奴隶读取更多的256字节的问题。我们怎样才能做到呢? I2CuUDbMyMaultRead Bufff(EZI2CYSLaveEdAdDR,(UTIN 8*)和ReAD2CREGS,SIZEOF(ReAD2CREGS),I2CUDUBMYMDEDEX完成EXEXEXXFER); 谢谢 以上来自于百度翻译 以下为原文 Hi, How we can read I2C master more then 256 bytes from slave? Both Master and slave I2C are using PSOC 3. Slave I2C Sub_Address size(bits) = 16 bits. typedef struct _EZI2C_REGS { uint16 stat; /* R/W variable */ uint16 cmd; /* R/W variable */ uint16 volts[3][3]; /* R/W variable */ uint16 str[6u]; /* Read only to I2C */ } EZI2C_REGS; EZI2C_REGS readI2cRegs; I2C_UDB_M_MasterReadBuf() function :automatically reads an entire buffer of data from a slave device. We can't use this function to read single array data or specific location to the stucture. We try the code on following and it failed to provide correct data. I2C_UDB_M_MasterClearStatus(); CyDelay(2); I2C_UDB_M_MasterReadBuf(EZI2C_SLAVE_ADDR, (uint8 *)&readI2cRegs.volts[0], sizeof(readI2cRegs.volts[0]) , I2C_UDB_M_MODE_COMPLETE_XFER); while(0u == (I2C_UDB_M_MasterStatus() & I2C_UDB_M_MSTAT_RD_CMPLT)) { } I2C_UDB_M_MasterReadBuf(EZI2C_SLAVE_ADDR, (uint8 *)&readI2cRegs.volts[1], sizeof(readI2cRegs.volts[1]) , I2C_UDB_M_MODE_COMPLETE_XFER); while(0u == (I2C_UDB_M_MasterStatus() & I2C_UDB_M_MSTAT_RD_CMPLT)) { } LCD_PrintInt16(readI2cRegs.volts[0][0]); LCD_PrintInt16(readI2cRegs.volts[0][1]); LCD_PrintInt16(readI2cRegs.volts[0][2]); It only working by following code. The problem that we need to read more then 256 byte from the slave. How we can do it? I2C_UDB_M_MasterReadBuf(EZI2C_SLAVE_ADDR, (uint8 *)&readI2cRegs, sizeof(readI2cRegs) , I2C_UDB_M_MODE_COMPLETE_XFER); Thanks |
|
相关推荐
7个回答
|
|
看看你的代码,你读过伏特(0)和伏特(1),两个* 3字节一般只读取更多字节,重复读操作…对于(i=0;i和lt;256;i++){…VoLT=Read();//Read函数在这里}您想读取更多的256字节在哪里读取?伏特为3×3=9字节。
以上来自于百度翻译 以下为原文 Look through your code You had read volts[0] and volts[1], two*3 byte only Generally to read more bytes, Repeat the read action ... for(i=0;i<256;i++) { ... volts= READ(); // read function here } You said want to read more 256 bytes Where to read? volts is 3*3=9 bytes |
|
|
|
我附上了示例代码。我们不能做正确的数组显示之前,我们不能继续读取,然后从奴隶256字节。
Redi2Curgs.伏特[ 1 ]〔0〕 Redi2Curgs.伏特[ 1 ]〔1〕 Redi2Curgs.伏特[ 1 ]〔2〕 以上来自于百度翻译 以下为原文 I have attached the example code. We can't do correct the array shown before we can't proceed to read more then 256 bytes from the slave. readI2cRegs.volts[1][0] readI2cRegs.volts[1][1] readI2cRegs.volts[1][2] |
|
|
|
可能奴隶没有被配置为具有超过256个字节的红色。恐怕你得给我们看一点你的代码,因为在I2C中对于传输的字节数没有限制。
如果你能公开展示你的项目,我们都可以很容易地发现并发现任何缺陷。要做到这一点,在创建者使用“文件& GT;创建工作区束”,并将结果文件附加到你的下一个帖子(不要使用Chrome,上传经常不起作用)。 鲍勃 以上来自于百度翻译 以下为原文 Probably the slave is not configured to have more than 256 bytes red. I'm afraid you'll have to show us a bit more of your code since there is no limitation in I2C for the number of bytes to transmit. If you can show your project(s) openly, we all could have a look at and will find any flaw easily. To do so, in Creator use "File -> Create Workspace Bundle" and attach the resulting files to your next posts (do NOT use Chrome, upload often doesn't work) Bob |
|
|
|
Ooopsi,我太匆忙了!I2C API只接受一个UIT8作为主和从的计数。
通常的解决方法是以较小的块读取,并且从属器必须管理在读取前一个块之后的每个源块的源地址。 鲍勃。 以上来自于百度翻译 以下为原文 Ooopsi, I was too hasty! The I2C APIs only accept an uint8 as the count for master and slave. Usual workaround is to read in smaller chunks and the slave has to manage setting up the source address for each chunk after the previous has been read. Bob. |
|
|
|
我们解决了这个问题。
我们的最大错误是,我们使用了函数2CyUbbMyMaultRead BuffFER(),这个函数从255字节内的从属设备读取数据。对于255字节以上的数据,它将无法工作。 当我们使用函数2CuUbbMyMistRead Read()时,它工作得很好,我们测试了用316字节读取,并且检查了所有数据是正确的。 以上来自于百度翻译 以下为原文 We resolved the problem. Our big mistake that we are using the function I2C_UDB_M_MasterReadBuf(), this function read entire buffer of data from a slave device within 255 bytes. It won't work for data more then 255 bytes. It works well when we are using the function I2C_UDB_M_MasterReadByte(), we tested to read with 316 bytes and we checked all the data is correct. |
|
|
|
你好,
EZI2C从设备必须配置为16位子地址,用于读取超过256字节。 I2C主读API支持只读取256字节的时间,因为计数是UTI8类型。因此,您需要多次调用主读API,每次重置EZI2C偏移地址。 以上来自于百度翻译 以下为原文 Hi, The EzI2C slave has to configured for 16bit sub address for reading more than 256 bytes. I2C Master Read API supports reading only 256bytes at time since the count is a uint8 type. So you need to call the MAster Read API multiple times, resetting the EzI2C offset address each time. |
|
|
|
我在这里附上一个示例项目,从EZI2C从使用UDB I2C主机读取256字节。希望它会有用。
EZI2CY16BIT 5.1兆字节 以上来自于百度翻译 以下为原文 I am attaching here an example project to read more that 256 bytes from EZI2C slave using UDB I2C master. Hope it will be useful. |
|
|
|
只有小组成员才能发言,加入小组>>
754个成员聚集在这个小组
加入小组2100 浏览 1 评论
1846 浏览 1 评论
3665 浏览 1 评论
请问可以直接使用来自FX2LP固件的端点向主机FIFO写入数据吗?
1782 浏览 6 评论
1532 浏览 1 评论
CY8C4025LQI在程序中调用函数,通过示波器观察SCL引脚波形,无法将pin0.4(SCL)下拉是什么原因导致?
561浏览 2评论
CYUSB3065焊接到USB3.0 TYPE-B口的焊接触点就无法使用是什么原因导致的?
413浏览 2评论
CX3连接Camera修改分辨率之后,播放器无法播出camera的画面怎么解决?
434浏览 2评论
380浏览 2评论
使用stm32+cyw43438 wifi驱动whd,WHD驱动固件加载失败的原因?
907浏览 2评论
小黑屋| 手机版| Archiver| 电子发烧友 ( 湘ICP备2023018690号 )
GMT+8, 2024-12-20 15:48 , Processed in 1.135058 second(s), Total 90, Slave 74 queries .
Powered by 电子发烧友网
© 2015 bbs.elecfans.com
关注我们的微信
下载发烧友APP
电子发烧友观察
版权所有 © 湖南华秋数字科技有限公司
电子发烧友 (电路图) 湘公网安备 43011202000918 号 电信与信息服务业务经营许可证:合字B2-20210191 工商网监 湘ICP备2023018690号