The book Serial Pic'n goes through I2C thoroughly(115 pages just for iic), including master and slave modes, with code. I just got my copy, and know I will be referencing it quite a bit as I go along. http://www.amazon.com/exec/obidos/ASIN/0965416224/adamdaviscollect (helps me support my PIC website) It is well worth the $50 it costs at Amazon. If you just want the code, Square One has it here: http://sq-1.com/srccode.html The routines you'll be interested in are: MASTER: Use EEPROM - ORANGE1.ASM Use A/D - ORANGE2.ASM Use A/D & EEPROM - ORANGE3.ASM ORANGE4.ASM and ORANGE5.ASM go with the next two SLAVE programs SLAVE: FAWN1.ASM With ACK polling - FAWN2.ASM I hope this helps! -Adam Greg Hartung wrote: > > Well, there's certainly more questions about I2C than answers. > Since no one seems to know how to do this, I will continue informing the > list of my progress. I finally got some DS275's, so I substitued one > for the MAX232 just to make sure those charge pumps weren't screwing > with me again. No improvement, however, other than 5 fewer caps on my > board :-) > So I decided I'd done enough homework and called Microchip. At first > they said, oh, yeah, sure, you just need PICDEM2.ZIP. Well, it is > technically an example of I2C, but it's mostly bit banging; it certainly > isn't code for master mode on the 877, tho. So then they admitted they > are working on an AN and will try to get the code to me. uhu, sure... > > > It's a bad day when I'm replying to my own messages... > > > > I tried de-coupling caps on the EEPROM. I put huge 40ms delays after every I2C > > bus access. And I put a scope on the SDA and SCL. SCL had a rock solid pulse at > > 385kHz, just like I calculated. Big grin on that one. And SDA had 1's and 0's all > > over the place. I also tried 1K pullups instead of 2K, and 33pf caps on the bus > > lines, but I still can't get anything out that looks like what I put in. > > > > > > Greg Hartung wrote: > > > > > No problem, Mike, any input is welcome. > > > I found one eroneous line in the code. I moved the clrf SSPSTAT that was > > > after the switch to Bank 0 to before the switch because SSPSTAT in bank 1. > > > Will I ever learn? > > > I also tried a value of 49 for a clock of 100kHz. And I also tried > > > commenting out the SSPCON2 inits. And I even tried changing the slew rate for > > > the 100kHz test. The output was still the same rotated pattern of grouped 1's > > > no matter what I did. The 100kHz did slow the output down quite a bit, which > > > was encouraging. > > > Pleeeeeeease someone help me. > > > I am foolishly thinking of putting the scope on it, but I dunno what to look > > > for. Those timing charts in the datasheet hurt my head. > > > Does anybody know how I might read the I2C with some other device to try and > > > narrow down if I'm having read or write problems? > > > I also noticed the original author had a stop bit before the second start > > > bit in the i2c_read proc, but the 24lc256 datasheet does not indicate that it > > > should be there. > > > I have 2k pullups and no caps on SCL and SDA. Should I try decoupling caps > > > on power again? (Can't believe I just thought of that... not the brightest > > > lad sometimes...) > >