EEPROM reader malfunctionning

Hello guys,

I'm trying to read the content of a P24C08C EEPROM (I2C) to get the firmware stored inside it.
I tried many things, none of them worked:

  • Using a CH341A programmer, but the hardware is malfunctionning even when I tried fixing the capacitance problem it has.

  • Using example codes from the I2C_EEPROM library. It connects and read the chip. But it struggles to even understand the size of the chip (sometimes it tells that it is a 2ko EEPROM, which it is not.). And tells me the chip is always empty (full 0 or FF, depending on whatever is happening in the code for some reason)

  • Using example codes from the library JC_EEPROM. It can't even detect the chip, and I can't seem to be able to do anything about it.

  • Lastly, I made my own simple sketch, here it is:

#include <Wire.h>

const uint8_t EEPROM_ADDR = 0x50;
const uint16_t EEPROM_SIZE = 1024;

uint8_t readByte(uint8_t slave_address, uint8_t word_address){
  Wire.beginTransmission(slave_address);
  Wire.write(word_address >> 8);
  Wire.write(word_address & 0xFF);
  Wire.endTransmission();
  Wire.requestFrom(slave_address, 1);

  if (Wire.available()) {
    return Wire.read();
  }
}

void setup(void){
  Serial.begin(115200);
  Wire.begin();

  for (int i = 0; i < EEPROM_SIZE; i++) {
    Serial.print("Value @ Adrr "); Serial.print(i); Serial.print(" is: ");
    Serial.println(readByte(EEPROM_ADDR, i), HEX);
  }
}

void loop() {}

It reads the chip but always tell me "Value @ Addr X is: 3", which seems to be absurd. The EEPROM was used in an industrial SFP, it should have been programmed correctly I suppose. And the memory has no read protection, so I don't think it has to do with that.

Does someone has any idea on how to retrieve the hex table from that EEPROM? (It must not be erased beforehand of course).

PS : I have scanned addresses before communicating with the chip. It founds 8 address starting from 0x50, seems normal considering that we can hard configure the chip address between 8 different configs.

Hello,

This subject has been treated so many times, please read the forum next time before asking a question.

Also, your code writes to the EEPROM but you said you wanted not to erase content???

I2C_EEPROM

I have no experience with the P24C08C so it is not tested the library.
I might be compatible, or not.
Do you have a link to the data sheet of the P24C08C?

Back to your problem:
Use this constructor to set the size. Do not use determineSize () or determineSizeNoWrite().

  I2C_eeprom(const uint8_t deviceAddress, const uint32_t deviceSize, TwoWire *wire = &Wire);

Does that give better results?
Please post the code you used with the library and its output.

Found a datasheet

Page 12 of the datasheet describes the addressing modes, night help.

Thanks for trying to help.
Unfortunately, I already had the datasheet in hand, and it was no use. Or at least, I can't understand it properly.

For example, the memory address seems to be off, on the datasheet it says that I can address it via 0b1011xxxx
But the I2C scanner recognises address 0x50 and so forth (0101xxxx). Something may be wrong.

If I don't succeed rapidly, I might as well find an entirely different approach to my project that does not recquire EEPROM readings.

If you have any additionnal info, that'll help

How to you expect to pass a word (e.g. uint16_t) when you declare your parameter as an 8 bit value?

And after you fix that, the P24C08C has a 10 bit address (A9...A0) and according to the datasheet, you have to put A9 and A8 into the lower bits of the chip Address byte. Remember that the Wire library shifts the address byte 1 bit internally and then adds the R/W bit. so your code should look something like this

#include <Wire.h>

const uint8_t EEPROM_ADDR = 0x50;
const uint16_t EEPROM_SIZE = 1024;

uint8_t readByte(uint8_t slave_address, uint16_t word_address) {
  uint8_t msb_word = (word_address >> 8) & 0x03;  // only 2 bits
  uint8_t lsb_word = word_address & 0xFF;         // not really necessary

  slave_address += msb_word;    // address = 0101 00 A9 A8
  
  Wire.beginTransmission(slave_address);
  Wire.write(lsb_word);
  Wire.endTransmission();
  Wire.requestFrom(slave_address, 1);

  while(!Wire.available()) {
  }
  return Wire.read();
}

void setup(void) {
  Serial.begin(115200);
  Wire.begin();

  for (int i = 0; i < EEPROM_SIZE; i++) {
    Serial.print("Value @ Adrr "); Serial.print(i); Serial.print(" is: ");
    Serial.println(readByte(EEPROM_ADDR, i), HEX);
  }
}

void loop() {}

Okay, one of my misunderstanding came from the fact that I did not know the Wire library shifted one byte, wich made the address seems a bit odd to me.

Thank you for your help, I think that is enough hints for me to achieve my target goal.

One bit, not byte. That is why you specify the chip address as 0x50 (0b 0101 0000) but the data sheet shows it as 0b 1010 xxxx which would be 0xA0

Yep sorry, I understood. Just a typo.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.