2017-12-07 02:33 AM
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?
2017-12-07 04:28 AM
The classical implementation of such a device would be to use interrupts and a state machine.
2017-12-07 05:53 AM
+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
2017-12-07 07:15 AM
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?
2017-12-08 03:14 AM
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!