Who is up for a challenge? Software I2C

Hi All,

Has this code (the working version) been posted on the code site at all? I have tried using the version here and got the InvalidOperationExceptions in the constructor - I can fix it, but rather than to that myself I would happily opt to use the tested working code ;D

Thanks

Kofi

I just posted a working version of the code here: http://code.tinyclr.com/project/297/software-i2c-driver/

Give it a try and let me know what you think …

Great! I am sure we will benefit from that

Al,

Works a treat.

Thanks a lot!

How fast can that driver work assuming no capacitance?

It is slow compared to hardware I2C but you can always make a native I2C using RLP

Ballistic … Your welcome!

Xarren … Actually, the software I2C is really slow. With no added delays, the serial clock is only about 1.5 KHz. But it does work, and allows me to connect multiple identical sensors (all of which use the same address) to a single Domino.

Gus … I was already thinking about writing an RLP version of the driver. It wouldn’t fit on a Domino, but I have a Cobra that I can try it out on. That should be much faster … maybe even fast enough that I’ll have to worry about getting the serial clock rate right!

Sure it would fit on Domino/panda…etc!

Hi,

I want to use the software I2C implementation with 1kHz.

Can anyone explain how it is possible to add the required timing to accomplish this?

I’m a bit shocked by the fact that this only runs at 1.5 khz… What’s that processor doing in between?

I’m in need of being able to read and write bytes to the I2C bus, so the GHI & NETCF version don’t suffice… They only allow ‘block’ operations…

Any suggetions to get the speed up to at least 50 khz?

You could use the I2CDevice from Microsoft.SPOT.Hardware.

Nope, the class stands most away from the hardware… I need to read and write the bytes which are read. In the reading I need to process the bytes, this to see the number of bytes to actually read…

You could develop the protocol in native code, using RLP

GHI already include native version in all products.

@ Gus: Yes, for the SoftwareI2C, but if you want a custom protocol on the hardware I2C, and the I2CDevice from Microsoft.SPOT.Hardware is too slow, the only way out would be RLP…

@ iwritecode: Have you tried the I2CDevice already?

But that’s still reading and writing blocks of data…

For reading I first need to check a status byte… If its 0x00 then I can continue read, otherwise I have to abort and try again. Then I need to read the data size, and then need to read the number of bytes specified + CRC…

Not possible with both current solutions I believe

That should all be possible with I2CDevice. Your device is the I2C master, so it defines the clock and when the slave must send out its data.

Create a read transaction for 1 byte, and use that transaction to read status and later on, to read the data length. Then you setup an other read transaction that matches the requested length+CRC length, and use that transaction to read the rest of your data.

Doesn’t a read transaction automatically start with a write of the slave address?

Oh I see, it’s a very custom protocol you have there! What device are you talking with, if I might ask? Do you have a datasheet we can see? If it is your own hardware, I would switch to a normal serial protocol like RS232.