Troubleshooting I2C

Started by Max April 2, 2011
I have been trying to write to a 24LC1025 EEPROM which uses an I2C interface without success. The software I2C routines that I am using are the same ones that I have successfully used with a Dallas 1307 clock chip and were downloaded from the Dallas website back a few years ago. Using my Pickit2 programmer I wrote some data into the 24LC1025 chip and using these routines I am able to read the data out with no apparent problems. Using a logic analyzer made by Saleae shows no problems. It decodes the reads and writes just as they should be with an example shown below. Now the thing I don't understand is, in order to read data you must first write three bytes to the EEPROM. The first byte is the Control byte and the next two bytes are the Address High Byte and the Address Low Byte. If those writes weren't working then I would never be able to read any data, but reads seem to work fine. Using the logic analyzer to look at the signals shows the clock frequency to be 55 kHz, well below the 400 kHz that this chip can run at. The data sheet says the maximum write time is 5ms and I am waiting much longer than that for now between writes and reads. It is as if the write protect pin isn't grounded, but it is. After working on this for some time now I'm at a loss as to what to do next.

Time [s] ,Event
"0.0000000",Start
"0.0000230",Setup write to 0xA0. +ACK Control Byte
"0.0002060",Wrote 0x00 to 0xA0. +ACK High Address +
"0.0003890",Wrote 0x00 to 0xA0. +ACK Low Address = 0000
"0.0005720",Wrote 0x45 to 0xA0. +ACK Write 45 in hex
"0.0007620",Stop
"0.0512970",Start
"0.0513200",Setup write to 0xA0. +ACK
"0.0515030",Wrote 0x00 to 0xA0. +ACK
"0.0516860",Wrote 0x00 to 0xA0. +ACK
"0.0518610",Start
"0.0518770",Setup read from 0xA1. +ACK
"0.0520595",Read 0x01 from 0xA1. +No ACK Here it reads 01 hex
"0.0522235",Stop not 45 as it should.

Thanks, Max

Hi Max,
You did not specify all pin connections.
Pin 3 (A2) HAS to connect to Vdd.
Do you see the EEPROM's Ack bits at low after each byte write?
What do you mean by "but reads seem to work fine"? Do you get FF's back? If so,
that does not mean the chip is answering.

 
Best regards
Noam
 
 
________________________________

From: Max
To: p...
Sent: Sat, April 2, 2011 10:25:17 AM
Subject: [piclist] Troubleshooting I2C

I have been trying to write to a 24LC1025 EEPROM which uses an I2C interface
without success. The software I2C routines that I am using are the same ones
that I have successfully used with a Dallas 1307 clock chip and were downloaded
from the Dallas website back a few years ago. Using my Pickit2 programmer I
wrote some data into the 24LC1025 chip and using these routines I am able to
read the data out with no apparent problems. Using a logic analyzer made by
Saleae shows no problems. It decodes the reads and writes just as they should be
with an example shown below. Now the thing I don't understand is, in order to
read data you must first write three bytes to the EEPROM. The first byte is the
Control byte and the next two bytes are the Address High Byte and the Address
Low Byte. If those writes weren't working then I would never be able to read any
data, but reads seem to work fine. Using the logic analyzer to look at the
signals shows the clock frequency to be 55 kHz, well below the 400 kHz that this
chip can run at. The data sheet says the maximum write time is 5ms and I am
waiting much longer than that for now between writes and reads. It is as if the
write protect pin isn't grounded, but it is. After working on this for some time
now I'm at a loss as to what to do next.

Time [s] ,Event
"0.0000000",Start
"0.0000230",Setup write to 0xA0. +ACK Control Byte
"0.0002060",Wrote 0x00 to 0xA0. +ACK High Address +
"0.0003890",Wrote 0x00 to 0xA0. +ACK Low Address = 0000
"0.0005720",Wrote 0x45 to 0xA0. +ACK Write 45 in hex
"0.0007620",Stop
"0.0512970",Start
"0.0513200",Setup write to 0xA0. +ACK
"0.0515030",Wrote 0x00 to 0xA0. +ACK
"0.0516860",Wrote 0x00 to 0xA0. +ACK
"0.0518610",Start
"0.0518770",Setup read from 0xA1. +ACK
"0.0520595",Read 0x01 from 0xA1. +No ACK Here it reads 01 hex
"0.0522235",Stop not 45 as it should.

Thanks, Max
> What do you mean by "but reads seem to work fine"?

Data that was written using my PicKit2 programmer reads fine using my program. When I try to overwrite the data with my program and I do a read, I read the old data, not the new data. The old data is NOT "FF". I say "but reads seem to work fine" because I haven't done thousands of them yet, but all that I have tried, worked.

> Do you see the EEPROM's Ack bits at low after each byte write?
If you look at the analyzer output it shows the ACK's.

