Monday, November 16, 2020

EPROM programmer -2-

This is part 2 of my post about my EPROM programmer. I did not yet tested the EPROM programmer however i want to report that i have tested the I2C_EEPROM that i mounted on my board.

As i mentioned in my last post , having an EEPROM on a UV EPROM board is perhaps a little confusing. It think it can be a valuable add on. Use cases for the additional EEPROM can be;

  • using the EPROM programmer as stand alone device to write the same program to several EPROMs
  • reading several EPROMS to the EEPROM for later investigation
  • comparing EPROMs with EEPROM
  • creating an EPROM emulator
  • using a spare PCB of this programmer to add an I2C_EEPROM to a project (most PCB manufacturers (like JLCPCB send out multiple PCBs)
  • .........

I have recently tested an I2C EEPROM on my PCB and it works fine.
The first sketch used for testing is the sketch below (as found at several places on the internet) and some variants i created of it:
/*
* I2C EEPROM sketch
* this version for 24LC128
*/
#include <Wire.h>
const byte EEPROM_ID = 0x50; // I2C address for 24LC128 EEPROM
// first visible ASCII character '!' is number 33:
int thisByte = 33;
void setup()
{
Serial.begin(9600);Wire.begin();
Serial.println("Writing 1024 bytes to EEPROM");
for (int i=0; i < 1024; i++)
{
I2CEEPROM_Write(i, thisByte);
// go on to the next character
thisByte++;
if (thisByte == 126) // you could also use if (thisByte == '~')
thisByte = 33; // start over
}
Serial.println("Reading 1024 bytes from EEPROM");
int thisByte = 33;
for (int i=0; i < 1024; i++)
{
char c = I2CEEPROM_Read(i);
if( c != thisByte)
{
Serial.println("read error");
break;
}
else
{
Serial.print(c);
}
thisByte++;
if(thisByte == 126)
{
Serial.println();
thisByte = 33; // start over on a new line
}
}
Serial.println();
}
void loop()
{
}
// This function is similar to EEPROM.write()
void I2CEEPROM_Write( unsigned int address, byte data )
{
Wire.beginTransmission(EEPROM_ID);
Wire.write((int)highByte(address) );
Wire.write((int)lowByte(address) );
Wire.write(data);
Wire.endTransmission();
delay(5); // wait for the I2C EEPROM to complete the write cycle
}
// This function is similar to EEPROM.read()
byte I2CEEPROM_Read(unsigned int address )
{
byte data;
Wire.beginTransmission(EEPROM_ID);
Wire.write((int)highByte(address) );
Wire.write((int)lowByte(address) );
Wire.endTransmission();
Wire.requestFrom(EEPROM_ID,(byte)1);
while(Wire.available() == 0) // wait for data
;
data = Wire.read();
return data;
}

However i did first run an I2C scan program to check the ID of the EEPROM. And with the EEPROM connected i found indeed the ID value 0x50 as used in the script.
Reading writing to te EEPROM works fine. Next step to make EPROM programmer working is testing and writing code for the SN 74595 shift registers.


Meanwhile i am also working on a redesign of my EEPROM shield for multiple EEPROMs. I did not yet order my first design at e JLCPCB  as i had some ideas for improvements and features that i wanted to add. 
On my 'Arduino to do list' is also writing a a better memory dump program for these EEPROMs and also running Forth code on the Arduino Uno.

No comments: