I want to simulate an I2C slave device using a generic 8051 MPU which doesn't have hardware I2C(not like 80C552). I know it is easy to implement software simulated I2C in master mode, but I want to turn my 8051 MPU to be a slave device. How can?
The other problem with a software implementation of I2C is that the slave is not in control of the clock. The master sets the clock rate. Since the I2C spec says that the bus is supposed to operate at 100 kHz (for the minimum rate), a conforming master can generate this clock even in hardware, and thus the slave software implementation must be able to keep up at 100 kHz. This speed requires a fairly high clock rate for the 8051 just to sample the clock and data pins and accumulate the data in time. (The lower clocks per instruction cycle devices also help.) I2C devices are allowed to operate at slower clock rates, but only when the master is clocking slower than 100 kHz. This is easy when the software implementation is the master. It simply generates whatever clock it wants to or can do. But when you're stuck with an inflexible master that you can't slow down, you have to beef up the bit-banged slave implementation accordingly. And a device marketed as a separate component might be connected to any master.