Go Down

Topic: Microchip 24C02C EEPROM read/write problems (Read 238 times) previous topic - next topic

sn4k3

Hello


I currently have an 24C02C to program, i have multiple hardware programers but only one is capable of read (SkyPro), when i try to write it say success but when i verify it come with a error message "Verify Fail![Address:00000053H;Buffer:60H;Chip:00H]" no matter what i change... And chip cotents will not change.
And yes i connect WP (Write Protection) to GND

So after many tries i move to arduino and connect all wires, write a small program using this functions: https://playground.arduino.cc/Code/I2CEEPROM

I had no success, but my attemps make chip blank
After many searchs i found other code that i try (I lost the link) so i will post all the code


Program 1
Program 2
(Code is outside this post because (9000 characters) max allowed)

I have used 1K pullup on SCL and SDA lines as i saw on internet, but the result is the same

Program 2 read all FF while program 1 read real chip content but none write as i want. I don't know if i'm doing it well.
I want to write variable "somedata" contents into chip.

Current chip contents:

aarg

Can you program a different EEPROM type?
  ... with a transistor and a large sum of money to spend ...
Please don't PM me with technical questions. Post them in the forum.

sn4k3

#2
May 19, 2017, 04:21 pm Last Edit: May 19, 2017, 04:26 pm by sn4k3
Can you program a different EEPROM type?
On hardware programers Yes, on arduino not tested.
Currently only have 25 SPI spare ROMs, but the one i need is 24 I2C type and i only have this one.
ROM come from a car controller

avr_fred

Using your SkyPro tool:

Your screen dump shows that you have the "size" set to 256 bytes. The size of the 24C02C is 2048 bytes.

Your screen dump shows that you have the "page size" set to 8 bytes. The page size of the 24C02C is 16 bytes.

Set your device size and page size correctly and try it again, post your results if it fails.

avr_fred

Are you certain that device is a 24C02C? According to the Microchip docs, the SOIC should have the full 24C02C printed on it.

JiaoJiao

Hi,
I only checked the Program 2 and have a few question:
Code: [Select]

 for(byte i = 0; i < 16; i++)
  {
    writeEEPROM (rom, i, somedata[i], sizeof somedata[i]);
  }

Won't the EEPROM address overlap when you are writting 16bytes and only increment the address by one ?

Code: [Select]
byte readEEPROM (byte device, unsigned int addr )
  {
  byte temp;
 
  if (readEEPROM (device, addr, &temp, 1) == 0)
    return temp;
 
  return 0xFF;
 
  }

Can you change the return error code so that we can see if you are really reading 0xFF from the memory or if an error occured ?

sn4k3

Using your SkyPro tool:

Your screen dump shows that you have the "size" set to 256 bytes. The size of the 24C02C is 2048 bytes.

Your screen dump shows that you have the "page size" set to 8 bytes. The page size of the 24C02C is 16 bytes.

Set your device size and page size correctly and try it again, post your results if it fails.
PDF says: "The device is organized as a single block of 256 x 8-bit memory with a 2-wire serial interface"
256 x 8 = 2048

So i think is correct

I tested with settings you suggest and read/write both fail and not able to continue

Are you certain that device is a 24C02C? According to the Microchip docs, the SOIC should have the full 24C02C printed on it.
Yes, as this is from a car they often hide real refs to people not able to find the IC, if you search for the printed ref on IC it will lead you to 24C02C

As i told Skypro is able to read and write to it, but write never happen, contents will not be modified or saved

sn4k3

Hi,
I only checked the Program 2 and have a few question:
Code: [Select]

 for(byte i = 0; i < 16; i++)
  {
    writeEEPROM (rom, i, somedata[i], sizeof somedata[i]);
  }

Won't the EEPROM address overlap when you are writting 16bytes and only increment the address by one ?

Code: [Select]
byte readEEPROM (byte device, unsigned int addr )
  {
  byte temp;
 
  if (readEEPROM (device, addr, &temp, 1) == 0)
    return temp;
 
  return 0xFF;
 
  }

Can you change the return error code so that we can see if you are really reading 0xFF from the memory or if an error occured ?

Program 2 was my second attempt with multi byte write. Can you have a look at program 1? It write byte by byte.
I'm not sure how i must write to EEPROM or if i'm doing it the right way. If max address is 000000F0 (240) and im only write up to 16 it seens that i'm not filling it proper, but it should write something right? And dump always come with same result, almost empty.
So instead a for from 0 to 16 i must multiply counter by 16 right?

I will try your suggestion and post results

sn4k3

#8
May 19, 2017, 05:07 pm Last Edit: May 19, 2017, 05:26 pm by sn4k3
Program 1 Output is:
Quote
Wait for Wire
OK!
Write: 
0xAA, 0x55, Cannot write to device0xAA, 0x55, 0xAA, 0x55, 0x38, 0x36, 0x36, 0x2E, 0x32, 0x37, 0x38, 0x36, 0x36, 0x2E, 
0x32, 0x37, 0x3, 0x93, 0x0, 0x0, 0x0, 0x0, 0x0, 0x5, 0x7F, 0x4A, 0x2, 0x0, 0x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0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
I'm not sure why i get a Cannot write to device and if it affect the write procedure.
Should i try using 4.7K pullup on I2C Lines?

