Thursday 4 March 2021

Ben Eater : Arduino EEPROM Programmer

 Having substantially completed Ben's 6502 Hello World project I can start to think what to progress myself.  My priority is to see if I can avoid the need to remove the EEPROM, burn new code in a programmer, and replace it each time I write, amend or correct a 6502 assembly program.

I have a Mega 2560 attached to the 6502 board connected to the address and data buses and therefore connected to most pins on the AT28C256 EEPROM.  The TLS EEPROM programmer I have been using doesn't require special hardware capabilities so providing I connect the Mega to the three EEPROM control pins (Output Enable, Write Enable, Chip Enable) I should be able to write programs to it.

Prototype EEPROM write sketch

I started with a separate breadboard EEPROM with digital I/O pins on an Arduino Mega 2560 connected to each I/O pin.  I firstly wrote a sketch to read data from the EEPROM and display on the Arduino serial monitor.  Functionally this program was very similar to the 6502 video program to read from memory, so it was easy to implement in a sketch.

Ben has an Arduino EEPROM programmer as a separate video tutorial.  It uses a nano and shift registers instead of a Mega to read/write the EEPROM but it provided useful hints for me to write to the EEPROM.  In fact the write process is very simple: disable the output pins, set address and data values on the bus then pulse Write Enable low for 1 microsecond to write data.  To test the program I took the EEPROM which previously displayed "Goodbye, Cruel W" and changed the letter "l" (0x68" to "t" (0x74).  I replaced the EEPROM in the 6502 board and checked that the message displayed was updated. 


John65-02

Originally it was my intention to retrofit this change to the BenEater circuit but instead I have started a new circuit which I will call John65-02.  Leaving the mega connected to ROM I also connected up a 6502 CPU on the board.  CPU and ROM share the same address and data bus so I simply added chip enable, output enable, write enable logic from 6502 as previously.  I connected Bens clock circuit for a testing clock signal.  With the mega connected to 6502 read-write bus, clock and reset I was able to run the Mega monitor program to watch what was happening on the processor.  Importantly, without changing any connections I can also run a sketch to re-program the ROM.  I thought I might have to turn off the 6502 using its ready or bus enable pins but it turned out that , as long as I stopped the clock I could run the ROM update.

This is great progress, I can avoid removing chips to change a program.  It was becoming a liability inserting/removing the chip on a crowded board.  Eventually wires would be dislodged causing a difficult debugging exercise.

In addition to being able to write to the ROM, I have more work to do.  I need to be able to move the raw data from a PC file into a sketch so that I can download it to the ROM.  I am considering using X/Y/ZMODEM to do this, as I did for the RPI bare metal programs.  Alternatively I have ordered a wide 28 pin ZIF socket, which I could put into the circuit to make ROM extraction / replacement easier.

No comments:

Post a Comment