Skip to main content
added 4 characters in body
Source Link
#define WE 52
#define OE 51
#define CE 53
#define NUM_ADDR 3

int DP[8] = {22, 23, 24, 25, 26, 27, 28, 29};
int AP[] = {37, 36, 35};
byte data[] = {0xB080400, 0x1C16140F, 0x2A28231E, 2F32373A0x3A37322F, 0x4B46433F, 0x5B57534E, 5F63676B0x6B67635F, 0x7B77736F, 0x8B86837E, 0x9A97938E, 0xABA7A29F, 0xBBB6B3AE, 0xCBC6C3BE, 0xDAD7D3CE, 0xEAE7E2DF, 0xFAF7F2EF}; /// Sinus Lookup-Table


//------------------------ Init ----------------------------

void setupDataBus(int mode) {
  for (int i = 0; i < 8; i++) {
    pinMode(DP[i], mode);
  }
}

void setupControlPins(int mode) {
  pinMode(WE, mode);
  pinMode(OE, mode);
  pinMode(CE, mode);
}

void setupAddressBus(int mode) {
  for (int i = 0; i < NUM_ADDR; i++) {
    pinMode(AP[i], mode);
  }
}

//------------------------ Write Byte ----------------------

void writeByte(int address, byte data) {
  setupDataBus(OUTPUT);
  setupAddressBus(OUTPUT);
  setupControlPins(OUTPUT);
  Serial.print("Write Byte: ");
  for (int b = 0; b < 7; b++) {
    digitalWrite(AP[b], bitRead(address, b));

  }
  Serial.print(address, HEX);
  Serial.print(", ");
  Serial.print(data, HEX);
  Serial.println();
  delay(1);
  // Enable write
  digitalWrite(OE, HIGH);
  delay(1);
  digitalWrite(CE, LOW);
  delay(1);
  delay(10);
  for (int b = 0; b < 8; b++) {
    digitalWrite(DP[b], bitRead(data, b));
  }
  unsigned long time_i, time_f, time;
  time_i = micros();
  // Start write
  digitalWrite(WE, LOW);
  // End write
  digitalWrite(WE, HIGH);
  time = micros();
  Serial.println(time_f - time_i, DEC);
  delay(1);
  digitalWrite(OE, LOW);
  delay(1);
  digitalWrite(CE, HIGH);
  delay(1);

}

//------------------------ Read Byte ----------------------

byte readByte(int address) {
  setupDataBus(INPUT);
  setupAddressBus(OUTPUT);
  setupControlPins(OUTPUT);
  byte val;
  digitalWrite(WE, HIGH);
  delay(1);
  digitalWrite(CE, HIGH);
  delay(1);
  digitalWrite(OE, HIGH);
  delay(1);
  Serial.print("Read Byte: ");
  for (int b = 0; b < 7; b++) {
    digitalWrite(AP[b], bitRead(address, b));
  }

  Serial.print(address, HEX); /// print Address
  Serial.print(", ");
  delay(1);
  digitalWrite(WE, HIGH);
  delay(1);
  digitalWrite(CE, LOW);
  delay(1); 
  digitalWrite(OE, LOW);
  delay(1);

  for (int b = 0; b < 8; b++) {
    bitWrite(val, b, digitalRead(DP[b]));
  }

  Serial.print(val, HEX); /// print Bit
  delay(1);
  digitalWrite(OE, HIGH);
  delay(1);
  digitalWrite(CE, HIGH);
  delay(1);
  digitalWrite(WE, HIGH);
  Serial.println();
  return val;
}

//------------------------ SETUP ----------------------

void setup() {
  setupDataBus(OUTPUT);
  setupAddressBus(OUTPUT);
  pinMode(WE, OUTPUT);
  pinMode(OE, OUTPUT);
  pinMode(CE, OUTPUT);
  Serial.begin(9600);
}

//------------------------ LOOP -----------------------

void loop() {
  // init
  digitalWrite(OE, HIGH);
  digitalWrite(CE, HIGH);
  digitalWrite(WE, HIGH);
  Serial.println("Initializing pins for write...");
  delay(1000);
  //for (int i = 0; i < sizeof(data); i++) {
  //writeByte(i, data[i]);
  //}
  for (int i = 0; i < sizeof(data); i++) {
    readByte(i);
  }
  while (true);
}
#define WE 52
#define OE 51
#define CE 53
#define NUM_ADDR 3

