Hi,
I was working on a little electronics project: a z80 computer, while I was doing that I needed to program an EEPROM, after seeing the price of a universal programmer, I decided to make my own using an arduino.
So far I managed to read the EEPROM and to erase it using my Arduino, here you can see my code for writing 0's to the EEPROM. Now I want to burn a binary image, let's call it "data.rom", to the EEPROM. I was thinking of using serial communication and then use some sort of script that reads data.rom and that passes byte per byte to the arduino through the serial monitor. The arduino then stores the byte in "D" (see code) and then writes that byte, and then wait for a new byte and so on.
But I'm not so familiar with coding for the arduino, neither with serial communication, so I was hoping someone could help me.
/*
EEPROM Programmer
*/
#define memsize 8192
int STS = 13; // Status Indicator
// The pins that are used for the address bus
int AP[13] = {24,26,30,32,36,38,42,44,48,50,47,51,53};
// Used by the code to decode an address
int AD[16] = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};
// The pins used for the Data bus
int DP[8] = {23,25,29,31,35,37,41,43};
// Used by the code to decode a byte
int DD[8] = {0,0,0,0,0,0,0,0};
// Pins used for the control bus
int CE = 6;
int OE = 4;
int WE = 2;
int i; // Used by for-loops
int A; // Used to store the current address in the main loop
int D; // Used to store the byte that will be written in that cycle to address A
void setup()
{
Serial.begin(9600);
Serial.println("Writing EEPROM...");
// Led that shows activity
pinMode(STS, OUTPUT);
// Setup Address Pins
for (i=0;i<16;i++)
{
pinMode(AP[i],OUTPUT);
}
// Setup Data Pins
for (i=0;i<8;i++)
{
pinMode(DP[i],OUTPUT);
}
// Setup Control Pins
pinMode(CE, OUTPUT);
pinMode(WE, OUTPUT);
pinMode(OE, OUTPUT);
// Setup Chip
digitalWrite(CE, LOW);
digitalWrite(WE, LOW);
digitalWrite(OE, HIGH);
// Loop that writes Byte per byte
for (A=0;A<memsize;A++)
{
// D is the Byte that will be written to the current address(A).
D=0;
digitalWrite(STS,HIGH); //Signal that we're writing.
// Setup Address Pins
for (i=0;i<13;i++)
{
if((A&bit(i))>0)
{
AD[i]=HIGH;
} else {
AD[i]=LOW;
}
digitalWrite(AP[i],AD[i]);
}
// Setup Control bus
digitalWrite(OE,LOW); // Reads Disabled
delay(1); // Give the EEPROM some time to catch up
digitalWrite(CE,HIGH); // Chip Enable
digitalWrite(WE,HIGH); // Write Enabled
// Setup Data Pins
for (i=0;i<8;i++)
{
if((D&bit(i))>0)
{
DD[i]=HIGH;
} else {
DD[i]=LOW;
}
digitalWrite(DP[i],DD[i]);
}
// Write data (D)
digitalWrite(WE,LOW); // Write Disabled
digitalWrite(CE,LOW); // Chip Disabled
digitalWrite(OE,HIGH); // Reads Enabled
delay(1);
digitalWrite(STS,LOW); // Signal that we're waiting
}
// We got through the loop, signal that the write was succesfull
Serial.println("Done...");
}
void loop() {
// Small loop to show that data was written and device can be removed
digitalWrite(STS, HIGH);
delay(1000);
digitalWrite(STS, LOW);
delay(1000);
}