piclist 2001\05\18\102534a >
Thread: I2C slave software for the PC to talk to a PIC
www.piclist.com/techref/i2cs.htm?key=i2c
flavicon
face BY : Michael Rigby-Jones email (remove spam text)



{Quote hidden}

       Normal speed I2C = 100Khz = 10us per bit, fast mode 400KHz = 2.5us
per bit.  In that time your state machine will have to decode the current
state of the lines, compare to the previous state and the state of the slave
in general (e.g if it has just been addressed, or is waiting for a start bit
etc).  If you have just received a byte, that will need to be stored
somewhere etc..etc.

       Basically an I2C software slave is orders of magnitude more complex
than a simple master, and timing is absolutely critical.  As Bob said, a
timer tick interrupt under DOS could be enough to stop this working
reliably.  Irrespective, this will need a reasonably fast machine.

       Even using clock stretching to slow the master dosen't help matters
much, as the state machine still has to work fast enough to be able to hold
the clock low before the master releases it.

       If your master if running at a substantialy slower speed, or if you
use some hardware for start/stop detection, then the task gets much easier.

       Several years ago I started writting a bus analyser that worked in a
non-real time way.  Basically it was a logic analyser, storing the state of
the lines into a large array, sampling as fast as possible.  Once the array
was full, the software decoded the states of the SCL and SDA lines through a
state machine.  It worked, kinda, but as there was no way of synchronising
that start of the data gathering to a start bit on the bus, it was all a bit
hit or miss was to wether you actually caught anything.  The next
improvement would be a simple latch on the port to detect a start condition,
and then start logging.  Dosn't know what happened to it, probably gathering
dust in a box of floppies up in the loft somewhere!

       The bottom line is, I'm sure it's possible to do, I just don't think
it's as easy as you do.

       Regards

       Mike

--
http://www.piclist.com hint: The list server can filter out subtopics
(like ads or off topics) for you. See http://www.piclist.com/#topics


<0F60BEDDC090D41185D300508BCFA39EE815A4@zpgty002.europe.nortel.com>

See also: www.piclist.com/techref/i2cs.htm?key=i2c
Reply You must be a member of the piclist mailing list (not only a www.piclist.com member) to post to the piclist. This form requires JavaScript and a browser/email client that can handle form mailto: posts.
Subject (change) I2C slave software for the PC to talk to a PIC

month overview.

new search...