I2C devices, when powering up, can be accidentally placed inside a READ or WRITE sequence due to its detecting a false start. I always issue a STOP then a START then a STOP after powerup. It fixes ALL I2C chips on the bus. --Bob Dmitriy Fitisov wrote: > I think you are talking about START byte - see I2C specification > 10.1.2 for version 2.1 > Basically it used for slaves which are software-coded, and in some cases, > yes, slave remembers last address it was addressed with - see 10-bit address > READ mode - it sets address in WRITE mode, after that send repeated START, > 2-nd byte of the address with READ byte. > > Dmitriy > > -----Original Message----- > From: pic microcontroller discussion list > [mailto:PICLIST@MITVMA.MIT.EDU]On Behalf Of Nick Veys > Sent: March 7, 2004 4:50 PM > To: PICLIST@MITVMA.MIT.EDU > Subject: [PIC]: I2C Guru's, Help! > > > Ok, this has to be a quirk of I2C that I'm not aware of, this is odd. > > I'm using a PIC18F2320 to talk to a Matrix Orbital GLK12232-25SM LCD, It > has a 16C87 on it FYI. > > I was having trouble talking to it so I thought I had the address wrong, > I wrote a loop to go though all possible addresses, and bingo it worked. > So I binary searched til I found it, decimal 80, which was what I > thought it was in the first place. So I took the loop out and tried to > talk to 80, no luck. What the hell I say to myself. :) > > So I play around a bit and find that if I try to send data to it without > first having tried to send data beforehand, ANY data, it won't work. > But if I just send 0x00 to address 0x00 (or anything to anything) it > works fine. > > So I'm guessing it's some kind of reset condition on the I2C bus? I set > SDA/SCL high before starting anything and that didn't seem to do > anything, maybe something in the PIC that gets setup after the first > run? Seems odd but I'm out of ideas here! :) > > Here's my code to illustrate if I'm doing something absurd: > > --------- SNIP ------------ > void init() { > TRISC = 0b10000000; // See pinout > > SMP = 1; // Slew Rate Standard (100KHz - 1MHz) > SSPADD = 19; // I2C clock = 8M/(4*(19+1)) -> 100KHz > SSPCON1 = 0x08; // Master, clock from SSPADD > SSPEN = 1; // Synch. Serial Port Enabled > } > void sendI2C(unsigned char addr, char* data, unsigned char len) { > unsigned char i; > > SSPIF = 0; // Clear SSP flag > SEN = 1; // Start Enable > while(SEN); // Wait to finish > SSPIF = 0; // Clear SSP flag > SSPBUF = addr; // Send address > while(!SSPIF); // Wait for SSPIF flag > SSPIF = 0; // Clear SSP flag > for(i = 0; i < len; i++) { > SSPBUF = data[i]; // Send data > while(!SSPIF); // Wait for SSPIF flag > SSPIF = 0; // Clear SSP flag > } > PEN = 1; > while(PEN); // Wait to finish > SSPIF = 0; // Clear SSP flag > > delayMilliseconds(1); > } > > void sendStuff() { > char data[] = { 0xFE, 0x62, 2, 0, 0 }; > char len = 5; > > sendI2C(80, data, len); > sendI2C(80, data, len); > } > > void main() { > init(); // setup ports, registers, etc... > > delaySeconds(2); // wait for everyone to wake up > sendStuff(); > > while(1); > } > ------------- SNIP -------------- > > This works. If I change sendStuff() to have just 1 sendI2C, it doesn't > work. Any suggestions are appreciated on the code as well of course. > > Thanks! > > Nick > > -- > http://www.piclist.com hint: PICList Posts must start with ONE topic: > [PIC]:,[SX]:,[AVR]: ->uP ONLY! [EE]:,[OT]: ->Other [BUY]:,[AD]: ->Ads > > -- > http://www.piclist.com hint: PICList Posts must start with ONE topic: > [PIC]:,[SX]:,[AVR]: ->uP ONLY! [EE]:,[OT]: ->Other [BUY]:,[AD]: ->Ads > -- Replies: NOTE-Script, EXE,BAT and COM files will be rejected by server -------------- Bob Axtell PIC Hardware & Firmware Dev http://beam.to/baxtell 1-520-219-2363 -- http://www.piclist.com hint: PICList Posts must start with ONE topic: [PIC]:,[SX]:,[AVR]: ->uP ONLY! [EE]:,[OT]: ->Other [BUY]:,[AD]: ->Ads