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

philipPJ

Member
// the timing is OK just can't get all the bits to work some of this was from AI
#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(0x7FFFF); // CS goes low
writeAddress20(0x3FFFF); // OE goes low
writeAddress20(0x3FFFF);
// eepromDataCB = readData8();
writeAddress20(0x00000); //visual for scope
writeAddress20(0xFFFFF);
writeAddress20(0x00000);

delayMicroseconds(1);
}
 
C++:
// the timing is OK just can't get all the bits to work some of this was from AI
#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(0x7FFFF); // CS goes low
    writeAddress20(0x3FFFF); // OE goes low
    writeAddress20(0x3FFFF);
    // eepromDataCB = readData8();
    writeAddress20(0x00000); //visual for scope
    writeAddress20(0xFFFFF);
    writeAddress20(0x00000);

    delayMicroseconds(1);
}
Welcome to the Forum. 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.
See how it presents your code above...
 
No information given regarding how the EEPROM is connected.
It's very difficult to find runs of pins that are all connected sequentially to a single port; afaik there is only one large run of 16 pins on the Teensy 4.1 like this, so there's no way to make this code sample work.
 
Last edited:
This AI generated code has a built in assumption of wiring 20 address pins to GPIO6 bits 0 to 19, and 8 data pins to GPIO7 bits 0 to 7. At least it was nice enough to say so in the comments.

Code:
// Mask for 8 data bits (e.g., bits 0 to 7 of GPIO6)

// Mask for 20 address bits (e.g., bits 0 to 19 of GPIO7)

But those 28 signals are not all available on Teensy 4.1, so this can't work. You would need to build a completely custom PCB to have access to the signals this code imagines using.

This seems to be a regular problem with AI advice... the LLMs seem to know about info NXP publishes but they're much less able to know the practical reality of using the Teensy hardware.
 
so if I don't care about random pin assignments, I need to read 8 bits input (parallel) how many can I output parallel)
 
No information given regarding how the EEPROM is connected.
It's very difficult to find runs of pins that are all connected sequentially to a single port; afaik there is only one large run of 16 pins on the Teensy 4.1 like this, so there's no way to make this code sample work.
i don't need sequenced, I am hand wiring a jpin connector, random outputs inputs are OK
 
Which eprom is it? 5V? maybe, you don't need Teensy pins for cs and oe (fixed to 1 and 0) -> ( 8+18 pins only)
 
? D0-7 + A0-A17 and still some free.... do I miss something?
1793211323630.png


mapping these to registers/bits ist just some software.. probably a constexpr table..

re: 20ns if that is the number from the datasheet: it's minimum 20ns and can be *much* slower. even single digitial writes would work.
 
Last edited:
? D0-7 + A0-A17 and still some free.... do I miss something?
View attachment 39992

mapping these to registers/bits ist just some software.. probably a constexpr table..

re: 20ns if that is the number from the datasheet: it's minimum 20ns and can be *much* slower. even single digitial writes would work.
I do not care about what the mapping is. I need to output 0xFFFFF and input 0xXX. I have a 40ns square wave output but only (12pins? i forget) do you have any code for the output? I have spent over a week and the engineer have given up on this effort, I am doing this on the side now.
 
First, tell us: Which EPROM (which chip)? Why 20 ns? (<- That's pretty ambitious, and I don't know if it's feasible—you say you just want to test it, so there's no reason for that (?!) )
 
in gen
First, tell us: Which EPROM (which chip)? Why 20 ns? (<- That's pretty ambitious, and I don't know if it's feasible—you say you just want to test it, so there's no reason for that (?!) )
its work related so i can't say without permission. its 18 address lines and a chip enable and output enable and 8 bits in. the top 4 address lines can be 0000 for now, I will need all working to prove it's possible for Engineering testing. right now I 12 going high and then low at a 20ns duration.
 
i don't need sequenced, I am hand wiring a jpin connector, random outputs inputs are OK
It doesn't matter how the ROM is being connected, the physical pins on the Teensy are not consecutive in GPIO6 and GPIO7 like your code expects them to be. They're scattered all over GPIO6/7/8/9 and you're not going to be able to read 8 data bits or write 20 address bits in a single operation, instead each bit will effectively have to be accessed individually.

It would be far easier to do this with shift registers, which would also make it easier to handle voltage conversion...
 
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.
 
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.
its an unreliable 27C265
address -> data should be :
051CB -> 01
051CC -> 8E
051CE -> 55
051CF -> 8B
with chip select and Output enable i need 20 lines with a 150 ns valid address and then drop the CE and OE and do a parallel read. yes I hand wired level shifters from Teency to the EEPROM. if we can get this running we can put scope probes on the failing pins. Engineering has given up on this and want me to try a STM32F4 Dev board. I would prefer to stick with what i know but I am limmited to basic Arduino code.

a basic code that writes 0xFFFFF and reads 8 bits is all I need with the write being parallel and the read being a parallel read.

writeAddress20(0xFFFFF);
writeAddress20(0x00000);
writeAddress20(0xFFFFF);
writeAddress20(0x00000);

this gives a 40ns square wave but not on all 20bits
 
Only 11 lines toggle. The Principal Engineer was impressed that I only took three days to get this going with AI help. The new hire engineer was exited to do something useful in the lab. The Master Engineering Technician who came up with the was happy to help. After a week of trying to get all 20 output lines working, I was told to give up. What a disappointment, you guy could have looked really good. I have used Teencys for years in the lab, the 3.2 was like candy.
 
You don't even need a microcontroller... hardwire the thing on a breadboard (with 100nF vcc-gnd) with your test address, and it will output the value stored at that address forever... if you want to test some timings, you can toggle oe...
What is your real intention?
 
Last edited:
U could tell your boss to buy something like this: https://www.amazon.de/ETETRON-Programmierer-27Cxxx-27c256-27c512/dp/B00K2VYBC0
That'll be cheaper for him than paying several people (for many hours) just to read a single EPROM, and he'll thank you for the suggestion.
how do yo trouble shoot an intermittent? still cant get more that 11bits toggling and no code suggestions. looks like the Teency wont do 20 lines
You don't even need a microcontroller... hardwire the thing on a breadboard (with 100nF vcc-gnd) with your test address, and it will output the value stored at that address forever... if you want to test some timings, you can toggle oe...
What is your real intention?
clearly you don't know how the read timing diagram works.
 
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...

and no code suggestions

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

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

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

how do yo trouble shoot an intermittent?

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.
 
Back
Top