int DP[8] = {22, 23, 24, 25, 26, 27, 28, 29};
int AP[] = {37, 36, 35};
byte data[] = {0xB080400, 0x1C16140F, 0x2A28231E, 2F32373A, 0x4B46433F, 0x5B57534E, 5F63676B, 0x7B77736F, 0x8B86837E, 0x9A97938E, 0xABA7A29F, 0xBBB6B3AE, 0xCBC6C3BE, 0xDAD7D3CE, 0xEAE7E2DF, 0xFAF7F2EF}; /// Sinus Lookup-Table


//------------------------ Init ----------------------------

void setupDataBus(int mode) {
  for (int i = 0; i < 8; i++) {
    pinMode(DP[i], mode);
  }
}

void setupControlPins(int mode) {
  pinMode(WE, mode);
  pinMode(OE, mode);
  pinMode(CE, mode);
}

void setupAddressBus(int mode) {
  for (int i = 0; i < NUM_ADDR; i++) {
    pinMode(AP[i], mode);
  }
}

//------------------------ Write Byte ----------------------

void writeByte(int address, byte data) {
  setupDataBus(OUTPUT);
  setupAddressBus(OUTPUT);
  setupControlPins(OUTPUT);
  Serial.print("Write Byte: ");
  for (int b = 0; b < 7; b++) {
    digitalWrite(AP[b], bitRead(address, b));

  }
  Serial.print(address, HEX);
  Serial.print(", ");
  Serial.print(data, HEX);
  Serial.println();
  delay(1);
  // Enable write
  digitalWrite(OE, HIGH);
  delay(1);
  digitalWrite(CE, LOW);
  delay(1);
  delay(10);
  for (int b = 0; b < 8; b++) {
    digitalWrite(DP[b], bitRead(data, b));
  }
  unsigned long time_i, time_f, time;
  time_i = micros();
  // Start write
  digitalWrite(WE, LOW);
  // End write
  digitalWrite(WE, HIGH);
  time = micros();
  Serial.println(time_f - time_i, DEC);
  delay(1);
  digitalWrite(OE, LOW);
  delay(1);
  digitalWrite(CE, HIGH);
  delay(1);

}

//------------------------ Read Byte ----------------------

byte readByte(int address) {
  setupDataBus(INPUT);
  setupAddressBus(OUTPUT);
  setupControlPins(OUTPUT);
  byte val;
  digitalWrite(WE, HIGH);
  delay(1);
  digitalWrite(CE, HIGH);
  delay(1);
  digitalWrite(OE, HIGH);
  delay(1);
  Serial.print("Read Byte: ");
  for (int b = 0; b < 7; b++) {
    digitalWrite(AP[b], bitRead(address, b));
  }

  Serial.print(address, HEX); /// print Address
  Serial.print(", ");
  delay(1);
  digitalWrite(WE, HIGH);
  delay(1);
  digitalWrite(CE, LOW);
  delay(1); 
  digitalWrite(OE, LOW);
  delay(1);

  for (int b = 0; b < 8; b++) {
    bitWrite(val, b, digitalRead(DP[b]));
  }

  Serial.print(val, HEX); /// print Bit
  delay(1);
  digitalWrite(OE, HIGH);
  delay(1);
  digitalWrite(CE, HIGH);
  delay(1);
  digitalWrite(WE, HIGH);
  Serial.println();
  return val;
}

//------------------------ SETUP ----------------------

void setup() {
  setupDataBus(OUTPUT);
  setupAddressBus(OUTPUT);
  pinMode(WE, OUTPUT);
  pinMode(OE, OUTPUT);
  pinMode(CE, OUTPUT);
  Serial.begin(9600);
}

//------------------------ LOOP -----------------------

void loop() {
  // init
  digitalWrite(OE, HIGH);
  digitalWrite(CE, HIGH);
  digitalWrite(WE, HIGH);
  Serial.println("Initializing pins for write...");
  delay(1000);
  //for (int i = 0; i < sizeof(data); i++) {
  //writeByte(i, data[i]);
  //}
  for (int i = 0; i < sizeof(data); i++) {
    readByte(i);
  }
  while (true);
}
#define WE 52
#define OE 51
#define CE 53
#define NUM_ADDR 3

