cancel
Showing results for 
Search instead for 
Did you mean: 

STM32F030 I2C Memory Interface emulation

Steve Sutherland
Associate
Posted on December 07, 2017 at 11:33

I would like to make my MCU appear as a 256-byte I2C RAM on the I2C bus - then I can have the controlling device simply write to the 'RAM' in  order to communicate.

This requires variable length access ( e.g. 'write', 'address', 'data0', 'data1', 'data2'.... 'datan' ) where the address written to will auto-increment on each I2C data-byte.

This sounds reasonably simple using the DMA functions on an I2C slave, but all the example code I have seen for the I2C interface works with a fixed size comms buffer.

Are there any examples which show this sort of I2C interface - or has anyone implemented this? 

4 REPLIES 4
Posted on December 07, 2017 at 13:28

The classical implementation of such a device would be to use interrupts and 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..
Posted on December 07, 2017 at 13:53

+1.

DMA might be tricky and it's questionable if it's worth, given the speeds.

Btw. there are at least two distinct incarnations of I2C on STM32 so if it gets to details, it's important to know the particular model number (it's always better to start a post stating that anyway).

JW

Andrew Neil
Evangelist III
Posted on December 07, 2017 at 16:15

all the example code I have seen for the I2C interface works with a fixed size comms buffer.

So why not just do that, then?

Posted on December 08, 2017 at 11:14

An interface that looks like a memory block, with variable length read/writes makes the software on the master side easier.

It's probably true that DMA won't be particularly helpful - an interrupt where I can set up pointers to a static buffer and then just keep reading/writing via a state machine is likely to be all I need.

If nothing exists, I will look at writing the code - Just wanted to make sure no-one had any wheels before I start inventing round things!