> Pin 3 (A2) HAS to connect to Vdd.
Reads won't work if this pin is not connected to +5v and reads are working.

Pin 1 A0:Ground
Pin 2 A1:Ground
Pin 3 A2:+5v
Pin 4 VSS:Ground
Pin 5 SDA:I2C Data
Pin 6 SCL:I2C Clock
Pin 7 WP:Ground
Pin 8 VCC:+5v

Max

--- In p..., noam naaman wrote:
>
> Hi Max,
> You did not specify all pin connections.
> Pin 3 (A2) HAS to connect to Vdd.
> Do you see the EEPROM's Ack bits at low after each byte write?
> What do you mean by "but reads seem to work fine"? Do you get FF's back? If so,
> that does not mean the chip is answering.
>
>  
> Best regards
> Noam
>  
>  
> ________________________________
>
> From: Max
> To: p...
> Sent: Sat, April 2, 2011 10:25:17 AM
> Subject: [piclist] Troubleshooting I2C
>
> I have been trying to write to a 24LC1025 EEPROM which uses an I2C interface
> without success. The software I2C routines that I am using are the same ones
> that I have successfully used with a Dallas 1307 clock chip and were downloaded
> from the Dallas website back a few years ago. Using my Pickit2 programmer I
> wrote some data into the 24LC1025 chip and using these routines I am able to
> read the data out with no apparent problems. Using a logic analyzer made by
> Saleae shows no problems. It decodes the reads and writes just as they should be
> with an example shown below. Now the thing I don't understand is, in order to
> read data you must first write three bytes to the EEPROM. The first byte is the
> Control byte and the next two bytes are the Address High Byte and the Address
> Low Byte. If those writes weren't working then I would never be able to read any
> data, but reads seem to work fine. Using the logic analyzer to look at the
> signals shows the clock frequency to be 55 kHz, well below the 400 kHz that this
> chip can run at. The data sheet says the maximum write time is 5ms and I am
> waiting much longer than that for now between writes and reads. It is as if the
> write protect pin isn't grounded, but it is. After working on this for some time
> now I'm at a loss as to what to do next.
>
> Time [s] ,Event
> "0.0000000",Start
> "0.0000230",Setup write to 0xA0. +ACK Control Byte
> "0.0002060",Wrote 0x00 to 0xA0. +ACK High Address +
> "0.0003890",Wrote 0x00 to 0xA0. +ACK Low Address = 0000
> "0.0005720",Wrote 0x45 to 0xA0. +ACK Write 45 in hex
> "0.0007620",Stop
> "0.0512970",Start
> "0.0513200",Setup write to 0xA0. +ACK
> "0.0515030",Wrote 0x00 to 0xA0. +ACK
> "0.0516860",Wrote 0x00 to 0xA0. +ACK
> "0.0518610",Start
> "0.0518770",Setup read from 0xA1. +ACK
> "0.0520595",Read 0x01 from 0xA1. +No ACK Here it reads 01 hex
> "0.0522235",Stop not 45 as it should.
>
> Thanks, Max
>



to unsubscribe, go to http://www.yahoogroups.com and follow the instructions
Is the write protect pin set the right way?
On Apr 2, 2011, at 6:26 PM, Max wrote:

