Created
July 19, 2021 11:33
-
-
Save moralrecordings/fbd5368b3b02d08bf16d2318aa1b0d26 to your computer and use it in GitHub Desktop.
Teensyduino sketch for ripping a 4-megabit ROM (HN62404P)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Teensyduino sketch for ripping a 4-megabit ROM (HN62404P) | |
#include <stdint.h> | |
#define MAX_ADDR 0x80000 | |
#define START 0x0 | |
void setup() { | |
// Pin setup for the Teensy++ 2.0 | |
DDRB = B11111111; // A-1 to A6 | |
DDRC = B11111111; // A7 to A14 | |
DDRD = B11100011; // CE, OE, 3 NC, A15 to A17 | |
DDRF = B00000000; // D0 to D7 | |
Serial.begin(115200); | |
} | |
void writeAddr(uint32_t addr) { | |
uint32_t mask = B11111111; | |
PORTB = addr & mask; | |
mask = mask << 8; | |
PORTC = (addr & mask) >> 8; | |
mask = B111; | |
mask = mask << 16; | |
PORTD = ((addr & mask) >> 16) << 5; | |
PORTD |= B00000001; | |
PORTD |= B00000010; | |
} | |
void dump() { | |
uint32_t addr = START; | |
while (addr < MAX_ADDR) { | |
writeAddr(addr); | |
delayMicroseconds(2); | |
addr += 1; | |
byte out = PINF; | |
Serial.write(out); | |
delayMicroseconds(2); | |
PORTD = 0; | |
delayMicroseconds(2); | |
} | |
} | |
void loop() { | |
while (1) { | |
char input = Serial.read(); | |
if (input == 'd') { | |
dump(); | |
Serial.write("done"); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment