完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
电子发烧友论坛|
大家好,
IAM使用PSoC4000作为从控制器, 我已经配置了从控制器作为100kbp-波特, 主控是100kb/s的写/读,我们使用微芯片的PIC24系列作为主器件。 我检查过,当传输到主设备时,总是出现从PoSOC4000溢出的情况。 还想知道如何在PSoC4000上清除TXFIFO, 在读取字节之后,应该从主端发送任何NACK/ACK吗?? 请尽快帮助我解决项目中的疑难问题。 谢谢和问候, 普拉莫德卡希亚普 以上来自于百度翻译 以下为原文 Hello all, Iam using psoc4000 as slave controller, I have configured slave controller as 100kbps baud, Also master is write/reading at 100kbps, we are using pic24 series from microchip as master device. I have checked that Overflow condition slave psoc4000 always occurs when transmitting to master device, Also want to know how to clear the tx fifo at psoc4000, Should Any NACK/ACK should be transmitted from master end after reading the bytes?? Please can help me on these doubt as project is under critical situation ASAP . Thanks and regards, Pramod Kashyap |
|
相关推荐
18个回答
|
|
|
主机读取的最后一个字节应该是裸的。地址可能存在误解,PSoC I2C使用7位地址,RW位被自动追加。我不知道你的照片需要什么。
FIFO通过读取字节清除,直到状态告诉FIFO为空。 鲍勃 以上来自于百度翻译 以下为原文 The last byte read by master should be NAKed. There might be a misunderstanding with the addresses, PSoC I2C uses 7 bit addresses, the RW bit is appended automatically. I don't know what your PIC requires. FIFO is cleared by reading bytes until status tells fifo empty. Bob |
|
|
|
|
ncmza 发表于 2018-11-12 10:59 你好,鲍伯, 谢谢你的回应, 我知道,当主机接收最后一个字节时,PSOC 4设备需要NACK, 我应该读到255,这意味着溢出状态发生在PSoC 4中吗? 当PSOC 4发生溢出情况时,I2C RD指针是否应清除? 从PoSO4设备读取PIC控制器时的问题是在PIC控制器侧读取最新值时,从TXFIFO寄存器中读取旧值; 请澄清这一问题。 谢谢和问候, Pramod Kashyap 以上来自于百度翻译 以下为原文 Hello Bob, Thanks for response, I got to know that NAK is required by psoc 4 device when Master receives last byte, Should I read until 255 that means Overflow condition occurs in psoc 4? should the i2c Rd pointer be cleared when Overflow condition occurs in psoc 4 Issue in reading at pic controller from psoc4 device is iam reading old values from TX fifo register when latest values to be read at pic controller side, Please clarify on this issues. Thanks and regards, Pramod Kashyap, |
|
|
|
|
|
一个I2C主机必须精确地知道要读取多少字节,这是你必须实现的协议的一部分。 读取直到发生溢出将无法正常工作,PIC应该如何知道PSoC已获得读溢出。 你必须通过PIC读取你需要的字节数。当在PSoC侧,用API检测传输完成时,可以重置缓冲区。 鲍勃 以上来自于百度翻译 以下为原文 An I2C master must know exactly how many bytes to read, this is part of the protocol you have to implement. Reading until overflow occurs will not work correctly, how should the PIC know that the PSoC has got a read overflow. You will have to read by PIC the exact amount of bytes you require. When on PSoC side you detect with API that the transfer is done you may reset the buffers. Bob |
|
|
|
|
ncmza 发表于 2018-11-12 11:30 你好,鲍伯, 谢谢你的回应, 这意味着在读取主机所需的字节数之后,我们需要将NAK从主机发送到从属设备, 因为我能从PSoC4读取主端255, 指示在PSoC4上发生溢出。 我会尝试复位所有的缓冲区在PSoC4。 谢谢和问候, 普拉莫德 以上来自于百度翻译 以下为原文 Hello Bob, Thanks for response, That means after reading required number of bytes at master we need to send NAK from master to slave, As iam able to read 255 at master side from psoc4, That indicates Overflow has occurred at psoc4. I will try to reset all the buffer at psoc4. Thanks and regards, Pramod |
|
|
|
|
|
你好,鲍伯, 如何在所有数据字节被发送到主控制器之后避免溢出条件被执行, 因为我可能会发送2字节数据MAX到主控制器, 我有下面的PSOC创建者为PSoC 4设备的I2C驱动程序生成的代码片段, /*I2CyInTyxTx-空: *主读取奴隶:在缓冲区结束时提供数据读取或0xFF。 *必须捕获溢出条件,但直到事务结束才设置。 *由于TXFIFO利用,有可能出现假溢出。 */ 如果(I2CXCHECKION TIXTX掩码(I2CIIN TIXTXY空)) { 同时(I2C2I2CI FIFOOL大小!)= I2CGETGETTXXFIFOX条目) { /*使用临时SLRDBUFDEXTMP,因为主机可以对字节进行中和。 *在这种情况下需要索引回滚。在最后更新SLRDBUFDEX *读取传输的*。 */ 如果(I2CySldBuffExtMMP& lt;I2CySLRdBufSead) *来自缓冲区*的数据* { I2CYTXFIFOWA WRYRG =(UIT32)I2CYSLRDBUFPTR [I2CYSLRDBUFDEXTMPTMP ]; I2CySLRDbFixDeXTMP++; } 其他的 /*可能溢出* { I2CYTXXFIFOXWRYRG = I2CYI2CYSLaveYOVFLFLY返回; IF(I2ClSlVultFrutoSt.lt;=I2C1I2CY-TXX溢出流计数) { *在溢出范围内得到计数器。*/ I2C.SLVER流计数+; } } } I2C.CultTXStCultSo源(I2CI InthTx空); } 在代码段的粗体部分是溢出条件, 你能尽快澄清这个问题吗? 谢谢和问候, 普拉莫德卡希亚普 以上来自于百度翻译 以下为原文 Hello Bob, How can i Avoid the Overflow condition from been executed after all the data bytes are been transmitted to Master controller, as i might be transmitting 2 bytes data max to master controller, I have below code snippet generated by PSOC creator for I2C driver of PSOC 4 device, /* I2C_INTR_TX_EMPTY: * The master reads the slave: provide data to read or 0xFF in the case of the end of the buffer * The overflow condition must be captured, but not set until the end of transaction. * There is a possibility of a false overflow due to TX FIFO utilization. */ if(I2C_CHECK_INTR_TX_MASKED(I2C_INTR_TX_EMPTY)) { while(I2C_I2C_FIFO_SIZE != I2C_GET_TX_FIFO_ENTRIES) { /* Temporary slRdBufIndexTmp is used because the master can NACK the byte and * index roll-back is required in this case. The slRdBufIndex is updated at the end * of the read transfer. */ if(I2C_slRdBufIndexTmp < I2C_slRdBufSize) /* Data from buffer */ { I2C_TX_FIFO_WR_REG = (uint32) I2C_slRdBufPtr[I2C_slRdBufIndexTmp]; I2C_slRdBufIndexTmp++; } else /* Probably Overflow */ { I2C_TX_FIFO_WR_REG = I2C_I2C_SLAVE_OVFL_RETURN; if(I2C_slOverFlowCount <= I2C_I2C_TX_OVERFLOW_COUNT) { /* Get counter in range of overflow. */ I2C_slOverFlowCount++; } } } I2C_ClearTxInterruptSource(I2C_INTR_TX_EMPTY); } in the bold part of the code snippet is overflow condition, Please can you clarify on this issue ASAP. Thanks & Regards, Pramod Kashyap |
|
|
|
|
|
你好,鲍伯, 按照以前的PSOC4生成代码的代码片段, 我几乎没有什么闲话, 1)如何同步从PSoC4设备读取,因为IAM不能在PIC主控制器上一致地观察值。 2)在PSOC4设备每次读取之后,我如何才能将传输确认为主机? 请在下面找到主控制器端的代码段, UIT88T回退缓冲区() { UIT88T T Buff〔9〕={0,0,0,0,0,0,0,0}; UIT88T数据; I2CREADBUFF(I2CsLaveEx ADDR,CMD,Buff,9); 数据=Buff〔0〕; 返回数据; } 我看到Buff(0)有时错误的值,而不是预期的值。 请尽快帮助我解决这个问题。 谢谢和问候, 普拉莫德卡希亚普 以上来自于百度翻译 以下为原文 Hello Bob, As per the previous Code snippet from I2C generated code for PSOC4, I have few querries, 1) How can i synchronise the Reads from PSOC4 device, as iam not able to consistently observe values at PIC master controller. 2) How can i ACK the transmits to Master after every read from PSOC4 device? Please find below the code snippet for master controller end, uint8_t returnbuff() { uint8_t buff[9]={0,0,0,0,0,0,0,0,0}; uint8_t data; I2CReadBuff(I2C_SLAVE_ADDR, cmd, buff, 9); data = buff[0]; return data; } Iam seeing sometimes wrong values at buff[0] other than expected values. Please help me on this issues ASAP. Thanks & Regards, Pramod Kashyap |
|
|
|
|
|
I2CREADBUFF(I2CsLaveEx ADDR,CMD,Buff,9); 当你只期望一个字节时,为什么要读取9字节? NAK应该由PIC侧的库函数I2CREADBUFF来处理。 鲍勃 以上来自于百度翻译 以下为原文 I2CReadBuff(I2C_SLAVE_ADDR, cmd, buff, 9); Why are you reading 9 bytes when you expect only one? The NAK should be handled by your library function I2CReadBuff on PIC side. Bob |
|
|
|
|
ncmza 发表于 2018-11-12 12:15 嗨,鲍伯, 谢谢你的回应, 我把NACK从PANS4转到PSOC4, 从属向主机发送任何ACK信号吗?? 如何避免在PSOC4控制器中执行溢出条件。 谢谢和问候, 普拉莫德卡希亚普 以上来自于百度翻译 以下为原文 Hi Bob, Thanks for response, I gave nack from master to psoc4, Should slave send any ack signal to master?? How can avoid Overflow condition being executed in psoc4 controller. Thanks and regards, Pramod Kashyap |
|
|
|
|
|
从属向主机发送任何ACK信号吗?? 这是由组件自动完成的。 如何避免在PSOC4控制器中执行溢出条件。 不要读取比从属传递/从从属TX缓冲器读取更多的信息 鲍勃 以上来自于百度翻译 以下为原文 Should slave send any ack signal to master?? That is done automatically by the component. How can avoid Overflow condition being executed in psoc4 controller. Do not read more information than the slave delivers / is in slave Tx buffer Bob |
|
|
|
|
|
嗨,鲍伯, 如果我从主控制器做NACK,我仍然面临着问题。 我不能在PIC主控制器读取所需缓冲区的正确数据, 下面是我的主控制器的代码片段,如果这个序列是正确的,你能帮助我吗? I2C1CONBITI.I2CEN=1;启用I2C 启动位 I2CSEnEdEnter(ADDR);带有写入命令的地址 I2CSDENETENEL(RG) (10); I2CRESTATE();重新启动 I2CSEnDead字节(ADDR I2CX Read PixBIT);带有读命令的地址 如果(size & gt;0){ 对于(i=0;I & lt;(siZE-1);I++) I2CRADADACK(Buff++);从接收缓冲区复制数组 } I2C1CONBITS.ACKDT=1;NACK信号 I2C1CONBITS。AKEN=1;启用NACK。 I2cReSET();停止条件 I2C1CONITS.I2CEN=0;禁用I2C 请告诉我这是否正确? 谢谢 普拉莫德 以上来自于百度翻译 以下为原文 Hi Bob, Iam still facing issues if i do NACK from Master controller, Iam not able to read the proper data's at required buffer place at PIC master controller , Below is my code snippet for master controller, please can you help me if this sequence is alright, I2C1CONbits.I2CEN = 1; Enable I2C I2CStart(); Start bit I2CSendByte(addr); Address with Write command I2CSendByte(reg); Cmd register __delay_us(10); I2CRestart(); restart I2CSendByte(addr | I2C_READ_BIT); Address with Read command if (size > 0) { for (i = 0; i < (size-1); i++) I2CReadAck(buff++); Copying the Array from Receive buffer } I2C1CONbits.ACKDT = 1; NACK signal I2C1CONbits.ACKEN = 1; Enable NACK. I2CReset(); STOP Condition I2C1CONbits.I2CEN = 0; Disable I2C Please let me know if this is correct? THanks Pramod |
|
|
|
|
|
我不知道PIC API的I2C,但我可以看到 I2CSN字节(ADDR);//在PSoC侧的地址必须是一个7位地址,它是ADDR & Gt;& 1。为PSoC签入创建者。 你的NACK将不会被发送。检查是否存在I2CeRADnAK()API。如果是,使用它发送最后一个字节。你必须修改你的for循环。 鲍勃 以上来自于百度翻译 以下为原文 I do not know the PIC APIs for I2C, but I can see I2CSendByte(addr); // The address at PSoC side must be a 7 bit address which is addr >>1. Check in Creator for the PSoC. Your NAK will not be sent. Check if there is a I2CReadNak() API. If so, use it to send the last byte. You'll have to modify your for-loop for that a bit. Bob |
|
|
|
|
ncmza 发表于 2018-11-12 12:47 你好,鲍伯, 谢谢你的回复, 我已经检查了NAK处理器在从控制器是触发后,我启用NAK在主控制器。 请找到下面的代码片段,其中IAM在从主控制器获得命令时从从属控制器更新读缓冲器, 案例CMD1: U8I2CRADADSPOR[零]=10; 断裂; 案例CMD2: U8I2CRADADSPOR[零]=20; 断裂; 案例CMD3: U8I2CRADADSPOR[零]=30; 断裂; 案例CMD4: U8I2CRADADSPOR[零]=40; 断裂; IAM从PIC主控制器向PSoC控制器发送回读命令, 上面的更新方式是读取缓冲区是正确的,就像IAM更新到读取缓冲区的单一位置一样。 如何在PSOC4控制器中清除TXFIFO。 请你澄清一下这个问题。 谢谢和问候, 普拉莫德卡希亚普 以上来自于百度翻译 以下为原文 Hello Bob, Thanks for reply, I have checked the NAK handler in slave controller is getting triggered after i enable NAK at master controller. Please find below snippet of code where iam updating the read buffers at slave controller as i get the command from Master, case cmd1: u8i2cReadBuffer[ZERO] = 10; break; case cmd2: u8i2cReadBuffer[ZERO] = 20; break; case cmd3: u8i2cReadBuffer[ZERO] = 30; break; case cmd4: u8i2cReadBuffer[ZERO] = 40; break; Iam sending back to back read commands from PIC master controller to PSOC controller, Is the above way of updating to read buffer is right, as iam updating to single location of read buffer. How can clear the TX FIFO in psoc4 controller. please can you clarify on this issue. Thanks & Regards, Pramod Kashyap |
|
|
|
|
|
请您发布您的完整PSoC4项目,以便我们都可以查看您的所有设置。为此,使用 创建者-gt;文件& gt;创建工作区束(最小) 并附加生成的文件。 鲍勃 以上来自于百度翻译 以下为原文 Can you please post your complete PSoC4 project so that we all can have a look at all of your settings. To do so, use Creator->File->Create Workspace Bundle (minimal) and attach the resulting file. Bob |
|
|
|
|
|
嗨,鲍伯, 谢谢你的回应, 你能告诉我如何从奴隶中清除以前的读缓冲区值吗? IAM观察到索引0中的读缓冲区即使在发送NACK之后仍保留先前的数据, 我也看到NACK handler被处死了。 请在这个问题上让我知道。 谢谢和问候, 普拉莫德 以上来自于百度翻译 以下为原文 Hi Bob, Thanks for response, Can you please let me know how can i clear the previous Read buffer values in slave, Iam observing that Read buffer at index 0 hold previous data even after sending NACK, Iam also seeing that NACK handler is getting executed. Please can you let me know on this issue. Thanks & Regards, Pramod |
|
|
|
|
|
索引0中的读取缓冲区即使发送NACK也保留先前的数据。 我不明白你的意思。请如上所述发布您的项目。 鲍勃 以上来自于百度翻译 以下为原文 Read buffer at index 0 hold previous data even after sending NACK I don't understand what you mean. Please post your project as mentioned above. Bob |
|
|
|
|
|
你好,鲍伯, 我的意思是,下面提到的缓冲区不会随着最新的值更新, U8I2CRADADSPOR[零] 也在调用inAPI中的这些API I2CJI2CSLaveInRead Buf(U8I2CRADADBULL,PACETETHYSIZE);/*初始化读取缓冲器*/ I2CJI2CSLaveInWruteBuf(U8I2CWrreBuffor,PACETETHYSIZE);/*初始化写缓冲器*/ I2C*START();/*启动I2C通信*/ 请你告诉我我到底哪里错了。 谢谢 普拉莫德 以上来自于百度翻译 以下为原文 Hello Bob, I mean that some time below mentioned buffer wont get updated with latest values, u8i2cReadBuffer[ZERO] also iam calling these API's at init I2C_I2CSlaveInitReadBuf (u8i2cReadBuffer, PACKET_SIZE); /* Initialize the Read buffers*/ I2C_I2CSlaveInitWriteBuf(u8i2cWriteBuffer, PACKET_SIZE); /* Initialize the Write buffers*/ I2C_Start(); /* start the I2C communication */ please can you let me know where exactly iam going wrong. thanks pramod |
|
|
|
|
|
嗨,鲍伯, 请找到项目设置的存档。 请告诉我IAM生成的代码是否正确使用? 谢谢 普拉莫德 WorkStudio01.CyWrk.CaseV01.Zip 470.6 K 以上来自于百度翻译 以下为原文 hi bob, Please find the archive for the project setup. Please let me know if the I2C generated code which iam using is alright? Thanks Pramod
|
|
|
|
|
|
你没有为奴隶提供任何代码。您将需要等待来自主机的读或写请求并相应地采取行动。 在.h文件中定义缓冲区会导致错误。总是在.c文件中定义变量和函数,h文件只用于声明。 鲍勃 以上来自于百度翻译 以下为原文 You didn't provide any code for the slave. You will need to wait for a read or write request from master and act accordingly. Defining your buffers in a .h file can lead to errors. ALWAYS define variables and functions in .c files, .h files are used for declarations only. Bob |
|
|
|
|
只有小组成员才能发言,加入小组>>
786个成员聚集在这个小组
加入小组cyUSB3014一直显示2.1,不能到3.0情况,谁遇到过
7088 浏览 0 评论
2474 浏览 1 评论
2166 浏览 1 评论
4031 浏览 1 评论
请问可以直接使用来自FX2LP固件的端点向主机FIFO写入数据吗?
2073 浏览 6 评论
CY8C4025LQI在程序中调用函数,通过示波器观察SCL引脚波形,无法将pin0.4(SCL)下拉是什么原因导致?
7566浏览 2评论
CYUSB3065焊接到USB3.0 TYPE-B口的焊接触点就无法使用是什么原因导致的?
6114浏览 2评论
CX3连接Camera修改分辨率之后,播放器无法播出camera的画面怎么解决?
742浏览 2评论
710浏览 2评论
使用stm32+cyw43438 wifi驱动whd,WHD驱动固件加载失败的原因?
7962浏览 2评论
/9
小黑屋| 手机版| Archiver| 电子发烧友 ( 湘ICP备2023018690号 )
GMT+8, 2025-12-2 05:02 , Processed in 1.184818 second(s), Total 106, Slave 89 queries .
Powered by 电子发烧友网
© 2015 bbs.elecfans.com
关注我们的微信
下载发烧友APP
电子发烧友观察
版权所有 © 湖南华秋数字科技有限公司
电子发烧友 (电路图) 湘公网安备 43011202000918 号 电信与信息服务业务经营许可证:合字B2-20210191

淘帖
2089