int DP[8] = {22, 23, 24, 25, 26, 27, 28, 29};
int AP[] = {37, 36, 35};
byte data[] = {0xB080400, 0x1C16140F, 0x2A28231E, 0x3A37322F, 0x4B46433F, 0x5B57534E, 0x6B67635F, 0x7B77736F, 0x8B86837E, 0x9A97938E, 0xABA7A29F, 0xBBB6B3AE, 0xCBC6C3BE, 0xDAD7D3CE, 0xEAE7E2DF, 0xFAF7F2EF}; /// Sinus Lookup-Table


//------------------------ Init ----------------------------

void setupDataBus(int mode) {
  for (int i = 0; i < 8; i++) {
    pinMode(DP[i], mode);
  }
}

void setupControlPins(int mode) {
  pinMode(WE, mode);
  pinMode(OE, mode);
  pinMode(CE, mode);
}

void setupAddressBus(int mode) {
  for (int i = 0; i < NUM_ADDR; i++) {
    pinMode(AP[i], mode);
  }
}

//------------------------ Write Byte ----------------------

void writeByte(int address, byte data) {
  setupDataBus(OUTPUT);
  setupAddressBus(OUTPUT);
  setupControlPins(OUTPUT);
  Serial.print("Write Byte: ");
  for (int b = 0; b < 7; b++) {
    digitalWrite(AP[b], bitRead(address, b));

  }
  Serial.print(address, HEX);
  Serial.print(", ");
  Serial.print(data, HEX);
  Serial.println();
  delay(1);
  // Enable write
  digitalWrite(OE, HIGH);
  delay(1);
  digitalWrite(CE, LOW);
  delay(1);
  delay(10);
  for (int b = 0; b < 8; b++) {
    digitalWrite(DP[b], bitRead(data, b));
  }
  unsigned long time_i, time_f, time;
  time_i = micros();
  // Start write
  digitalWrite(WE, LOW);
  // End write
  digitalWrite(WE, HIGH);
  time = micros();
  Serial.println(time_f - time_i, DEC);
  delay(1);
  digitalWrite(OE, LOW);
  delay(1);
  digitalWrite(CE, HIGH);
  delay(1);

}

//------------------------ Read Byte ----------------------

byte readByte(int address) {
  setupDataBus(INPUT);
  setupAddressBus(OUTPUT);
  setupControlPins(OUTPUT);
  byte val;
  digitalWrite(WE, HIGH);
  delay(1);
  digitalWrite(CE, HIGH);
  delay(1);
  digitalWrite(OE, HIGH);
  delay(1);
  Serial.print("Read Byte: ");
  for (int b = 0; b < 7; b++) {
    digitalWrite(AP[b], bitRead(address, b));
  }

  Serial.print(address, HEX); /// print Address
  Serial.print(", ");
  delay(1);
  digitalWrite(WE, HIGH);
  delay(1);
  digitalWrite(CE, LOW);
  delay(1); 
  digitalWrite(OE, LOW);
  delay(1);

  for (int b = 0; b < 8; b++) {
    bitWrite(val, b, digitalRead(DP[b]));
  }

  Serial.print(val, HEX); /// print Bit
  delay(1);
  digitalWrite(OE, HIGH);
  delay(1);
  digitalWrite(CE, HIGH);
  delay(1);
  digitalWrite(WE, HIGH);
  Serial.println();
  return val;
}

//------------------------ SETUP ----------------------

void setup() {
  setupDataBus(OUTPUT);
  setupAddressBus(OUTPUT);
  pinMode(WE, OUTPUT);
  pinMode(OE, OUTPUT);
  pinMode(CE, OUTPUT);
  Serial.begin(9600);
}

//------------------------ LOOP -----------------------

void loop() {
  // init
  digitalWrite(OE, HIGH);
  digitalWrite(CE, HIGH);
  digitalWrite(WE, HIGH);
  Serial.println("Initializing pins for write...");
  delay(1000);
  //for (int i = 0; i < sizeof(data); i++) {
  //writeByte(i, data[i]);
  //}
  for (int i = 0; i < sizeof(data); i++) {
    readByte(i);
  }
  while (true);
}
Source Link

How to write a lookup-table into an 28C64 parallel EEPROM?

Based on the program from this post 28C64 EEPROM Programming Using Arduino, I would like to write, using Arduino Mega, a lookup-table that contains one sinewave cycle, created in Excel. I would like this table to be written in address "1" in the EEPROM. I have encoded the table in hex, but I am not sure how to split it into proper code. I would also like to read the table with the Arduino Serial Plotter instead of Serial Printer. Thanks.

enter image description here

sinus wave in HEX:

