cancel
Showing results for 
Search instead for 
Did you mean: 

I2C BitBang ??

lizerd
Associate III
Posted on December 04, 2010 at 21:57

I2C BitBang ??

1 REPLY 1
Posted on May 17, 2011 at 14:17

The I2C protocol is fairly well documented, and reasonably simple to implement.

You basically have to define your clock/data signals on GPIO pins in open collector/drain mode, and shift out your address and data, and wait for slave acknowledgements, or data. The most difficult part would be to get some reasonable timing delays, but the clocking of I2C is not particularly critical (most parts will work for DC to several hundred KHz, and any variation between). Most I2C bus routines can be sufficiently abstracted that the EEPROM access code can live on top of native HW I2C implementations or GPIO bit-bang implementations. If this is difficult to understand, you really need to review the I2C protocol some more, and look at how GPIO pins are configured and controlled on the STM32.

The biggest problem with I2C is that it is pretty dumb, and peripherals don't reset when you reset the CPU, or the I2C HW. If they get stuck in weird states, they must be clocked out.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..