avr_fred

#9
May 19, 2017, 05:42 pm Last Edit: May 19, 2017, 05:43 pm by avr_fred
I was incorrect on the device size, yes, it is 256 bytes.

Have you tried the settings of 256 byte size, 16 bytes page size. These are the correct settings for the SkyPro.

I assumed you have removed the device from the board, is this correct?

sn4k3

I was incorrect on the device size, yes, it is 256 bytes.

Have you tried the settings of 256 byte size, 16 bytes page size. These are the correct settings for the SkyPro.

I assumed you have removed the device from the board, is this correct?

I can't set manual settings on SkyPro, settings are set by chip ref.
16 bytes can't be set and don't exists in any of skypro chips, still it will lead a invalid size.
If you look at my screenshot, skypro have 16 rows and 16 cols (16*16 = 256) which mean correct setting

Yes i remove it from board and solder in a PCB that come with skypro it just expand chip to a normal Through hole mount

sn4k3

#11
May 19, 2017, 06:14 pm Last Edit: May 19, 2017, 06:31 pm by sn4k3
Look at skypro video: http://i.imgur.com/bfBzAh5.gifv

Martin-X

#12
May 19, 2017, 11:55 pm Last Edit: May 20, 2017, 12:02 am by Martin-X Reason: Added
Both of your sketches are using 16 bit addressing, the datasheet shows that it should be 8 bit.

Code: [Select]
void i2c_eeprom_write_byte( int deviceaddress, unsigned int eeaddress, byte data )
{
  byte err;
  byte counter;

  Wire.beginTransmission(deviceaddress);
  Wire.write((byte)(eeaddress >> 8)); // MSB      <-- remove this line
  Wire.write((byte)(eeaddress & 0xFF)); // LSB
  Wire.write(&data, 1);
  err = Wire.endTransmission();

  // ... etc
}


This will need to be changed for all read and write functions.

sn4k3

#13
May 20, 2017, 07:21 pm Last Edit: May 20, 2017, 07:45 pm by sn4k3
Both of your sketches are using 16 bit addressing, the datasheet shows that it should be 8 bit.

Code: [Select]
void i2c_eeprom_write_byte( int deviceaddress, unsigned int eeaddress, byte data )
{
  byte err;
  byte counter;

  Wire.beginTransmission(deviceaddress);
  Wire.write((byte)(eeaddress >> 8)); // MSB      <-- remove this line
  Wire.write((byte)(eeaddress & 0xFF)); // LSB
  Wire.write(&data, 1);
  err = Wire.endTransmission();

  // ... etc
}


This will need to be changed for all read and write functions.

Oh man that worked, thanks!  ???  Using program 1 and 2, still first 2 bytes do not match...

Output:
Quote
Write: 
0xAA, 0x55, 0xAA, 0x55, 0xAA, 0x55, 0x38, 0x36, 0x36, 0x2E, 0x32, 0x37, 0x38, 0x36, 0x36, 0x2E, 
0x32, 0x37, 0x3, 0x93, 0x0, 0x0, 0x0, 0x0, 0x0, 0x5, 0x7F, 0x4A, 0x2, 0x0, 0xFA, 0xC5, 
0xFA, 0xFB, 0xF8, 0xF9, 0xF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, 0xFF, 0x71, 0xAC, 0x85, 0x89, 0x6F, 0x17, 0x8, 0x8, 0x8, 0x0, 0x0, 0x28, 
0xFF, 0x2B, 0x0, 0x1C, 0xAA, 0x7D, 0x8, 0x8, 0x2, 0x2, 0x0, 0x0, 0x28, 0x17, 0x0, 0x93, 
0x2, 0xB8, 0xB7, 0x22, 0x4C, 0x80, 0x80, 0x0, 0x4, 0x28, 0x7B, 0x0, 0x0, 0x0, 0x82, 0x92, 
0x2E, 0x44, 0x1, 0x1, 0x0, 0x4, 0x28, 0x1, 0x74, 0x0, 0x82, 0x0, 0x99, 0xB, 0x8, 0x10, 
0x10, 0x0, 0x0, 0x28, 0x3, 0x5F, 0x61, 0x57, 0x9E, 0x6B, 0xFF, 0x0, 0x0, 0x0, 0x0, 0x0, 
0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
Also after this SkyPro are unable to read the chip, but arduino can...

EDIT: i tried manual set bytes in program 1 and i got this result: "Cannot write to deviceCannot write to device"

Code: [Select]
i2c_eeprom_write_byte(device, 0, 0xAA);
i2c_eeprom_write_byte(device, 1, 0x55);
i2c_eeprom_write_byte(device, 2, 0xAA);


Error code is 2:received NACK on transmit of address

Martin-X

I would try Ack polling prior to the first write to make sure the device is ready.

Do the first 2 writes always fail regardless of the address or data written?

Go Up