使用STM32Cubeide调试提取I2C SDA信号内容
我想在SDA线上提取I2C通信的内容/序列,而不使用示波器解密信号,所以我想知道是否可以通过STM32Cubeide调试来进行信号?
谢谢
I want to extract the content/sequence of an I2C communication on the SDA line, without using an oscilloscope to decrypt the signal, so i was wondering if it was possible to do it via STM32CUBEIDE debug?
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
不是直接的,也不是整个沟通。您可以输出发送/接收到连接到ST-Link的UART的数据。不要忘记,您必须将一个数据字节(例如)0x34转换为“ 0x34”字符串,以使UART从终端使其可读(否则终端将用代码0x34显示ASCII字符,甚至可能是看不见的),因此必须进行一些数据转换,这是您需要实现的整个函数,在此网站上有多个解决方案有关如何做到这一点,或者您可以提出自己的解决方案那。
您将无法完全跟踪通信,如查看波形。您将无法看到启动和停止位置并从物理上寻址通信,但是您可以观看I2C状态寄存器,这将有各种标志。您可以使用断点并在I2C中查看标志,但是请记住,与断点进行沟通非常困难和有限。您可以在中间打破数据包,当程序暂停等时毁了时间。注意放置断点的位置。您也将无法验证您从主机发送到从属的数据实际上将实际发送到I2C线(因为您可以成功地将其发送给UART,但是您不知道I2C是否将其发送给它,而I2C状态的标志注册就是您所拥有的)。但是,您可以通过将其重定向到UART来完全验证从从服务器中验证传入的数据。
为了访问I2C标志,请在STM32Cubeide中运行调试,当您处于调试模式并坐在断点时,请转到右上角(默认面板)上的特殊功能寄存器(SFR)选项卡(SFR)选项卡它并找到SR(状态寄存器)或ISR(中断和状态寄存器),以任何为准。在那里,您应该有各种0和1,该0和1指示外围的某些状态(例如,闲置,忙碌,转移完成,覆盖错误等)
Not directly, and not the entire communication. You can output the data you send/receive to the UART connected to ST-Link. Don't forget that you'll have to convert a data byte (such as) 0x34 into a string of "0x34" for UART to make it readable from the terminal (otherwise the terminal will display an ASCII character with the code 0x34, which may even be invisible), so there will have to be some data conversion, which is a whole function you need to implement, there are multiple solutions on this very site about how to do that, or you can come up with your own solution to that.
You will not be able to fully trace the communication, as in see the waveforms. You won't be able to see start and stop bits and address communication physically, but you can watch I2C status register, which will have various flags. You can use breakpoints and see the flags in I2C, but remember, that tracing communication with breakpoints is very hard and limited. You can break packets of data in the middle, ruin timings when the program pauses and so on. Be mindful of where you place your breakpoints. You will also not be able to verify that the data you send from master to slave actually gets physically sent out to I2C line (since you can successfully send it out to UART but you have no idea if I2C sent it out, flags in I2C status register are all you have). But you can totally verify incoming data from the slave by redirecting it to UART.
In order to access I2C flags, run debug in STM32CubeIDE, when you're in debug mode and sitting at a breakpoint, go to Special Function Registers (SFR) tab on the top-right (default panels), find your I2C interface, unfold it and find SR (status register) or ISR (interrupt and status register), whichever exists. There you should have various 0 and 1, which indicate certain state of the peripheral (e.g. line idle, busy, transfer complete, overrun error etc.)