// 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);
}
#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);
}