On Tue 28 Oct, Robert Nansel wrote: > > This may be a bone-headed idea, but has anybody tried to implement an I2C > slave on a 12Cxx device? My first guess is that it wouldn't have nearly > enough bandwidth to keep up with a 100 KHz bit-rate, but how close could it > come? I've been doing just this, and it does work. A friend of mine wrote an I2C interface on a 16C84 to connect his HP48 calculator to I2C peripherals. He of course implemented his I2C in software and _very_fortunately_ he used a slow start pulse (waiting 20us between states). In my 12C508 copy of it I actually implemented an I2C slave as well -- the main loop would continuously poll the RS232 RxD signal and the I2C SDA/SCL signals to detect a start bit on the RS232 or a start condition on the I2C. It was just about possible to get this loop to execute fast enough so that it would successfully detect all 20us-per-state I2C start conditions as well as not miss a start bit on the 9600bps RS232. It would not be able to read the RS232 when receiving I2C messages or vice versa, but that isn't a big problem. > A related (and perhaps more practical) notion would be to use a 12Cxx as a > bit-banged START condition and Address Match Detector (to be paired with a > 16F84 with suitable I2C slave code). Any thoughts? Nah, software only is always cheaper=better. I've since modified my I2C library to also generate a slow (20us steps) start condition so that it can be recognized by this I2C device. Not a great loss when it isn't needed, only 6 instruction words or so. CONTEST ======= Anyone out there who can write a PIC loop that can detect RS232 start bits as well as I2C start conditions in less than (say) 8 cycles between samples? You can assume the bits are all on the same port. Bonus for running on 12-bit PICs. Frank ------------------------------------------------------------------------ Frank A. Vorstenbosch Phone: +44-181-636 3391 Electronics & Software Engineer or: +44-181-636 3000 Eidos Technologies Ltd., Wimbledon, London Mobile: +44-976-430 569