完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
大家好,
在我的应用程序中,我正在使用100kHz时钟通过I2C与M24SR02芯片进行通信。我遇到的问题是使用ReadBinary命令。在应用程序中,我一遍又一遍地发出完全相同的ReadBinary命令 - 从偏移0x0097读取0x10字节。在M24SR02中,NDEF消息长度在NDEF文件的两个第一个字节中设置为0x00E5。在操作过程中,我没有改变NFC芯片的内容,只是一遍又一遍地阅读。大多数时候 ReadBinary 从M24SR02内存返回正确的值可以正常工作,但有时完全相同的命令会返回0x6A 0x86错误('P1或P2值不正确')。然后在该点之后重新发出相同的ReadBinary命令将永远返回相同的错误。如果在接收到错误后我将命令中的偏移量改为0x0000,则一切都恢复正常,ReadBinary再次起作用。我已经检查了带有范围的违规数据包的I2C流量,我可以看到发送到M24SR02的命令很好并且相同,无论是否导致错误被返回。说过我已经注意到了一些东西看起来像I2C时钟延长:I2C_SCL线拉低并在一段时间后再次开始翻转(大约200us,但它稍微变化)。它总是发生在发送字节之间的边界上。我认为这是由M24SR02完成的 - 我的MCU主驱动I2C总线使用硬件I2C模块和DMA发送数据包,因此极不可能耗尽数据发送这么长时间。我已经使用ExtendedReadBinary重复实验命令(我认为问题可能是由错误的NDEF消息长度引起的),但结果与ReadBinary命令相同。我还介绍了在发送C-APDU和开始读出R-APDU之间的一些延迟(从1ms到2ms范围),但问题仍然存在 题: 1)M24SR02如何控制I2C上的数据流?它是否使用时钟拉伸?或者它可能不会确认其I2C地址? 2)是否需要在命令或命令/回复之间引入延迟? 略有不相关的一点。我注意到在应用笔记中提供的示例中,(扩展)ReadBinary命令中使用的PCB字段在0x02和0x03之间交替。在我的应用程序中,我总是发送0x02,M24SR02回复在0x02和0x03之间交替。对于我发送的每个命令,是否必须在0x02和0x03之间交替? 亲切的问候, 亚当 以上来自于谷歌翻译 以下为原文 Hi all, In my application I am talking to M24SR02 chip over I2C with 100kHz clock. The problem I am having is with ReadBinary command. In the application I issue exactly the same ReadBinary command over and over again - reading 0x10 bytes from offset 0x0097. NDEF message length is set to 0x00E5 in two first bytes of NDEF file in M24SR02. During operation I am not changing the contents of NFC chip, just read it over and over again. Most of the time ReadBinary works fine returning correct values from M24SR02 memory, however sometimes exactly the same command returns 0x6A 0x86 error ('Incorrect P1 or P2 values'). Then after that point re-issuing the same ReadBinary command returns the same error forever. If after receiving and error I change the offset in command to say 0x0000, then everything goes back to normal and ReadBinary works again. I've checked I2C traffic of the offending packet with the scope and I can see that the command sent to M24SR02 is fine and the same regardless if it results in the error being returned or not.. Having said that I've noticed something that looks like I2C clock stretching: I2C_SCL line gets pulled low and starts toggling again after some time (approx. 200us, but it varies a little bit). It always happens on the boundary between sent bytes. I presume that this is done by M24SR02 - my MCU being master driving I2C bus uses hardware I2C block and DMA to send the packet, so it is extremely unlikely to run out of data to send for so long.I've repeated experiment using ExtendedReadBinary command (I thought that the problem may have been caused by wrong NDEF message length), but the result was the same as with ReadBinary command. I've also introduced some delays (from 1ms - 2ms range) between sending C-APDU and starting to read out R-APDU, but the problem is still there Question: 1) How M24SR02 controls data flow on I2C? Is it using clock stretching? Or maybe it doesn't acknowledge its I2C address? 2) Is there a need to introduce delays between commands or command/replies? Slightly unrelated bit. I've noticed that in examples provided in application notes PCB field used in (Extended)ReadBinary command alternates between 0x02 and 0x03. In my application I always send 0x02, M24SR02 replies alternate between 0x02 and 0x03. Is it obligatory to alternate between 0x02 and 0x03 for each command I sent? Kind regards, Adam |
|
相关推荐
1个回答
|
|
以下是我在原帖中谈到的成功和不成功访问的示例:
################################################# ReadBinary返回成功时访问 (只打印出每个C-APDU和R-APDU的前8个字节及其总长度) ################################################# --- NDEF标签应用选择--- C-APDU:02 00 A4 04 00 07 D2 76 C-APDU:len 16 dec --- OK回复--- R-APDU:02 90 00 F1 09 00 00 00 R-APDU:len 5 dec --- NDEF Select --- C-APDU:02 00 A4 00 0C 02 00 01 C-APDU:len 10 dec --- OK响应--- R-APDU:03 90 00 2D 53 00 00 00 R-APDU:len 5 decC-APDU:02 00 B0 00 00 02 6B 7D C-APDU:len 8 dec --- OK响应NDEF消息长度数据--- R-APDU:02 00 E5 90 00 9F 3F 00 R-APDU:len 7 dec ---来自偏移0x0097的ExtendedReadBinary 0x10字节--- C-APDU:02 A2 B0 00 97 10 E1 E6 C-APDU:len 8 dec --- OK响应NDEF消息,数据0x1097,数据来自0x0097偏移量--- R-APDU:03 80 00 00 00 00 00 00 R-APDU:len 21 dec ################################################# ReadBinary返回错误代码时访问 (只打印出每个C-APDU和R-APDU的前8个字节及其总长度) ################################################# --- NDEF标签应用选择--- C-APDU:02 00 A4 04 00 07 D2 76 C-APDU:len 16 dec --- OK回复--- R-APDU:02 90 00 F1 09 00 00 00 R-APDU:len 5 dec --- NDEF Select --- C-APDU:02 00 A4 00 0C 02 00 01 C-APDU:len 10 dec --- OK响应--- R-APDU:03 90 00 2D 53 00 00 00 R-APDU:len 5 dec ---来自偏移0x0000的ReadBinary NDEF 0x02字节(NDEF消息长度) C-APDU:02 00 B00 00 00 02 6B 7D C-APDU:len 8 dec --- OK响应NDEF消息长度数据--- R-APDU:02 00 E5 90 00 9F 3F 00 R-APDU:len 7 dec ---来自偏移0x0097的ExtendedReadBinary 0x10字节--- C-APDU:02 A2 B0 00 97 10 E1 E6 C-APDU:len 8 dec ---响应0x6A 0x86错误代码('错误的P1或P2值') R-APDU:03 6A 86 6B 33 FF FF FF R-APDU:len 21 dec ---从偏移量0x0097重新发出ExtendedReadBinary 0x10字节--- C-APDU:02 A2 B0 00 97 10 E1 E6 C-APDU:len 8 dec ---响应0x6A 0x86错误代码('错误的P1或P2值') R-APDU:03 6A 86 6B 33 FF FF FF R-APDU:从现在开始,在最后两条消息中,Len 21将永远重复 以上来自于谷歌翻译 以下为原文 Here is an example of successful and unsuccessful accesses I was talking about in the original post: ################################################# Access when ReadBinary returns is successful (only first 8 bytes of each C-APDU and R-APDU and their total lengths are printed out) ################################################# --- NDEF Tag Application Select --- C-APDU: 02 00 A4 04 00 07 D2 76 C-APDU: len 16 dec--- OK response --- R-APDU: 02 90 00 F1 09 00 00 00 R-APDU: len 5 dec--- NDEF Select --- C-APDU: 02 00 A4 00 0C 02 00 01 C-APDU: len 10 dec--- OK response --- R-APDU: 03 90 00 2D 53 00 00 00 R-APDU: len 5 decC-APDU: 02 00 B0 00 00 02 6B 7D C-APDU: len 8 dec--- OK response with NDEF message lenght data --- R-APDU: 02 00 E5 90 00 9F 3F 00 R-APDU: len 7 dec--- ExtendedReadBinary 0x10 bytes from offset 0x0097 --- C-APDU: 02 A2 B0 00 97 10 E1 E6 C-APDU: len 8 dec--- OK response with NDEF message with data 0x10 bytes of data from 0x0097 offset --- R-APDU: 03 80 00 00 00 00 00 00 R-APDU: len 21 dec ################################################# Access when ReadBinary returns error code (only first 8 bytes of each C-APDU and R-APDU and their total lengths are printed out) ################################################# --- NDEF Tag Application Select --- C-APDU: 02 00 A4 04 00 07 D2 76 C-APDU: len 16 dec--- OK response --- R-APDU: 02 90 00 F1 09 00 00 00 R-APDU: len 5 dec--- NDEF Select --- C-APDU: 02 00 A4 00 0C 02 00 01 C-APDU: len 10 dec--- OK response --- R-APDU: 03 90 00 2D 53 00 00 00 R-APDU: len 5 dec--- ReadBinary NDEF 0x02 bytes from offset 0x0000 (NDEF message lenght) C-APDU: 02 00 B0 00 00 02 6B 7D C-APDU: len 8 dec--- OK response with NDEF message lenght data --- R-APDU: 02 00 E5 90 00 9F 3F 00 R-APDU: len 7 dec--- ExtendedReadBinary 0x10 bytes from offset 0x0097 --- C-APDU: 02 A2 B0 00 97 10 E1 E6 C-APDU: len 8 dec--- Response with 0x6A 0x86 error code ('Incorrect P1 or P2 value') R-APDU: 03 6A 86 6B 33 FF FF FF R-APDU: len 21 dec--- Reissue ExtendedReadBinary 0x10 bytes from offset 0x0097 --- C-APDU: 02 A2 B0 00 97 10 E1 E6 C-APDU: len 8 dec--- Response with 0x6A 0x86 error code ('Incorrect P1 or P2 value') R-APDU: 03 6A 86 6B 33 FF FF FF R-APDU: len 21 decfrom now on the last two messages repeat forever |
|
|
|
只有小组成员才能发言,加入小组>>
请教:在使用UDE STK时,单片机使用SPC560D30L1,在配置文件怎么设置或选择?里面只有SPC560D40的选项
2741 浏览 1 评论
3244 浏览 1 评论
请问是否有通过UART连接的两个微处理器之间实现双向值交换的方法?
1813 浏览 1 评论
3653 浏览 6 评论
6043 浏览 21 评论
1342浏览 4评论
203浏览 3评论
对H747I-DISCO写程序时将CN2的st-link复用为usart1,再次烧录时无法检测到stlink怎么解决?
356浏览 2评论
STM32G474RE芯片只是串口发个数据就发烫严重是怎么回事?
445浏览 2评论
STM32处理增量式编码器Z信号如何判断中断是正转的还是反向转的?
275浏览 2评论
小黑屋| 手机版| Archiver| 电子发烧友 ( 湘ICP备2023018690号 )
GMT+8, 2024-12-26 03:24 , Processed in 1.497409 second(s), Total 76, Slave 60 queries .
Powered by 电子发烧友网
© 2015 bbs.elecfans.com
关注我们的微信
下载发烧友APP
电子发烧友观察
版权所有 © 湖南华秋数字科技有限公司
电子发烧友 (电路图) 湘公网安备 43011202000918 号 电信与信息服务业务经营许可证:合字B2-20210191 工商网监 湘ICP备2023018690号