> > I have a better idea, one of you guys with the Hi-Tech C write a simple > program for the '84' that reads one byte from a half duplex serial port, > echo's back the byte, writes the byte to I2C memory, reads the byte from > I2C memory, sends the byte. A simple test of something we all do on a > regular basis that tests common library support. > > My CCS results : ~374 instructions If you look at CCS's code, their I2C routines are rather bloated. I don't know the exact reasoning behind some of the coding decisions (probably some RAM/ROM tradeoffs involved) but while their RS232-style stuff is handy for debugging sometimes I find their I2C stuff less useful (and instead spin my own). Note that this is not necessarily a slam at CCS; some I2C devices require a more complex protocol that others. For example, a "proper" I2C master should float the clock wire after each bit (there must be a pullup on it) and wait for it to go high; slower I2C devices that can't keep up with the bit rate may hold the line low for up to something like 1ms/bit. Since the I2C memory devices can always keep up with any valid bit rate, a system that ONLY has such memory devices on its I2C bus can simply drive the clock full high/full low at whatever rate it wants. This will simplify the code, but will cause the code to fail on other devices. Personally, I also usually write my I2C routines a bit differently from CCS's: the write-byte routine assumes the current bit out there is an ack from the previous write, clocks it out, then clocks 8 data bits. After that it checks the state of the data line (to see if there was an ACK) but it does not clock out the ACK. The read routine asserts data, clocks once, releases data, and then clocks 8 data bits. If another byte of data is needed, the PIC can ACK it then. This approach works well from my experience (a little trickery is required to make the writes work with the start condition, but nothing too bad) and is easier than declaring after each byte whether I'll want another. Anyone else use this trick?