I am trying to program my UNO to be able to write a program to EEPROM for a Z80 computer I'm trying to build. I am so close to having it done, but I have met an issue. I can tell the UNO is writing to EEPROM because code modifications affect how the CPU misbehaves lol. I tested the hardware, making sure I got my address/data bus wired correctly. It's good. So I moved to the programmer part because it was all that was left to check for malfunction.
In the code, I set two pins (formerly 0 and 1, now 8 and 9) to control the EEPROM's /OE and /WE (respectfully) and set them high in the setup, along with establishing a few more outputs and setting them as required. However, the two that control the EEPROM seem to want to always be low, which is a problem for obvious reasons. In my code, I set the pins low to perform the write and then set them high again. If I send it pseudo-data to watch the outputs, I can see that the pins go high at some point in the write, but then go back low after that until it receives new data. These are the only two times these pins change states and I am at a loss. Short of utilizing a NOR gate as an inverter), I am at a loss for what to do.
Pre-Post Edit
I added one more indicator for the shift register latch and it is behaving the same way.
const int oe = 8; // Output Enable (22)
const int we = 9; // Write Enable of EEPROM (27)
const int lat = 3; // shift register "latch" (12)
const int dat = 4; // Serial data (14)
const int clk = 5; // shift register clock (11)
int n; // temporary storage
byte Add; // address byte
byte Dat; // data byte
String readString;
void setup() {
// set up pins
pinMode(oe, OUTPUT); digitalWrite(oe,1);
pinMode(we, OUTPUT); digitalWrite(we,1);
pinMode(lat, OUTPUT); digitalWrite(lat,1);
pinMode(dat, OUTPUT);
pinMode(clk, OUTPUT); digitalWrite(clk,0);
// set up programmer and communications
Serial.begin(9600);
while (!Serial){
// wait for connection
}
Serial.println("EEPROM Programmer"); // hello message
}
void loop() {
// This clears all data from all registers
digitalWrite(lat, 0);
shiftOut(dat, clk, MSBFIRST, 0);
shiftOut(dat, clk, MSBFIRST, 0);
digitalWrite(lat, 1);
Serial.println("Specify an address"); // address to write to
while (!Serial.available()) {
// wait for data
}
while (Serial.available()) {
char c = Serial.read(); //gets one byte from serial buffer
readString += c; //makes the string readString
delay(2); //slow looping to allow buffer to fill with next character
}
if (readString.length() >0) {
Serial.println("Read: " + readString); //so you can see the captured string
n = readString.toInt(); //convert readString into a number
}
if (n > 0b11111111){
Serial.println("Invalid: Too Large"); Serial.println();
}
else {
Add = n; // valid address
readString=""; //empty for next input
Serial.println("Specify Data Byte");
while (!Serial.available()) {
// wait for data
}
while (Serial.available()) {
char c = Serial.read(); //gets one byte from serial buffer
readString += c; //makes the string readString
delay(2); //slow looping to allow buffer to fill with next character
}
if (readString.length() >0) {
Serial.println("Read: " + readString); //so you can see the captured string
n = readString.toInt(); //convert readString into a number
}
if (n > 0b11111111){
Serial.println("Invalid: Too Large"); Serial.println();
}
else {
Dat = n; //valid data
dataWrite(Add,Dat); // write to EEPROM
}
}
readString=""; //empty for next input
}
void dataWrite(int a, int b){
digitalWrite(lat, 0);
shiftOut(dat, clk, MSBFIRST, a);
shiftOut(dat, clk, MSBFIRST, b);
digitalWrite(lat, 1);
digitalWrite(oe,0); digitalWrite(we,0);
delay(1);
digitalWrite(oe,1); digitalWrite(we,1);
Serial.println("Written"); Serial.println();
}
Edit
makes post
realizes missing a ground wire to test equipment
connects ground wire
LED's stay on as opposed to flash
How to delete topic?
But since we're here anyway, I just grabbed the string-to-int code from idr where online. Can it be modified to accept hexadecimal also? That would make my project so much easier to work with as I wouldn't have to convert lots of lines to decimal before sending them.