0004080B 0F14161C 1E23282A 2F32373A 3F43464B 4E53575B 5F63676B 6F73777B 7E83868B 8E93979A 9FA2A7AB AEB3B6BB BEC3C6CB CED3D7DA DFE2E7EA EFF2F7FA

the code:

#define WE 52
#define OE 51
#define CE 53
#define NUM_ADDR 3

int DP[8] = {22, 23, 24, 25, 26, 27, 28, 29};
int AP[] = {37, 36, 35};
byte data[] = {0xB080400, 0x1C16140F, 0x2A28231E, 2F32373A, 0x4B46433F, 0x5B57534E, 5F63676B, 0x7B77736F, 0x8B86837E, 0x9A97938E, 0xABA7A29F, 0xBBB6B3AE, 0xCBC6C3BE, 0xDAD7D3CE, 0xEAE7E2DF, 0xFAF7F2EF}; /// Sinus Lookup-Table


//------------------------ Init ----------------------------

void setupDataBus(int mode) {
  for (int i = 0; i < 8; i++) {
    pinMode(DP[i], mode);
  }
}

void setupControlPins(int mode) {
  pinMode(WE, mode);
  pinMode(OE, mode);
  pinMode(CE, mode);
}

void setupAddressBus(int mode) {
  for (int i = 0; i < NUM_ADDR; i++) {
    pinMode(AP[i], mode);
  }
}

//------------------------ Write Byte ----------------------

void writeByte(int address, byte data) {
  setupDataBus(OUTPUT);
  setupAddressBus(OUTPUT);
  setupControlPins(OUTPUT);
  Serial.print("Write Byte: ");
  for (int b = 0; b < 7; b++) {
    digitalWrite(AP[b], bitRead(address, b));

  }
  Serial.print(address, HEX);
  Serial.print(", ");
  Serial.print(data, HEX);
  Serial.println();
  delay(1);
  // Enable write
  digitalWrite(OE, HIGH);
  delay(1);
  digitalWrite(CE, LOW);
  delay(1);
  delay(10);
  for (int b = 0; b < 8; b++) {
    digitalWrite(DP[b], bitRead(data, b));
  }
  unsigned long time_i, time_f, time;
  time_i = micros();
  // Start write
  digitalWrite(WE, LOW);
  // End write
  digitalWrite(WE, HIGH);
  time = micros();
  Serial.println(time_f - time_i, DEC);
  delay(1);
  digitalWrite(OE, LOW);
  delay(1);
  digitalWrite(CE, HIGH);
  delay(1);

}

//------------------------ Read Byte ----------------------

byte readByte(int address) {
  setupDataBus(INPUT);
  setupAddressBus(OUTPUT);
  setupControlPins(OUTPUT);
  byte val;
  digitalWrite(WE, HIGH);
  delay(1);
  digitalWrite(CE, HIGH);
  delay(1);
  digitalWrite(OE, HIGH);
  delay(1);
  Serial.print("Read Byte: ");
  for (int b = 0; b < 7; b++) {
    digitalWrite(AP[b], bitRead(address, b));
  }

  Serial.print(address, HEX); /// print Address
  Serial.print(", ");
  delay(1);
  digitalWrite(WE, HIGH);
  delay(1);
  digitalWrite(CE, LOW);
  delay(1); 
  digitalWrite(OE, LOW);
  delay(1);

  for (int b = 0; b < 8; b++) {
    bitWrite(val, b, digitalRead(DP[b]));
  }

  Serial.print(val, HEX); /// print Bit
  delay(1);
  digitalWrite(OE, HIGH);
  delay(1);
  digitalWrite(CE, HIGH);
  delay(1);
  digitalWrite(WE, HIGH);
  Serial.println();
  return val;
}

//------------------------ SETUP ----------------------

void setup() {
  setupDataBus(OUTPUT);
  setupAddressBus(OUTPUT);
  pinMode(WE, OUTPUT);
  pinMode(OE, OUTPUT);
  pinMode(CE, OUTPUT);
  Serial.begin(9600);
}

//------------------------ LOOP -----------------------

void loop() {
  // init
  digitalWrite(OE, HIGH);
  digitalWrite(CE, HIGH);
  digitalWrite(WE, HIGH);
  Serial.println("Initializing pins for write...");
  delay(1000);
  //for (int i = 0; i < sizeof(data); i++) {
  //writeByte(i, data[i]);
  //}
  for (int i = 0; i < sizeof(data); i++) {
    readByte(i);
  }
  while (true);
}