cancel
Showing results for 
Search instead for 
Did you mean: 

I2C passiv Mode possible?

Moritz1
Associate III

Hi,

I try to sniff a I2C communication between multiple devices with my STM32G473.

The controller should only listen passiv. Is this possible?

For sure, I can always set the NACK-Bit to prevent sending an ACK and disable the Clock-stretching.

And I can use the Adress-Masking feature to listen on all Addresses.

But if I understand correctly, the Controller will always send automatically an ACK if the Address matchs? Is this correct? I can not disable this.

So this ACK after Address match is the only point that prevents me from doing what I want to do.

Is there any possibility to listen 100% passively with the I2C periphery?

I tryed another way before: Generating interrupts on clock edges and reading the level of Data Line, and than getting the data Bit by Bit. This works fine for 250kHz, but unfortunately the Interrupt is too slow to sample an 1MHz I2C signal (Interrupt needs 440ns to be called and one clock pulse is just 500ns long, so I miss the databit). So I was thinking if it is mayby possible to use the I2C peripheral.

10 REPLIES 10
Moritz1
Associate III

Unfortunately, my hardware already exists and it is not possible to add an external flip-flop.

I had another idea to detect the stop condition:

I tried to use a timer. I configured the timer in gated mode. This means that the timer only counts when the SCL line is high. As clock source for the timer I use the SDA on rising edge.

So every time there is a stop condition on the bus, the counter increments by one.

This works fine. But I have a small problem with this: I want to get an interrupt when a stop condition happens. So I set the Auto-Reload ARR register to 1 and enabled the update interrupt.

Unfortunately with this solution the interrupt is only generated every second stop condition.

This is because the update event is generated when the counter value is higher than ARR.

(Setting ARR to 0 is not possible)

Surely I can additionaly set the compare value to 1 and enable the CCIE. This will generate a CCIE on every time the counter changes from 0 to 1. And the Update interrupt is generated if the counter changes from 1 to 2 (rest to 0). So I have an interrupt on every stop condition. But I want to trigger a DMA on this event to solve the interrupt run time problem. But for DMA you can only select TIM_UP or TIM_CH1 as the trigger source. It is not possible to trigger the DMA on both.

So is there a way to generate a timer interrupt every time the counter is incremented?