I need to test an old EEPROM and I need single cycle writes and reads (20ns timing is OK)

I want to help you, and everyone else here probably does too, but the way you're communicating makes effective help pretty much impossible. We really do help on this forum, but we're not psychics. We can't see your hardware unless you show us photos or clear accurate diagrams. We can't see your code unless you show us. So far the only code you've giving is AI generated without any consideration for the pins actually available on Teensy 4.1, and indeed we have made several suggestions based on that code.

You've said you can't give info because this is work related. But if you can't even show us how the pins are really connected, nobody can give specific and useful answers for the code which controls those pins.

Simply reading a 27C256 (you previously said 27C265 but I'm guessing those last 2 digits are a typo) isn't something special which anyone needs to keep secret. These EPROM chips have been around for over 40 years! I personally build several projects with then in the early 1990s.

If you only need to read the chip, which I specifically asked in msg #17 and you didn't clearly respond yes/no, but if reading the chip is all you need, the best suggestion is in msg #18... just buy a known-good EPROM programmer and use it to read your chip.

Normally going full DIY for something you can just buy is the realm of hobby electronics and education. But if you really want to go that way for some reason I can't understand in the context of business, that's fine. But if you don't tell us why, if we don't understand what you really need and why you're doing this instead of just buying off-the-shelf hardware, our answers can't be based on any understand of what you really need.

Still, we can try anyway. On that...



In msg #15, I suggested you use digitalWriteFast() rather than direct GPIO registers.



To quickly answer your latest question with more "I can't answer"...



Indeed intermittent and unreproducible problems are hard. Usually the path forward involves a combination of better observation of what's really happening, and a lot of experimentation and just thinking about it based on what you observe with each experiment.

I see in msg #19 you're using an oscilloscope to view the waveform. That's good. What's not good is your communication here on this forum. Nothing in msg #19 tells us any essential info needed to form opinion about that oscilloscope screenshot. We can't see your hardware because you haven't show a photo or accurate diagram. We can't see the code you actually ran on Teensy (presumably it's not the non-working AI gen code). The message doesn't even tell us which signal the oscilloscope is showing!

I want you to understand the reason you're not getting more useful help here, when we do really help quite a lot on this forum, is because you are communicating so poorly. If you invest some effort to really show us the hardware, software, and tests you're actually doing, we can and probably will help you much better. But it all depends on your ability to communicate effectively. If you keep us in the dark, the best help anyone can give is generic advice.

And again on generic advice, if this is really for your workplace, just buy a working EPROM programmer. These EPROM chips aren't special. You don't need to DIY build just to read one.
/*due to ITAR government regulations I was warned on what I can say. So I do not want to say the type of equipment and the use of it. I can say what I need in general. I need a ~500ns read cycle of a 27C256 EEPROM on a 300 to 500ns read cycle. I need to go over temperature and be able change the ADDRESS Setup Time to CS time in 20ns steps starting at 80ns.

I need a minimum of 16 lines, this works but only with 11 pins active:
*/
#include <Arduino.h>

// Define which GPIO ports you use.
// For high speed on Teensy 4.1, use GPIO6, GPIO7, GPIO8, or GPIO9.
// Example:
// - 8 bits for EEPROM Data (read) mapped to a set of 8 consecutive pins on GPIO6.
// - 20 bits for Address lines (write) mapped across GPIO6/GPIO7 or a dedicated port.

// Mask for 8 data bits (e.g., bits 0 to 7 of GPIO6)
#define DATA_MASK 0x000000FF
// Mask for 20 address bits (e.g., bits 0 to 19 of GPIO7)
#define ADDR_MASK 0x000FFFFF








void setup() {


// Configure 8 Data pins as INPUT (0 in GDIR)
GPIO6_GDIR &= ~DATA_MASK;

// Configure 20 Address pins as OUTPUT (1 in GDIR)
GPIO7_GDIR |= ADDR_MASK;

// Optional: Set MUX to GPIO mode for these pads if they default to a peripheral
// (Ensure your chosen pins are configured as ALT5 / GPIO in IOMUXC)


}

// Function to parallel write a 20-bit address
inline void writeAddress20(uint32_t address) {
// Clear the 20 address bits first, then apply the new 20-bit value
uint32_t currentVal = GPIO7_DR & ~ADDR_MASK;
GPIO7_DR = currentVal | (address & ADDR_MASK);
}

// Function to parallel read 8 data bits from EEPROM
inline uint8_t readData8() {
// Use GPIO6_PSR (Pin Status Register) for accurate physical pin reading
return (uint8_t)(GPIO6_PSR & DATA_MASK);
}

void loop() {
// uint32_t testAddress = 0x01234; // Example 20-bit address (0 to 0xFFFFF)
// 1. Write the 20-bit address in parallel

//051CB -> 01
writeAddress20(0xFFFFF);
writeAddress20(0xFFFFF);
writeAddress20(0xFFFFF);
writeAddress20(0xFFFFF);
writeAddress20(0xFFFFF); // CS goes low
writeAddress20(0xFFFFF); // OE goes low
writeAddress20(0xFFFFF);
// eepromDataCB = readData8();
writeAddress20(0x00000); //visual for scope
writeAddress20(0xFFFFF);
writeAddress20(0x00000);

delayMicroseconds(1);

}
 
/*due to ITAR government regulations I was warned on what I can say. So I do not want to say the type of equipment and the use of it. I can say what I need in general. I need a ~500ns read cycle of a 27C256 EEPROM on a 300 to 500ns read cycle. I need to go over temperature and be able change the ADDRESS Setup Time to CS time in 20ns steps starting at 80ns.

I need a minimum of 16 lines, this works but only with 11 pins active:
*/
#include <Arduino.h>

// Define which GPIO ports you use.
// For high speed on Teensy 4.1, use GPIO6, GPIO7, GPIO8, or GPIO9.
// Example:
// - 8 bits for EEPROM Data (read) mapped to a set of 8 consecutive pins on GPIO6.
// - 20 bits for Address lines (write) mapped across GPIO6/GPIO7 or a dedicated port.

// Mask for 8 data bits (e.g., bits 0 to 7 of GPIO6)
#define DATA_MASK 0x000000FF
// Mask for 20 address bits (e.g., bits 0 to 19 of GPIO7)
#define ADDR_MASK 0x000FFFFF








void setup() {


// Configure 8 Data pins as INPUT (0 in GDIR)
GPIO6_GDIR &= ~DATA_MASK;

// Configure 20 Address pins as OUTPUT (1 in GDIR)
GPIO7_GDIR |= ADDR_MASK;

// Optional: Set MUX to GPIO mode for these pads if they default to a peripheral
// (Ensure your chosen pins are configured as ALT5 / GPIO in IOMUXC)


}

// Function to parallel write a 20-bit address
inline void writeAddress20(uint32_t address) {
// Clear the 20 address bits first, then apply the new 20-bit value
uint32_t currentVal = GPIO7_DR & ~ADDR_MASK;
GPIO7_DR = currentVal | (address & ADDR_MASK);
}

// Function to parallel read 8 data bits from EEPROM
inline uint8_t readData8() {
// Use GPIO6_PSR (Pin Status Register) for accurate physical pin reading
return (uint8_t)(GPIO6_PSR & DATA_MASK);
}

void loop() {
// uint32_t testAddress = 0x01234; // Example 20-bit address (0 to 0xFFFFF)
// 1. Write the 20-bit address in parallel

//051CB -> 01
writeAddress20(0xFFFFF);
writeAddress20(0xFFFFF);
writeAddress20(0xFFFFF);
writeAddress20(0xFFFFF);
writeAddress20(0xFFFFF); // CS goes low
writeAddress20(0xFFFFF); // OE goes low
writeAddress20(0xFFFFF);
// eepromDataCB = readData8();
writeAddress20(0x00000); //visual for scope
writeAddress20(0xFFFFF);
writeAddress20(0x00000);

delayMicroseconds(1);

}
DO YOU REMEMBER!
When you post code, post it between CODE TAGS using the </> button.
It formats the code correctly and makes it easier to read and understand.
 
I need a minimum of 16 lines, this works but only with 11 pins active:

How many times do we need to explain not all GPIO6 and GPIO7 pins are connected as this code assumes.

If you want it to actually work, you need to craft the code to make use of the actual pins you've connected. But you're unwilling to tell or show us which pins you actually used, so nobody can give more specific advice. This is all I can do to help, because you haven't given specific info.
 
How many times do we need to explain not all GPIO6 and GPIO7 pins are connected as this code assumes.

If you want it to actually work, you need to craft the code to make use of the actual pins you've connected. But you're unwilling to tell or show us which pins you actually used, so nobody can give more specific advice. This is all I can do to help, because you haven't given specific info.
I am hand wiring each pin as needed an EEPROM socket so dont wory about pin assighnemt.

give me a sketch and i will do a bit shift across the 20 pins and hand wire it. make an output port work at a 20ns write. 20 undefined output pins and 8 input pins.
whatever is easy for to code. cant have microseconds delay between each write. at the end of a cycle i will put a delayMicroseconds
if this works: 0xFFFFF,0x00000. bitmapped will also work so no conversion is needed.
then all I have to do is map it with this:
0x00000
0x00001
0x00002
0x00004
0x00008
.
.
.
.
.0x80000
 
C:
GPIO6_GDIR = \
GPIO7_GDIR = \
GPIO8_GDIR = \
GPIO9_GDIR = 0xFFFFFFFF;

while (1) {
  GPIO6_DR_TOGGLE |= 0xFFFFFFFF;
  GPIO7_DR_TOGGLE |= 0xFFFFFFFF;
  GPIO8_DR_TOGGLE |= 0xFFFFFFFF;
  GPIO9_DR_TOGGLE |= 0xFFFFFFFF;
  delayMicroseconds(20);
}

There you go. Flips every single pin (while being completely useless for trying to output specific values, because you won't give any information about which pins you intend to use).
 
Apart from the sheer entertainment value of
groping around
in a coal cellar
with no lights
and a blindfold on
looking for a black cat
being directed by someone else
who doesn’t know what a cat looks like
when the cat has long since escaped…

this may be an occasion when a Teensy isn’t actually the best tool (see also post#18). A Pi Pico with a clever enough PIO+DMA setup might work quite nicely as a programmable sub-microsecond probe tool.

Just keeping the pot stirred … it’s a great thread for the spectators 🍿🍻
 
I'm just wondering why the EPROM can't simply be replaced with a working one, and why it's impossible to toggle individual pins. But it doesn't really matter anyway. It's also a good thing that our “light show” (patterns + state machine in eprom) hardware 30 years ago had no idea about the alleged timing problem and worked entirely without a microcontroller.
 
Last edited:
I suspect it’s the only existing copy of some code, and the datasheet’s quoted >200-year data retention time has proven to be …. optimistic. If you build your own reader you can mess with timings and drive levels until you get the right data out (not sure how you’d know - maybe the fact it has a CRC is a military secret and if they told us, they’d have to kill us).

In which case, of course, most of the above posts are pretty much futile, and OP, the AI, Principal Engineer, new hire engineer and Master Engineering Technician (see post#20) should probably all get fired. Or promoted to where they can do no further damage.
 
If you build your own reader you can mess with timings and drive levels until you get the right data out (not sure how you’d know - maybe the fact it has a CRC is a military secret and if they told us, they’d have to kill us).
The thing is, parallel EEPROMs don't have a max "read cycle" time - OP keeps insisting they need sub-microsecond timing, but as long as the ROM is enabled (CE and OE low) it will just continuously output data for whatever location the address pins are set to.
 
Quite so. I still own a couple of EPROM / GAL programmers, though sadly no UV eraser (not that I'd have a use for it, really). First experience was (probably) trying to make a programmer so I could blow extension ROMs for my Acorn Atom; around here that likely makes me a bit of a n00b.

So yes, ideally a working EPROM will output the correct data for the address given, ad infinitum, as long as /CE and /OE are asserted. A non-working one? Who knows. But timing is pretty unlikely to enter into the equation, as you say. And I suspect we'll never get to the bottom of what OP actually wants to achieve - they either aren't allowed to say, or don't know...
 
I tell a lie - three programmers. I'd forgotten about the QL-specific GAL programmer, which allowed me to program the 16V8 for the Minerva mkII, implementing a bit-banged I²C interface by reading from the top few addresses of the OS memory. Happy days.
 
I tell a lie - three programmers. I'd forgotten about the QL-specific GAL programmer, which allowed me to program the 16V8 for the Minerva mkII, implementing a bit-banged I²C interface by reading from the top few addresses of the OS memory. Happy days.
No programmer here but I've used the T4.1 to program EPROMs, GALs, and even a few PIC12F629s (using the quad timers to generate 10/12V with capacitors when necessary). The PSRAM is really handy for reordering the image when the ROM's address lines don't quite match the board it's going into...
We get enough sunlight here that an EPROM can be erased in a couple of days. Probably not the best for longevity but I try not to make a habit of it.
 
Since you're unwilling to even tell us the EPROM part number (maybe 27C1024), I'd imagine you *really* don't want to tell us what you're trying to actually accomplish?

But if the goal is simply to read all the data from an old chip, which is my guess from such a simple AI-gen program that reads but doesn't *do* anything, you could just use 18 digitalWriteFast() to set all the address pins, and use 8 digitalReadFast() to read all 8 data pins, and of course use digitalWriteFast() for the chip select and read enable pins.

If the part is old enough to use 5 volt power and signals, you MUST use level shifters. If you're just building a proof of concept, probably simplest to just buy a few of these.



Without understanding what you're really trying to do, and not even knowing the details of the hardware, this is as much advice as I can give. I hope you can understand all of here are real people, not AI large language models. The level of help we can offer is really limited if you keep us in the dark like this. It's how we humans are... when we understand and know details, human experience really is a huge benefit. Without understanding, with only vague info, best anyone can do is pretty generic advice.
Well, since the latest messages from the OP indicate that he can't tell us about the hardware, I'm going to use my imagination and assume that he's been handed a damaged PC board from an Iranian ballistic missile that got intercepted over Jordan. Somebody at the DIA would like to examine the contents of the EPROM which they assume to be the firmware for the guidance system. All we know is that it needs 18 address bits, Chip Enable and Output Enable, and 8 data bits.

Given that the device is probably static, I decided to follow Paul's suggestion and see what it would take to read out the data from the chip. I'm a bit short on hardware for testing---the last time I was near the impact area of a ballistic missile was about 600 miles from Midway Island in 1974. The re-entry vehicle from the missile self-destructed and sank. All we recovered was a few fragments of floating styrofoam. Lacking an EPROM, I just tested the data recovery algorithm by connecting the lowest 8 address bits to the data input bits with jumper wires.

Here's a picture of the hardware:

IMG_6249.jpg

The Jumper wires under the SD card connect 8 address bits to 8 data inputs. The jumper wires coming out the top of the T4.1 are ground connections at the USB Host connector.

and here's a better shot of the scope display:
SDS814X_4.jpg


IN the scope display: Yellow=Chip Enable, Blue=Output Enable, Green=Address Bit 0 connected to Data Input bit 0.


Here's the source code:
Code:
// Simple test to simulate reading eprom on Teensy 4.1
// M. Borgerson   10/30/26
#define LEDPin 13
#define LEDOFF digitalWriteFast(LEDPin, 0);
#define LEDON digitalWriteFast(LEDPin, 1);

#define CEPin 2
#define CELOW digitalWriteFast(CEPin, 0);
#define CEHI digitalWriteFast(CEPin, 1);

#define OEPin 1
#define OELOW digitalWriteFast(OEPin, 0);
#define OEHI digitalWriteFast(OEPin, 1);

// Sets up output address pin definitions for A0-A17
// Address bits 0..8 are on output pins 32..24
// Address bits 9..18 are on output pins 12..4
const uint8_t ADPins[] = { 32, 31, 30, 29, 28, 27, 26, 25, 24, 12, 11, 10, 9, 8, 7, 6, 5, 4 };

// Input data bits 0..7 are on input pins 33..40
const uint8_t INPins[] = { 33, 34, 35, 36, 37, 38, 39, 40 };

const char compileTime[] = " Compiled on " __DATE__ " " __TIME__;

uint8_t dbuffer[256 * 1024]; // big enough for whole EEPROM

void setup() {
  Serial.begin(9600);
  delay(1000);
  Serial.printf("\n\nSimulated 27C256 readout.  %s\n", compileTime);
 // Set the address bit pins to output
  SetOutputs();

  // digital pins default to inputs on startup
}

void loop() {
  char ch;
  if (Serial.available()) {
    ch = Serial.read();
    if (ch == 's') {
      SetOutputs();
    }
    if (ch == 'r') {
      ReadBytes(&dbuffer[0], 256*1024, 0);  // Read 256KB bytes starting at address 0
      ShowBytes(&dbuffer[0], 280);  // Display just a bit of the buffer
    }
  }
}

void SetOutputs(void) {
  uint8_t i;
  Serial.printf("Setting up Address Pins\n");
  // Set all bits from 0 to 17 as outputs
  pinMode(LEDPin, OUTPUT);
  LEDON
  delay(200);
  for (i = 0; i < 18; i++) {
    pinMode(ADPins[i], OUTPUT);
  }
  LEDOFF
  pinMode(OEPin, OUTPUT);
  OEHI
    pinMode(CEPin, OUTPUT);
  CEHI
}

elapsedMicros etm;
void ReadBytes(uint8_t *buffptr, uint32_t numbytes, uint32_t addrstart) {
  uint32_t bnum;
  uint32_t addr = addrstart;
  LEDON
  etm = 0;
  for (bnum = 0; bnum < numbytes; bnum++) {
    SetAddress(addr++);
    CELOW   // CE Set low after address valid
    delayNanoseconds(10);
    *buffptr++ = ReadByte(); // (OE pulsed low during ReadByte())
    CEHI
  }
  float tval = etm;
  tval = tval/1000000.0; // tval now in seconds
  Serial.printf("\nRead %6d bytes in %6.3fSeconds  ", numbytes, tval);
  Serial.printf("%6.3fMB/Sec.\n",(numbytes/tval)/1e6);
  LEDOFF
}

// Show some buffer contents to verify good reads
void ShowBytes(uint8_t *bufptr, uint32_t numbytes) {
  uint32_t i;
  uint8_t bt;
  for (i = 0; i < numbytes; i++) {
    bt = *bufptr++;
    Serial.printf(" %02X", bt);
    if ((i & 15) == 15) Serial.println();
  }
  Serial.println("\nDone");
}

// Set all 18 address bits as needed
void SetAddress(uint32_t addr) {
 // CELOW  // Set Chip Enable Low
  uint8_t adbit;

  for (adbit = 0; adbit<18; adbit++) {
    digitalWriteFast(LEDPin,(addr >> adbit) & 1 );
    digitalWriteFast(ADPins[adbit],  (addr >> adbit) & 1);
    //LEDOFF
  }
 // CEHI  // set CE high
}


// Read 8 bits and return assembled byte
uint8_t ReadByte() {
  uint8_t rdbyte = 0;
  uint8_t bval = 1;

  OELOW  // Set OE pin low
  for (uint8_t dbit = 0; dbit < 8; dbit++) {
    bval = digitalRead(INPins[dbit]);
    bval = bval << dbit;
    rdbyte |= bval;
  }
  OEHI  // Set OE pin high
  return rdbyte;
}

/*************************************************************************
Output from 'r' command:
Read 262144 bytes in  0.254Seconds   1.032MB/Sec.
 00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F
 10 11 12 13 14 15 16 17 18 19 1A 1B 1C 1D 1E 1F
 20 21 22 23 24 25 26 27 28 29 2A 2B 2C 2D 2E 2F
 30 31 32 33 34 35 36 37 38 39 3A 3B 3C 3D 3E 3F
 40 41 42 43 44 45 46 47 48 49 4A 4B 4C 4D 4E 4F
 50 51 52 53 54 55 56 57 58 59 5A 5B 5C 5D 5E 5F
 60 61 62 63 64 65 66 67 68 69 6A 6B 6C 6D 6E 6F
 70 71 72 73 74 75 76 77 78 79 7A 7B 7C 7D 7E 7F
 80 81 82 83 84 85 86 87 88 89 8A 8B 8C 8D 8E 8F
 90 91 92 93 94 95 96 97 98 99 9A 9B 9C 9D 9E 9F
 A0 A1 A2 A3 A4 A5 A6 A7 A8 A9 AA AB AC AD AE AF
 B0 B1 B2 B3 B4 B5 B6 B7 B8 B9 BA BB BC BD BE BF
 C0 C1 C2 C3 C4 C5 C6 C7 C8 C9 CA CB CC CD CE CF
 D0 D1 D2 D3 D4 D5 D6 D7 D8 D9 DA DB DC DD DE DF
 E0 E1 E2 E3 E4 E5 E6 E7 E8 E9 EA EB EC ED EE EF
 F0 F1 F2 F3 F4 F5 F6 F7 F8 F9 FA FB FC FD FE FF
 00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F
 10 11 12 13 14 15 16 17
Done
************************************************/



NOTE: This code example was written by an 80-year-old retired computer nerd who was tired of MatLab programming and wanted to work a little closer to the metal after a thousand hours of Matlab coding for a simulation of a 1970's era satellite ELINT collection system. It took about five hours to write and test. It would have gone faster if I didn't have to spend so much time thumbing through my 1988 copy of Kernigan and Ritchie to figure out all the minor syntax differences between C and MatLab.

And, Yes, I really was on a small ship in the North Pacific collecting telemetry from Soviet missile tests in 1974!

Now if I could only figure out why I have to press the button on the T4.1 to get the code to upload. I suspect it's something in the latest Win11 security updates.
 
Just to confirm what others have said, these old 27Cxx EPROM chips do not require tight timing. They also work fine for reading only if the just wire CS and OE always low and keep the WR pin high. You can change the address pins and the data pins change accordingly after only a short delay. I know this from experience because I built a motor control project in 1990 with a 74HC4060 counter chip (it might have been "LS" rather than "HC") which clocked from its own R-C oscillator and drove the address pins. It had a knob on a pot to control the oscillator speed. I programmed the motor movement pattern into the EPROM. The 8 data pins drove simple logic chips which drove transistors which powered the coils of stepper motors salvaged from 8 inch floppy disk drives (which were abundant at electronics surplus shops in the late 1980s and early 1990s). It was pretty primitive looking and those stepper made loud clucky sound, but it worked well. I used that machine to make PCBs (as this was the time before OSH Park and later PCBway and JLC). Robin called it "the acid swishing machine", the long step where you have to keep moving the pan while the circuit board etches. That EPROM-based design was the last home made PCB which I etched by hand moving the pan!

The timing diagrams in 27Cxx datasheets are meant to show using these chips on the buses common in 1970-1980s era computers. But all those specs in nanoseconds are miniums for what you must do and maximums for what the chip does, like that short delay from the address pins changing to the data pins setting to the correct byte for that address. You can drive the chip as slowly as you like. You only need to have something in your code like delayNanoseconds(150) after you've driven all the address and control pins, so you wait long enough for the chip to update its 8 output pins to have the correct data for whatever address you wanted.
 
@philipPJ
I think you are an AI bot and you do not understand a single word of what all the helpful people are posting here.
Please try to convince us humans that you are human and are willing to accept help.
some Engineering Techs read the paper when between projects, I build things like this Single Can Thermoelectric Soda Cooler. 500 Watts 5 minutes to +5C.Had to learn how to do a PID loop in Arduino to keep it from blowing up the soda can

1793880173856.jpeg
1793880185490.jpeg
 
Well, since the latest messages from the OP indicate that he can't tell us about the hardware, I'm going to use my imagination and assume that he's been handed a damaged PC board from an Iranian ballistic missile that got intercepted over Jordan. Somebody at the DIA would like to examine the contents of the EPROM which they assume to be the firmware for the guidance system. All we know is that it needs 18 address bits, Chip Enable and Output Enable, and 8 data bits.

Given that the device is probably static, I decided to follow Paul's suggestion and see what it would take to read out the data from the chip. I'm a bit short on hardware for testing---the last time I was near the impact area of a ballistic missile was about 600 miles from Midway Island in 1974. The re-entry vehicle from the missile self-destructed and sank. All we recovered was a few fragments of floating styrofoam. Lacking an EPROM, I just tested the data recovery algorithm by connecting the lowest 8 address bits to the data input bits with jumper wires.

Here's a picture of the hardware:

View attachment 40004
The Jumper wires under the SD card connect 8 address bits to 8 data inputs. The jumper wires coming out the top of the T4.1 are ground connections at the USB Host connector.

and here's a better shot of the scope display:
View attachment 40006

IN the scope display: Yellow=Chip Enable, Blue=Output Enable, Green=Address Bit 0 connected to Data Input bit 0.


Here's the source code:
Code:
// Simple test to simulate reading eprom on Teensy 4.1
// M. Borgerson   10/30/26
#define LEDPin 13
#define LEDOFF digitalWriteFast(LEDPin, 0);
#define LEDON digitalWriteFast(LEDPin, 1);

#define CEPin 2
#define CELOW digitalWriteFast(CEPin, 0);
#define CEHI digitalWriteFast(CEPin, 1);

#define OEPin 1
#define OELOW digitalWriteFast(OEPin, 0);
#define OEHI digitalWriteFast(OEPin, 1);

// Sets up output address pin definitions for A0-A17
// Address bits 0..8 are on output pins 32..24
// Address bits 9..18 are on output pins 12..4
const uint8_t ADPins[] = { 32, 31, 30, 29, 28, 27, 26, 25, 24, 12, 11, 10, 9, 8, 7, 6, 5, 4 };

// Input data bits 0..7 are on input pins 33..40
const uint8_t INPins[] = { 33, 34, 35, 36, 37, 38, 39, 40 };

const char compileTime[] = " Compiled on " __DATE__ " " __TIME__;

uint8_t dbuffer[256 * 1024]; // big enough for whole EEPROM

void setup() {
  Serial.begin(9600);
  delay(1000);
  Serial.printf("\n\nSimulated 27C256 readout.  %s\n", compileTime);
 // Set the address bit pins to output
  SetOutputs();

  // digital pins default to inputs on startup
}

void loop() {
  char ch;
  if (Serial.available()) {
    ch = Serial.read();
    if (ch == 's') {
      SetOutputs();
    }
    if (ch == 'r') {
      ReadBytes(&dbuffer[0], 256*1024, 0);  // Read 256KB bytes starting at address 0
      ShowBytes(&dbuffer[0], 280);  // Display just a bit of the buffer
    }
  }
}

void SetOutputs(void) {
  uint8_t i;
  Serial.printf("Setting up Address Pins\n");
  // Set all bits from 0 to 17 as outputs
  pinMode(LEDPin, OUTPUT);
  LEDON
  delay(200);
  for (i = 0; i < 18; i++) {
    pinMode(ADPins[i], OUTPUT);
  }
  LEDOFF
  pinMode(OEPin, OUTPUT);
  OEHI
    pinMode(CEPin, OUTPUT);
  CEHI
}

elapsedMicros etm;
void ReadBytes(uint8_t *buffptr, uint32_t numbytes, uint32_t addrstart) {
  uint32_t bnum;
  uint32_t addr = addrstart;
  LEDON
  etm = 0;
  for (bnum = 0; bnum < numbytes; bnum++) {
    SetAddress(addr++);
    CELOW   // CE Set low after address valid
    delayNanoseconds(10);
    *buffptr++ = ReadByte(); // (OE pulsed low during ReadByte())
    CEHI
  }
  float tval = etm;
  tval = tval/1000000.0; // tval now in seconds
  Serial.printf("\nRead %6d bytes in %6.3fSeconds  ", numbytes, tval);
  Serial.printf("%6.3fMB/Sec.\n",(numbytes/tval)/1e6);
  LEDOFF
}

// Show some buffer contents to verify good reads
void ShowBytes(uint8_t *bufptr, uint32_t numbytes) {
  uint32_t i;
  uint8_t bt;
  for (i = 0; i < numbytes; i++) {
    bt = *bufptr++;
    Serial.printf(" %02X", bt);
    if ((i & 15) == 15) Serial.println();
  }
  Serial.println("\nDone");
}

// Set all 18 address bits as needed
void SetAddress(uint32_t addr) {
 // CELOW  // Set Chip Enable Low
  uint8_t adbit;

  for (adbit = 0; adbit<18; adbit++) {
    digitalWriteFast(LEDPin,(addr >> adbit) & 1 );
    digitalWriteFast(ADPins[adbit],  (addr >> adbit) & 1);
    //LEDOFF
  }
 // CEHI  // set CE high
}


// Read 8 bits and return assembled byte
uint8_t ReadByte() {
  uint8_t rdbyte = 0;
  uint8_t bval = 1;

  OELOW  // Set OE pin low
  for (uint8_t dbit = 0; dbit < 8; dbit++) {
    bval = digitalRead(INPins[dbit]);
    bval = bval << dbit;
    rdbyte |= bval;
  }
  OEHI  // Set OE pin high
  return rdbyte;
}

/*************************************************************************
Output from 'r' command:
Read 262144 bytes in  0.254Seconds   1.032MB/Sec.
 00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F
 10 11 12 13 14 15 16 17 18 19 1A 1B 1C 1D 1E 1F
 20 21 22 23 24 25 26 27 28 29 2A 2B 2C 2D 2E 2F
 30 31 32 33 34 35 36 37 38 39 3A 3B 3C 3D 3E 3F
 40 41 42 43 44 45 46 47 48 49 4A 4B 4C 4D 4E 4F
 50 51 52 53 54 55 56 57 58 59 5A 5B 5C 5D 5E 5F
 60 61 62 63 64 65 66 67 68 69 6A 6B 6C 6D 6E 6F
 70 71 72 73 74 75 76 77 78 79 7A 7B 7C 7D 7E 7F
 80 81 82 83 84 85 86 87 88 89 8A 8B 8C 8D 8E 8F
 90 91 92 93 94 95 96 97 98 99 9A 9B 9C 9D 9E 9F
 A0 A1 A2 A3 A4 A5 A6 A7 A8 A9 AA AB AC AD AE AF
 B0 B1 B2 B3 B4 B5 B6 B7 B8 B9 BA BB BC BD BE BF
 C0 C1 C2 C3 C4 C5 C6 C7 C8 C9 CA CB CC CD CE CF
 D0 D1 D2 D3 D4 D5 D6 D7 D8 D9 DA DB DC DD DE DF
 E0 E1 E2 E3 E4 E5 E6 E7 E8 E9 EA EB EC ED EE EF
 F0 F1 F2 F3 F4 F5 F6 F7 F8 F9 FA FB FC FD FE FF
 00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F
 10 11 12 13 14 15 16 17
Done
************************************************/



NOTE: This code example was written by an 80-year-old retired computer nerd who was tired of MatLab programming and wanted to work a little closer to the metal after a thousand hours of Matlab coding for a simulation of a 1970's era satellite ELINT collection system. It took about five hours to write and test. It would have gone faster if I didn't have to spend so much time thumbing through my 1988 copy of Kernigan and Ritchie to figure out all the minor syntax differences between C and MatLab.

And, Yes, I really was on a small ship in the North Pacific collecting telemetry from Soviet missile tests in 1974!

Now if I could only figure out why I have to press the button on the T4.1 to get the code to upload. I suspect it's something in the latest Win11 security updates.
so the solution to a 10ns High, Low High, low was Getting Claude.AI. A manager said I can say more on the problem. An ADF ( Automatic Radio Direction Finder) designed the the 1980 had field failures about 6 months from delivery. The EEPROM is the system Processor Memory. I have used Claude AI output the Address and then to 200ns of fast reads into indexed ram location, now i can get a histagram on time it takes for the Data to go valid. we know four location are intermittent, I can increase the reads to go out longer if needed.




Code:
// Runs from RAM (FASTRUN) so the inlined writes are not slowed by flash.
FASTRUN void loop() {
  noInterrupts();  // keep the burst back to back
  writeAddress(address1);// 0xFFFFF;// valid address
  writeAddress(address1);// 0xFFFFF;// valid address
  writeAddress(address2);// 0x7FFFF;// drop CE
  writeAddress(address3);// 0x3FFFF;// drop OE
  const uint32_t start = ARM_DWT_CYCCNT;
  readData20();               // 20 back-to-back reads of the data bus
  burstCycles = ARM_DWT_CYCCNT - start;
   writeAddress(address4);// 0x00000;
   writeAddress(address1);// 0xFFFFF;   // ue this for read data time evaluation
   writeAddress(address4);// 0x00000;
   //test the 8 bits here and increment a fail count if falce
  interrupts();
  //test the 8 bits here and increment a fail count if falce

I have to put the EEPROM into a temperature chamber so I am having a mod operator Dead bug a teency and wire it up.
I can get back to work no that the 20' of rain that shut us down monday had receded
1793881298413.jpeg
bit flipper.PNG
 
I'm just wondering why the EPROM can't simply be replaced with a working one, and why it's impossible to toggle individual pins. But it doesn't really matter anyway. It's also a good thing that our “light show” (patterns + state machine in eprom) hardware 30 years ago had no idea about the alleged timing problem and worked entirely without a microcontroller.
we had a new Tech in Engineering replace a defective part that came from a field failure. the Engineer totally went off on the poor guy and said very loudly: "You disturbed the integrity of the problem!" I about fell out of my chair laughing! I had to figure out a way to keep him from quitting. the Tech was red in the face and his veins were popping out.
 
Well, since the latest messages from the OP indicate that he can't tell us about the hardware, I'm going to use my imagination and assume that he's been handed a damaged PC board from an Iranian ballistic missile that got intercepted over Jordan. Somebody at the DIA would like to examine the contents of the EPROM which they assume to be the firmware for the guidance system. All we know is that it needs 18 address bits, Chip Enable and Output Enable, and 8 data bits.

Given that the device is probably static, I decided to follow Paul's suggestion and see what it would take to read out the data from the chip. I'm a bit short on hardware for testing---the last time I was near the impact area of a ballistic missile was about 600 miles from Midway Island in 1974. The re-entry vehicle from the missile self-destructed and sank. All we recovered was a few fragments of floating styrofoam. Lacking an EPROM, I just tested the data recovery algorithm by connecting the lowest 8 address bits to the data input bits with jumper wires.

Here's a picture of the hardware:

View attachment 40004
The Jumper wires under the SD card connect 8 address bits to 8 data inputs. The jumper wires coming out the top of the T4.1 are ground connections at the USB Host connector.

and here's a better shot of the scope display:
View attachment 40006

IN the scope display: Yellow=Chip Enable, Blue=Output Enable, Green=Address Bit 0 connected to Data Input bit 0.


Here's the source code:
Code:
// Simple test to simulate reading eprom on Teensy 4.1
// M. Borgerson   10/30/26
#define LEDPin 13
#define LEDOFF digitalWriteFast(LEDPin, 0);
#define LEDON digitalWriteFast(LEDPin, 1);

#define CEPin 2
#define CELOW digitalWriteFast(CEPin, 0);
#define CEHI digitalWriteFast(CEPin, 1);

#define OEPin 1
#define OELOW digitalWriteFast(OEPin, 0);
#define OEHI digitalWriteFast(OEPin, 1);

// Sets up output address pin definitions for A0-A17
// Address bits 0..8 are on output pins 32..24
// Address bits 9..18 are on output pins 12..4
const uint8_t ADPins[] = { 32, 31, 30, 29, 28, 27, 26, 25, 24, 12, 11, 10, 9, 8, 7, 6, 5, 4 };

// Input data bits 0..7 are on input pins 33..40
const uint8_t INPins[] = { 33, 34, 35, 36, 37, 38, 39, 40 };

const char compileTime[] = " Compiled on " __DATE__ " " __TIME__;

uint8_t dbuffer[256 * 1024]; // big enough for whole EEPROM

void setup() {
  Serial.begin(9600);
  delay(1000);
  Serial.printf("\n\nSimulated 27C256 readout.  %s\n", compileTime);
 // Set the address bit pins to output
  SetOutputs();

  // digital pins default to inputs on startup
}

void loop() {
  char ch;
  if (Serial.available()) {
    ch = Serial.read();
    if (ch == 's') {
      SetOutputs();
    }
    if (ch == 'r') {
      ReadBytes(&dbuffer[0], 256*1024, 0);  // Read 256KB bytes starting at address 0
      ShowBytes(&dbuffer[0], 280);  // Display just a bit of the buffer
    }
  }
}

void SetOutputs(void) {
  uint8_t i;
  Serial.printf("Setting up Address Pins\n");
  // Set all bits from 0 to 17 as outputs
  pinMode(LEDPin, OUTPUT);
  LEDON
  delay(200);
  for (i = 0; i < 18; i++) {
    pinMode(ADPins[i], OUTPUT);
  }
  LEDOFF
  pinMode(OEPin, OUTPUT);
  OEHI
    pinMode(CEPin, OUTPUT);
  CEHI
}

elapsedMicros etm;
void ReadBytes(uint8_t *buffptr, uint32_t numbytes, uint32_t addrstart) {
  uint32_t bnum;
  uint32_t addr = addrstart;
  LEDON
  etm = 0;
  for (bnum = 0; bnum < numbytes; bnum++) {
    SetAddress(addr++);
    CELOW   // CE Set low after address valid
    delayNanoseconds(10);
    *buffptr++ = ReadByte(); // (OE pulsed low during ReadByte())
    CEHI
  }
  float tval = etm;
  tval = tval/1000000.0; // tval now in seconds
  Serial.printf("\nRead %6d bytes in %6.3fSeconds  ", numbytes, tval);
  Serial.printf("%6.3fMB/Sec.\n",(numbytes/tval)/1e6);
  LEDOFF
}

// Show some buffer contents to verify good reads
void ShowBytes(uint8_t *bufptr, uint32_t numbytes) {
  uint32_t i;
  uint8_t bt;
  for (i = 0; i < numbytes; i++) {
    bt = *bufptr++;
    Serial.printf(" %02X", bt);
    if ((i & 15) == 15) Serial.println();
  }
  Serial.println("\nDone");
}

// Set all 18 address bits as needed
void SetAddress(uint32_t addr) {
 // CELOW  // Set Chip Enable Low
  uint8_t adbit;

  for (adbit = 0; adbit<18; adbit++) {
    digitalWriteFast(LEDPin,(addr >> adbit) & 1 );
    digitalWriteFast(ADPins[adbit],  (addr >> adbit) & 1);
    //LEDOFF
  }
 // CEHI  // set CE high
}


// Read 8 bits and return assembled byte
uint8_t ReadByte() {
  uint8_t rdbyte = 0;
  uint8_t bval = 1;

  OELOW  // Set OE pin low
  for (uint8_t dbit = 0; dbit < 8; dbit++) {
    bval = digitalRead(INPins[dbit]);
    bval = bval << dbit;
    rdbyte |= bval;
  }
  OEHI  // Set OE pin high
  return rdbyte;
}

/*************************************************************************
Output from 'r' command:
Read 262144 bytes in  0.254Seconds   1.032MB/Sec.
 00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F
 10 11 12 13 14 15 16 17 18 19 1A 1B 1C 1D 1E 1F
 20 21 22 23 24 25 26 27 28 29 2A 2B 2C 2D 2E 2F
 30 31 32 33 34 35 36 37 38 39 3A 3B 3C 3D 3E 3F
 40 41 42 43 44 45 46 47 48 49 4A 4B 4C 4D 4E 4F
 50 51 52 53 54 55 56 57 58 59 5A 5B 5C 5D 5E 5F
 60 61 62 63 64 65 66 67 68 69 6A 6B 6C 6D 6E 6F
 70 71 72 73 74 75 76 77 78 79 7A 7B 7C 7D 7E 7F
 80 81 82 83 84 85 86 87 88 89 8A 8B 8C 8D 8E 8F
 90 91 92 93 94 95 96 97 98 99 9A 9B 9C 9D 9E 9F
 A0 A1 A2 A3 A4 A5 A6 A7 A8 A9 AA AB AC AD AE AF
 B0 B1 B2 B3 B4 B5 B6 B7 B8 B9 BA BB BC BD BE BF
 C0 C1 C2 C3 C4 C5 C6 C7 C8 C9 CA CB CC CD CE CF
 D0 D1 D2 D3 D4 D5 D6 D7 D8 D9 DA DB DC DD DE DF
 E0 E1 E2 E3 E4 E5 E6 E7 E8 E9 EA EB EC ED EE EF
 F0 F1 F2 F3 F4 F5 F6 F7 F8 F9 FA FB FC FD FE FF
 00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F
 10 11 12 13 14 15 16 17
Done
************************************************/



NOTE: This code example was written by an 80-year-old retired computer nerd who was tired of MatLab programming and wanted to work a little closer to the metal after a thousand hours of Matlab coding for a simulation of a 1970's era satellite ELINT collection system. It took about five hours to write and test. It would have gone faster if I didn't have to spend so much time thumbing through my 1988 copy of Kernigan and Ritchie to figure out all the minor syntax differences between C and MatLab.

And, Yes, I really was on a small ship in the North Pacific collecting telemetry from Soviet missile tests in 1974!

Now if I could only figure out why I have to press the button on the T4.1 to get the code to upload. I suspect it's something in the latest Win11 security updates.
I get to have more fun than allot of Engineers. A Radio Altimeter mixes the TX Frequency with the Return signal from the ground. the IF output is an audio band signal, DC on the ground and 100KHz and High altitude. I used a TC3.2 to detect when it was sampling the IF to gate a digitizer to then get sufficient samples to display a good FFT. The SW Engineer was trying for 6 months to get the IF measurements.
 
It's pretty silly that OP keeps claiming they can't share details of the situation, yet apparently has no problems sharing them with multiple AI agents.
 
It's pretty silly that OP keeps claiming they can't share details of the situation, yet apparently has no problems sharing them with multiple AI agents.
Probably has no clue what the ITAR really requires. It would be handy if he had cited the relevant section. I only worry about some things.
 
Back
Top