cancel
Showing results for 
Search instead for 
Did you mean: 

I2C bus monitor

GBoft.1
Associate

I want to make i2c monitor that can read data sent by slave with specific address (0x42). So monitor has to capture sequence of

​1. Start

2. Slave address (write)

3. Command byte

4. Repeated start

5. Slave address (read)

And then start reading actual data

​Is it even possible to make this and what would be the best approach? Preferred MCU is stm32f103c8 and I could use stm32f407vg for higher clock speed

3 REPLIES 3

>>Is it even possible to make this and what would be the best approach? 

Sure, you're just capturing signals, how hard can that be?

You can't use the I2C peripheral, it doesn't support this type of promiscuous listener mode.

400 KHz+ probably not going to want to use interrupts.

I'd probably use a 32-bit TIM, w/DMA, to capture pin transition times into a buffer, and then unpack that.

Digital / Synchronous level, you could perhaps sample the GPIO on both edges of the SCL.

GPS/GNSS receiver?

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
GBoft.1
Associate

​I tried to use I2C periph pretending to be slave with the same address. Couldn't get to the point of receiving actual data sent by slave sensor - DR just won't accept anything other than data sent by master.

Using oscilloscope I ​found bus speed is 400kHz and there are 2 more address (another slaves).

In case of TIM input capture how do I know when to start, stop and restart timer? Buffer size is another problem, because it has to fit unknown amount of elements. Also math behind it must be complicated including some kind of double buffering.

Could you, please, give me more details like where to start and how to progress.

You wouldn't have to restart the timer, I'm saying measure the signals (edges) in the time domain, plot/relate them as you might for a logic analyzer and decode where the start, stop, data and nack bits are. Use a state machine.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..