>Hello Radboud & PIC.ers, >.. >>Date: Wed, 21 Oct 1998 21:02:47 +0200 >>From: Radboud Verberne >>Subject: >.. >>Hi, >.. >>I'm trying to interface a 24c02 to a PIC16c62A... I thought it wouldn't be >>that difficult but problably i'm doing something wrong... The I2C DOES >>acknoledge the adress, but after i've done a write command the 24c02 does'nt >>ack.... (Also not after a 65ms delay (TMR0)... >.. >a quick question or two; >1. I suppose you (do) have the pullup resistors - e.g. 10k - from > both SDA and SCL to Vdd, installed? Yes, I Used 2k2 resistors... >2. Assuming yes to para.1 , then mmmm > You are not floating either SDA or SCL in order to put them HI. > At least, not on every occasion. > Well, actually you don't *have* to float'm, but this is vital > if you'll ever use this code for multi-master work. I'll *think* I'll never use the code for multi-master system so the pins are onlu inputs when reading from the bus or when the slave has to ack the signal. >It looks like you only float SDA when the master is looking for an ack (LO) >from the 24C02 slave. Yes, the datasheet says that the SCL signal of the 24c02 EEPROM is ONLY an input... >The bit-test happens after a delay of 14 instructions from the SCL rising >edge (don't know your clock rate) >-could this be too great a period for the slave ack? >i.e. the slave ack happens but the master is too busy doing nops to notice? >.. >or... when executing your routine i2crandomread -> i2creadcurrent >is nested within, so it calls a re-start & then proceeds to dump >another un-wanted control byte on the bus ? >It should just plant the eeprom internal 8-bit addr on the bus at this point. >No control byte (?) should go here , I think. >.. >Please let us know how it pans out in the end. > >Best regards, John Had to add some delays on the code and the start condition was not always correct... Know it works just fine.