I finally got it to work! I redid the whole assembly, but it looks like the problem was not in the assembly itself. Here is what it looks like now (Note that the ZIF is not part of the assembly and only used here to keep the IC upright for the photo):
Attachment:
IMG_20190406_134818.jpg [ 4.06 MiB | Viewed 1622 times ]
It looks like when powering up the arduino and setting some of the pins to outputs it sets them to low by default. This was solved by setting the CE and WE pins to high before setting the pins on the arduino to output.
Here is my code in case it helps anyone in the future:
Code:
#include "Arduino.h"
#define SHIFT_DATA 2
#define SHIFT_CLOCK 3
#define SHIFT_LATCH 4
#define DATA_PIN 5 // first data pin, 7 others will follow afterwards
#define WRITE_ENABLE 13
#define CHIP_ENABLE A0
#define OUTPUT_ENABLE A1
void high_pulse(int pin) {
digitalWrite(pin, LOW);
digitalWrite(pin, HIGH);
digitalWrite(pin, LOW);
}
void low_pulse(int pin) {
digitalWrite(pin, HIGH);
digitalWrite(pin, LOW);
digitalWrite(pin, HIGH);
}
void set_address(int address) {
shiftOut(SHIFT_DATA, SHIFT_CLOCK, MSBFIRST, address >> 8);
shiftOut(SHIFT_DATA, SHIFT_CLOCK, MSBFIRST, address);
high_pulse(SHIFT_LATCH);
}
void data_read_mode() {
for (int i = DATA_PIN; i <= DATA_PIN + 7; i++) {
pinMode(i, INPUT);
}
}
void data_write_mode() {
for (int i = DATA_PIN; i <= DATA_PIN + 7; i++) {
pinMode(i, OUTPUT);
}
}
int read_byte() {
int number = 0;
int temp;
for (int i = 0; i < 8; i++) {
temp = (int)digitalRead(DATA_PIN + i);
temp = temp << i;
number = number | temp;
}
return number;
}
int read(int address) {
data_read_mode();
set_address(address);
digitalWrite(WRITE_ENABLE, HIGH);
digitalWrite(CHIP_ENABLE, LOW);
digitalWrite(OUTPUT_ENABLE, LOW);
delayMicroseconds(2); // address to output delay(tACC)
int read = read_byte();
digitalWrite(CHIP_ENABLE, HIGH);
return read;
}
void write_byte(int address, int byte) {
set_address(address);
int temp;
for (int i = 0; i < 8; i++) {
temp = byte >> i;
temp = temp & 1;
digitalWrite(DATA_PIN + i, (bool)temp);
}
digitalWrite(CHIP_ENABLE, LOW);
digitalWrite(WRITE_ENABLE, LOW);
delayMicroseconds(1); // write pulse width(TWP)
digitalWrite(WRITE_ENABLE, HIGH);
digitalWrite(CHIP_ENABLE, HIGH);
delayMicroseconds(1);
}
void write_prepare() {
data_write_mode();
digitalWrite(OUTPUT_ENABLE, HIGH);
digitalWrite(CHIP_ENABLE, HIGH);
digitalWrite(WRITE_ENABLE, HIGH);
}
void write(int address, int byte) {
write_prepare();
write_byte(address, byte);
}
void setup() {
digitalWrite(CHIP_ENABLE, HIGH);
digitalWrite(WRITE_ENABLE,
HIGH); // need to set these pins to high beforehand, otherwise
// they will be pulsed low when the arduino is powered on
pinMode(SHIFT_DATA, OUTPUT);
pinMode(SHIFT_CLOCK, OUTPUT);
pinMode(SHIFT_LATCH, OUTPUT);
pinMode(WRITE_ENABLE, OUTPUT);
pinMode(CHIP_ENABLE, OUTPUT);
pinMode(OUTPUT_ENABLE, OUTPUT);
digitalWrite(CHIP_ENABLE, HIGH);
Serial.begin(9600);
}
void loop() {
for (int i = 0; i <= 0x7FFF; i++) {
write(i, i % 255);
Serial.println(read(i));
}
}