EEPROM fun

I had to program a legacy EEPROM on a Mercedes EDC15 ECU. I had a choice: to buy a reliable tool to read/write the E2P(3SP08/95SP08) or make my own by reading the datasheet. I chose the 2nd option.

This particular E2P isn’t supported by any opensource libraries(it’s very old), so the first thing I had to figure out was how the SPI was to be configured. Data/instructions are sent MSB first. Clock is low when idle and data is sampled on leading edge of clock. This means it’s Mode 0 SPI(CPOL = 0, CPHA = 0). This E2P had a max SPI clock of 2MHz, to be safe I used the slowest clock mode on arduino:

SPCR = (1<<SPE)|(1<<MSTR)|(1<<SPR1)|(1<<SPR0);

The opcodes for the instructions were special on this E2P:

The 2 MSb’s of the address(A9, A8) were to be encoded with the READ/WRITE opcode. I wrote these functions for R/W of this E2P on arduino:

byte read_eeprom(int EEPROM_address)
{
//READ EEPROM
int data;
digitalWrite(SLAVESELECT,LOW);
// bit A8 and A9 are copied to bit pos 4 and 5 of READ/WRITE opcode
byte A8A9=(byte)((EEPROM_address & 0x300) >> 5);
spi_transfer(READ | A8A9); //transmit read opcode
spi_transfer((byte)(EEPROM_address)); //send LSByte address
data = spi_transfer(0xFF); //get data byte
digitalWrite(SLAVESELECT,HIGH); //release chip, signal end transfer
return data;
}
void write_eeprom(int EEPROM_address, char data)
{
//WRITE EEPROM
digitalWrite(SLAVESELECT,LOW);
spi_transfer(WREN);
digitalWrite(SLAVESELECT,HIGH);
delay(5);
digitalWrite(SLAVESELECT,LOW);
// bit A8 and A9 are copied to bit pos 4 and 5 of READ/WRITE opcode
byte A8A9=(byte)((EEPROM_address & 0x300) >> 5);
spi_transfer(WRITE | A8A9); //transmit read opcode
spi_transfer((byte)(EEPROM_address)); //send LSByte address
spi_transfer(data); //write data byte
digitalWrite(SLAVESELECT,HIGH); //release chip, signal end transfer
delay(5);
}

The delays in the write function are to follow the timing diagrams in the datasheet:

I was in a rush to test this out, here’s the wiring:

Now, I’ll be testing an Immobiliser delete for this engine(never been made before by anyone 😉 ), lying in my backyard:


4 thoughts on “EEPROM fun

Leave a Reply

Your email address will not be published. Required fields are marked *

Related Posts

Begin typing your search term above and press enter to search. Press ESC to cancel.

Back To Top