cancel
Showing results for 
Search instead for 
Did you mean: 

Does the STM32F103C8 have an I2C monitor feature?

arno
Associate II
Posted on December 26, 2016 at 15:27

I want to implement a USB to I2C adapter.

Since the STM32F103C8 has two I2C interfaces and a USB interface, it seems to be a suitable candidate.

One of the features I'm looking for is a Monitor mode.

Goal is to send all events and data going over the bus to a PC.

Can I configure the I2C peripheral to do such a thing?

(Receive all data, but do not send ACKs, because other devices on the bus do that. I would also like to be notified of STOP and START conditions.)

Or should I implement this in software ('bit banging')?

#stm32f103 #stm32 #i2c
4 REPLIES 4
Posted on December 28, 2016 at 13:10

Since the STM32F103C8 has two I2C interfaces

I don't quite see why would two I2C interfaces be needed for monitoring an I2C bus.

Can I configure the I2C peripheral to do such a thing?

IMO no.

I concocted an I2C monitor from a L4 Disco a couple of months ago, using the masking feature of its OAR2 (the 'F1xx don't have this feature). It does not recognize the 'reserved' address ranges, though (a remarkably idiotic design decision, preventing to listen to these addresses in hardware while it would be trivial to filter them out in software) and I used a diode to avoid the ACK from the monitor to reach the bus. So, it had its limitations but it fit the purpose I needed it for. Still not suitable for general purpose I2C bus monitoring.

JW

Seb
ST Employee
Posted on December 28, 2016 at 20:38

If you'd like to monitor everything on the bus, including buggy communication such as missing NACK bit, 3 Start or 4 stop in a row, it is possible to build an I2C bus bit level state machine using EXTI on 2 GPIO which will be SDA and SCL.

Of course, because it's done by bit interrupt, the max analysis speed is limited. Was around 200kbps scan mode at 96MHz core frequency (the state machine was doing slave + monitor by GPIO). USB interrupt should not disrupt the analysis. The state machine under interrupt generates a string (see

https://community.st.com/0D50X00009XkW1mSAF

) which is fifoed to a USART or similar for console viewing and logging)

Good luck!

Posted on December 28, 2016 at 21:27

Yes, I'd lean toward not using the I2C peripheral for an analyzer, would likely interfere more than help. I might consider using two TIM CHx input capture pins on a free running timer at some desired resolution to timestamp edges. One might be able to use DMA to capture SDA/SCL traffic at high speeds, and to plot / analyze the signal vs I2C specifications, or to a model of the device being monitored.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
Posted on December 29, 2016 at 14:01

You are right. It is not necessary two have two I2C interfaces. Another feature I would like to have is to send data on to the bus using the USB interface.

I figured I could use one interface only for monitoring and another for transmitting data.

However, as you and others have mentioned, it is not possible to configure the I2C interface appropriately.