>> What do you mean by "but reads seem to work fine"?
>
> Data that was written using my PicKit2 programmer reads fine using
> my program. When I try to overwrite the data with my program and I
> do a read, I read the old data, not the new data. The old data is
> NOT "FF". I say "but reads seem to work fine" because I haven't done
> thousands of them yet, but all that I have tried, worked.
>
>> Do you see the EEPROM's Ack bits at low after each byte write?
> If you look at the analyzer output it shows the ACK's.
>
>> Pin 3 (A2) HAS to connect to Vdd.
> Reads won't work if this pin is not connected to +5v and reads are
> working.
>
> Pin 1 A0:Ground
> Pin 2 A1:Ground
> Pin 3 A2:+5v
> Pin 4 VSS:Ground
> Pin 5 SDA:I2C Data
> Pin 6 SCL:I2C Clock
> Pin 7 WP:Ground
> Pin 8 VCC:+5v
>
> Max
>
> --- In p..., noam naaman wrote:
>>
>> Hi Max,
>> You did not specify all pin connections.
>> Pin 3 (A2) HAS to connect to Vdd.
>> Do you see the EEPROM's Ack bits at low after each byte write?
>> What do you mean by "but reads seem to work fine"? Do you get FF's
>> back? If so,
>> that does not mean the chip is answering.
>>
>> br /> >> Best regards
>> Noam
>> br /> >> br /> >> ________________________________
>>
>> From: Max
>> To: p...
>> Sent: Sat, April 2, 2011 10:25:17 AM
>> Subject: [piclist] Troubleshooting I2C
>>
>> I have been trying to write to a 24LC1025 EEPROM which uses an I2C
>> interface
>> without success. The software I2C routines that I am using are the
>> same ones
>> that I have successfully used with a Dallas 1307 clock chip and
>> were downloaded
>> from the Dallas website back a few years ago. Using my Pickit2
>> programmer I
>> wrote some data into the 24LC1025 chip and using these routines I
>> am able to
>> read the data out with no apparent problems. Using a logic analyzer
>> made by
>> Saleae shows no problems. It decodes the reads and writes just as
>> they should be
>> with an example shown below. Now the thing I don't understand is,
>> in order to
>> read data you must first write three bytes to the EEPROM. The first
>> byte is the
>> Control byte and the next two bytes are the Address High Byte and
>> the Address
>> Low Byte. If those writes weren't working then I would never be
>> able to read any
>> data, but reads seem to work fine. Using the logic analyzer to look
>> at the
>> signals shows the clock frequency to be 55 kHz, well below the 400
>> kHz that this
>> chip can run at. The data sheet says the maximum write time is 5ms
>> and I am
>> waiting much longer than that for now between writes and reads. It
>> is as if the
>> write protect pin isn't grounded, but it is. After working on this
>> for some time
>> now I'm at a loss as to what to do next.
>>
>> Time [s] ,Event
>> "0.0000000",Start
>> "0.0000230",Setup write to 0xA0. +ACK Control Byte
>> "0.0002060",Wrote 0x00 to 0xA0. +ACK High Address +
>> "0.0003890",Wrote 0x00 to 0xA0. +ACK Low Address = 0000
>> "0.0005720",Wrote 0x45 to 0xA0. +ACK Write 45 in hex
>> "0.0007620",Stop
>> "0.0512970",Start
>> "0.0513200",Setup write to 0xA0. +ACK
>> "0.0515030",Wrote 0x00 to 0xA0. +ACK
>> "0.0516860",Wrote 0x00 to 0xA0. +ACK
>> "0.0518610",Start
>> "0.0518770",Setup read from 0xA1. +ACK
>> "0.0520595",Read 0x01 from 0xA1. +No ACK Here it reads 01 hex
>> "0.0522235",Stop not 45 as it should.
>>
>> Thanks, Max
>>
>
>
> to unsubscribe, go to http://www.yahoogroups.com and follow the
> instructions
Hi Max,
I have used some code that was in an article in the EPE magazine January 2004 The article is called "Car computer" The source code can be downloaded from their website.
http://www.epemag3.com/
Go to the library section for code downloads. The design uses a PIC16F877 with pin 18 driving SCL and pin 23 driving SDA on a 24LC64
The write protect pin on the EEPROM is left floating so I assume it floats high.Both SCL and SDA are pulled up to +5V with a 2K2 resistor.
I have used this with a 24LC256 with no problems. The code for driving the EEPROM is in is file called EEPROM.INC so it is in a convenient form to use.

Les.
--- In p..., "Max" wrote:
>
> I have been trying to write to a 24LC1025 EEPROM which uses an I2C interface without success. The software I2C routines that I am using are the same ones that I have successfully used with a Dallas 1307 clock chip and were downloaded from the Dallas website back a few years ago. Using my Pickit2 programmer I wrote some data into the 24LC1025 chip and using these routines I am able to read the data out with no apparent problems. Using a logic analyzer made by Saleae shows no problems. It decodes the reads and writes just as they should be with an example shown below. Now the thing I don't understand is, in order to read data you must first write three bytes to the EEPROM. The first byte is the Control byte and the next two bytes are the Address High Byte and the Address Low Byte. If those writes weren't working then I would never be able to read any data, but reads seem to work fine. Using the logic analyzer to look at the signals shows the clock frequency to be 55 kHz, well below the 400 kHz that this chip can run at. The data sheet says the maximum write time is 5ms and I am waiting much longer than that for now between writes and reads. It is as if the write protect pin isn't grounded, but it is. After working on this for some time now I'm at a loss as to what to do next.
>
> Time [s] ,Event
> "0.0000000",Start
> "0.0000230",Setup write to 0xA0. +ACK Control Byte
> "0.0002060",Wrote 0x00 to 0xA0. +ACK High Address +
> "0.0003890",Wrote 0x00 to 0xA0. +ACK Low Address = 0000
> "0.0005720",Wrote 0x45 to 0xA0. +ACK Write 45 in hex
> "0.0007620",Stop
> "0.0512970",Start
> "0.0513200",Setup write to 0xA0. +ACK
> "0.0515030",Wrote 0x00 to 0xA0. +ACK
> "0.0516860",Wrote 0x00 to 0xA0. +ACK
> "0.0518610",Start
> "0.0518770",Setup read from 0xA1. +ACK
> "0.0520595",Read 0x01 from 0xA1. +No ACK Here it reads 01 hex
> "0.0522235",Stop not 45 as it should.
>
> Thanks, Max
>