完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
你好,我想从我的PIC32 MZ中使用I2C作为主控器。我使用的是和声样本共现,我只看到第一个地址字节。我从来没有看到缓冲区的其余部分。有人以前有过这个问题吗?谢谢。
以上来自于百度翻译 以下为原文 Hi, I'm trying to use I2C from my PIC32MZ as master. I'm using the hARMony sample code uint8_t TXbuffer[]= "AAA"; ... appData.drvI2CTxRxBufferHandle[0] = DRV_I2C_Transmit(appData.drvI2CHandle_Master,CHIP_ADDRESS,&TXbuffer[0],(sizeof(TXbuffer)-1),NULL); but with the scope I only see the first address byte . I never see the rest of the buffer. Is someone ever have this problem before. Thanks you |
|
相关推荐
11个回答
|
|
是的,以前见过这种情况。每次I2C从机不响应时,都会发生,因为主叫用错误的地址,或者从设备没有连接或离线,或者从属忙,不准备接受呼叫。在范围内,注意NACK/ACK位,第9位。如果SDA线是Hig。h,在第9个时钟脉冲期间,没有答案。当微芯片在数据表和其他文档中指定寄存器中的比特字段的值时,它们总是一致地指定孤立字段的可能值,而不是组合寄存器的值。例如,MCC中的I2C驱动程序期望I2C值。地址,当7位寻址在使用时为7位I2C地址,但不和谐!DRVIII2CY传输(…)期望8位地址:MysIL
以上来自于百度翻译 以下为原文 Yes, Have seen that before. It will happen every time when the I2C slave do not respond, because: Master calling with wrong address, or Slave device is not connected or offline, or Slave is busy and not ready to accept calls. With scope, pay attention to the NACK/ACK bit, the 9'th bit. If SDA line is High, during the 9'th clock pulse, then there was no answer. When Microchip specify values for bitfield in registers in datasheet and other documentation, they quite consistently specify possible values of bitfields in isolation, not value of assembled register. E.g. I2C driver in MCC expect value of I2C address, to be 7-bit I2C address when 7 bit addressing is in use. But Not Harmony! DRV_I2C_Transmit(...) expect 8 bit address: CHIP_ADDRESS = 7-bit_I2C_address << 1; Mysil |
|
|
|
你好,这里有一个交换的范围,我的组件有地址0x40。不明白这个范围有什么问题。谢谢你。
以上来自于百度翻译 以下为原文 Hi, Here is a scope of the exchange , my component have the address 0x40. Don't understand what is wrong with this scope. Thanks you Attached Image(s) |
|
|
|
这里有一些截图与其他地址。我正在尝试使用的芯片是PCA9685。所有的地址引脚是下拉到地面和基地地址是0x40。我的SDA和SCL引脚有拉电阻
以上来自于百度翻译 以下为原文 Here some screenshot with other address. The Chip I'm trying to use is the PCA9685 . All the address pin are pull down to ground and the base address is 0x40. My SDA and SCL pin have Pull up resistor Attached Image(s) |
|
|
|
嗨,清晰的图像,但是你正在解释范围图像错误。捕获消息3显示:开始0,1,0,0,0,0,0,写NACK停止。第一个地址位是0,所以7位I2C地址是0x20,在消息4的第一个图像:开始0 1 1,γ写NAck Stop。I2C 7位地址是0x28。下一个跟踪显示:开始0 1,0,1,0,0,0,读取NAck Stop。I2C 7位地址为读写位0x28。这些地址在调用PCA9685时都是错误的,发送到照明控制器的所有地址在开始后的第一个时钟脉冲中都应该以数据位=1开始。在处理和声时,在调用驱动程序之前将地址加2。迈西尔
以上来自于百度翻译 以下为原文 Hi, Nice clear images, but you are interpreting scope images wrong. Capture in message #3 show: Start 0 1 0 0 0 0 0 Write NAck Stop . The first address bit is 0 , so 7-bit I2C address is 0x20, In the first image in message #4: Start 0 1 0 1 0 0 0 Write NAck Stop. I2C 7-bit address is 0x28. The next trace show: Start 0 1 0 1 0 0 0 Read NAck Stop. I2C 7-bit address is 0x28 with Read bit set. These addresses are All wrong for calling PCA9685, All addresses sent to the lighting controller shall start with data bit = 1 in the First clock pulse after Start. When dealing with Harmony, multiply the addresses *2 before calling the driver. Mysil |
|
|
|
是的,我已经改变了地址值,现在我得到了一个很好的答案和芯片答案。我把0x80在范围内有0x40。但是现在我有一个问题,当我发送PayLoad in TestI2Ic图像我发送这个,在ZooOrthTime2c我为什么我发送0x00 0x00的范围显示0x09 0x00。用我5分钟来使用芯片,用微型芯片LIB太难了。谢谢你。
以上来自于百度翻译 以下为原文 Yes I've change the address value and now I've got the good one and the chip answer. I put 0x80 to have 0x40 at the scope. but now I've a problem when I send the payload In the Test_I2C image I send this TXbuffer[0] = 0xAA TXbuffer[1] = 0xEE; WriteI2C(PCA9685_ADDRESS,&TXbuffer[0],2); TXbuffer[0] = 0xEE; TXbuffer[1] = 0xAA; WriteI2C(PCA9685_ADDRESS,&TXbuffer[0],2); ... void WriteI2C(uint16_t address,void *writeBuffer,size_t size) { if(appData.drvI2CTxRxBufferHandle[0] != DRV_I2C_Transmit(appData.drvI2CHandle_Master,address,&writeBuffer,size,NULL)) { //error } } and in the Zero_testI2C I send TXbuffer[0] = 0x00;//MODE1; TXbuffer[1] = 0x00; WriteI2C(PCA9685_ADDRESS,&TXbuffer[0],2); TXbuffer[0] = 0x00;//MODE2; TXbuffer[1] = 0x00; WriteI2C(PCA9685_ADDRESS,&TXbuffer[0],2); Why when I send 0x00 0x00 the scope show 0x09 0x00. With an arduino it take me 5min to use the chip and with the microchip lib it is so difficult. Thanks you Attached Image(s) |
|
|
|
嗨,你假装它,你显示的代码,和逻辑分析仪捕获的数据不一致。和谐是让你写程序期待微控制器在数据传输正在进行其他工作。因此,DRVIII2CyS传输(…)将传输请求放置在队列中,并立即返回到应用程序代码。一旦I2C硬件能够执行,传输将被执行。OrthixI2C驱动程序不提供缓冲,缓冲区是应用程序代码的责任。在消息1的开头所示的代码中,TXBuff[0 ]和TXbuffer(1)的内容在您的代码被重写之前,甚至在开始条件之前。信号完成后,您将获得2次发送的第二次传输的数据。迈西尔
以上来自于百度翻译 以下为原文 Hi, You are faking it, the code you show, and data captured by logic analyzer do not correspond. Harmony is made to let you write programs that expect microcontroller to do other work while data transfer is going on. Thus DRV_I2C_Transmit(...) will place the transport requests in a queue, and return to application code immediately. Transfer will then be performed as soon as I2C hardware is able. Harmony I2C driver do Not provide buffering, Buffers are a responsibility of the application code. In code shown in beginning of message #1, contents of TXbuffer[0] and TXbuffer[1] are overwritten by your code, before even Start condition signal is done. So you will get data intended for the second transfer sent 2 times. Mysil |
|
|
|
缓冲区初始化如下:里面没有什么:0x9来自哪里?UnT88t TxBuff[2 ] =“”;那么,什么是这样的函数,其中地址是0x80(具有0x40)和寄存器=0x0和value=0x0.0,像这样,当我将有一个工作代码时,它是驱动芯片的,我将在ARDUIO中生成一个像所有想要使用这个奇妙CH的人一样的库。用PIC来驱动伺服,谢谢
以上来自于百度翻译 以下为原文 Buffer is initialized like this nothing inside : where the 0x9 come from ? uint8_t TXbuffer[2]= ""; so what is the solution to make a function like this I2C_Write(Address,Register,Value); where Address is the 0x80 (to have 0x40) and register=0x0 and value=0x0. like this it is esay to drive the chip When I will have a working code,I will make a lib like in arduino for all people who want to use this fabulous chip to drive servo with a pic. Thanks you |
|
|
|
更改Tout88t TxBuff[2 ]={0}0};
以上来自于百度翻译 以下为原文 change that to uint8_t TXbuffer[2]= {0,0}; |
|
|
|
警告-请参阅PIC32 MZ的勘误表,因为I2Co稳定性存在问题,考虑使用BIT实现(使用PIN图中相同的I2C引脚分配)保罗
以上来自于百度翻译 以下为原文 Warning - See Errata for PIC32MZ as there are issues with I2C For stability consider using the Bit Bang Implementation (Uses same I2C pin assignments in Pin Diagram) Paul |
|
|
|
QYB:当我尝试在0x009 0x00 PotoSoL范围内看到0x00 0x00时也是一样的:这是一个耻辱,I2C是一个新的协议,它为什么不能在32 MZ中得到很好的实现。
以上来自于百度翻译 以下为原文 qyb :It is the same when I try to send 0x00 0x00 I see on the scope 0x09 0x00 PortSol: it is a shame, I2C is a new protocol that why it is not well implemented in the 32MZ. |
|
|
|
嗨,消息中显示的代码只是片段,不可能确定你在哪里做的错误。正如在消息7中所说的,和声不提供数据缓冲,I2C通信比PIC32 MZ中的CPU慢得多。因此,为了不在脚中射击自己,数据缓冲器要发送。对于PCA965必须存储在全局或静态RAM位置。此外,如果可能不止一个传输请求,那么每个传输必须有单独的数据缓冲器。每个缓冲区的内容必须保持不受干扰,直到I2C完成了整个传输。例如,我也怀疑消息6中的这个构造是没有意义的。当多个传输同时被调度时,它们应该得到不同的传输句柄。如果返回句柄,则返回句柄。如果句柄被返回,则用于检查传输的状态。如果使用相同的变量来存储多个传输的传输句柄,那么只能检查最后一个传输。全文:在协调手册和示例项目中有示例代码。
以上来自于百度翻译 以下为原文 Hi, The code shown in messages are only fragments, impossible to be sure what you are doing wrong where. As said in message #7 Harmony do Not provide buffering for data, and I2C communication is much slower than the CPU in PIC32MZ. So, in order to Not shoot yourself in the foot, the data buffer to send to PCA9685 Must be stored in Global or Static RAM locations. Also, if there may be more than a single transfer requested, then there must be separate data buffers for each transfer. Contents of each buffer must remain undisturbed until I2C have completed the whole transfer. E.g. static uint8_t TXbuffer_A[2]= {0,0}; static uint8_t TXbuffer_B[2]= {0,0}; static uint8_t TXbuffer_C[2]= {0,0}; static uint8_t TXbuffer_D[2]= {0,0}; Then also, I suspect this construct in message #6 if(appData.drvI2CTxRxBufferHandle[0] != DRV_I2C_Transmit(appData.drvI2CHandle_Master,address,&writeBuffer,size,NULL))do not make sense. When several transfers are scheduled at the same time, they should get different transfer handles. If a transfer could not be scheduled at all, then the handle returned will be NULL. If the handle is returned, then it is meant to be used for checking status of the transfer later. appData.drvI2CTxRxBufferHandle[0] = DRV_I2C_Transmit(appData.drvI2CHandle_Master, address, &writeBuffer, size, NULL)) if ( NULL == appData.drvI2CTxRxBufferHandle[0]) { /* Error */ } If the same variable is used to store the transfer handle for several transfers, then it will only be possible to check the last one. To check if transfer is completed: /* Check for the successful data transfer */ if( DRV_I2C_BUFFER_EVENT_COMPLETE == DRV_I2C_TransferStatusGet(appData.drvI2CHandle_Master, appData.drvI2CTxRxBufferHandle[0]) ) { ... /* Transfer completed */ } else { /* Transfer Not completed. */ } There is example code in Harmony manual and in example projects. Mysil |
|
|
|
只有小组成员才能发言,加入小组>>
5238 浏览 9 评论
2028 浏览 8 评论
1950 浏览 10 评论
请问是否能把一个ADC值转换成两个字节用来设置PWM占空比?
3204 浏览 3 评论
请问电源和晶体值之间有什么关系吗?PIC在正常条件下运行4MHz需要多少电压?
2253 浏览 5 评论
774浏览 1评论
664浏览 1评论
有偿咨询,关于MPLAB X IPE烧录PIC32MX所遇到的问题
592浏览 1评论
PIC Kit3出现目标设备ID(00000000)与预期的设备ID(02c20000)不匹配。是什么原因
674浏览 0评论
574浏览 0评论
小黑屋| 手机版| Archiver| 电子发烧友 ( 湘ICP备2023018690号 )
GMT+8, 2024-12-22 18:52 , Processed in 1.340574 second(s), Total 97, Slave 80 queries .
Powered by 电子发烧友网
© 2015 bbs.elecfans.com
关注我们的微信
下载发烧友APP
电子发烧友观察
版权所有 © 湖南华秋数字科技有限公司
电子发烧友 (电路图) 湘公网安备 43011202000918 号 电信与信息服务业务经营许可证:合字B2-20210191 工商网监 湘ICP备2023018690号