7 years, 1 month ago.

Software I2C driver?

Hi, has anyone attempted a bit-banged I2C driver, using only gpios? For example, for implementing another I2C bus besides the hardware supported one... The actual reason is harder to explain but anyway. I suppose I could try to port one of the everal available for AVR.

Thanks for any pointer.

Question relating to:

3 Answers

7 years, 1 month ago.

Hello. I have been keen on I2C since I first heard of it. A few years ago I (successfully) wrote a program in Microchip Assembler to read the bearing from an electronic compass, that is about the programming level you describe, except that the timing was handled my the Microsoft system. I found the descriptions of I2C very difficult to get round, and if that is part of your problem then I may be able to help.

Here is the diagram I drew to help me to understand it, bit of a mess, it just grew. I'll be happy to explain any of it that is too obscure.:

/media/uploads/ColonelPewter/i2c_001004.gif

7 years, 1 month ago.

A search resulted in: https://developer.mbed.org/users/p3p/code/SoftwareI2C/file/8670e78c4b63/SoftwareI2C.cpp. Sadly it does not seem to be completely compatible with mbed i2c api, however it might be a good point to start.

7 years, 1 month ago.

the mbed i2c problem is with slave mode: it does not work, nor is it supported. End of discussion. I2C Master ONLY ! beware !

the PCF8574 ic turns your mbed uc into a i2c slave device like magic ! it is not plug and pray, it is plug and play, that's what i did , it won't make more money for me if you buy some, or not. it is just a niece piece of engineering that fixed a BIG problem for me. Cheers.

this fabulous i2c chip is an i2c slave who simply reads a microcontroller's (uc) 8-bit parallel output, making any uc a i2c slave BINGO !

posted by Maximilian May 31 Oct 2015