Ben Eater is a remarkable electronics teacher and the 6502 video series continues to demonstrate the high quality he has brought to previous projects. I am excited to get started with my new 6502 microprocessor kit.
The 6502 microprocessor comes from a simpler age, its data sheet has only 32 pages and it needs no ancilliary components; it conveniently uses 5V power. We put the processor on a breadboard and connect a few pins to get started:
- four inputs used for control purposes are set to high and a reset button which can be set low to reset the processor
- for a clock input use the Ben Eater clock module; it allows us to run the processor slowly or single step it in the course of setting up and testing our hardware
- connect a few LEDs to the first 5 address pins
When we apply power and start the clock ticking we see LEDs flashing showing that the processor is doing something, although we dont know what.
An effective way of finding out what is happening is to use an Arduino Mega to monitor the 16 address and 8 data pins. We also want to check the status of the read/write pin. A simple sketch, using interrupts reads each pin with the clock ticks and displays address/data values on the serial monitor.
As the data pins will be read at some stage we hardware values 11101010 (0xEA) using resistors to the data pins.
In conjunction with the manual we see that on reset there is a 7 cycle initiation sequence which reads the reset vector from memory address FFFD and FFFE. Our read operations always return 0xEA so the reset vector read in is an address EAEA and we can see that the processor starts executing a program from that address. Each instruction read in will also be 0xEA, which was conveniently chosen as it is the NOP instruction. We can see from the Arduino serial monitor that the processor continuously reads and executes NOP instructions (which each take two cycles) and increments the program counter.
Amazingly without knowing very much at all we have an understanding of where we need to load our programs and we can see the simple NOP program running. Good progress for our first hour.
No comments:
Post a Comment