Seyed Masoud Hosseini · Overview · Study log · Ideas · Transcript · RSS feed
Embedded Systems, 6502 breadboard computer · Lecture 1 of 29 · 27:24
Part 1: 'Hello, world' from scratch on a 6502
Study guide
What this lecture covers
This is the first video in a series that builds a working computer around the classic 6502 microprocessor, starting from a completely bare chip on a breadboard. The lecture answers a basic question: with no operating system, compiler, or existing computer to lean on, what does it actually take to get a microprocessor to do anything at all?
You'll see every pin on the 6502 wired up by hand, a clock signal supplied, and an Arduino used as a makeshift logic monitor to read the address and data buses. By the end, the chip is executing a trivial "no operation" loop, which sets up the next video's step of feeding it real instructions from a ROM chip.
Key ideas
- VDD/VSS: the 6502's power and ground pins, wired directly to the breadboard's power and ground rails.
- Input vs. output pins: inputs (like
RDY,IRQB, reset) must be tied to a sensible voltage for the chip to run; outputs can be left unconnected while exploring. - Clock (
PHI2): the 6502 needs a repeating clock signal to step through its operation; a manually adjustable clock module is used so individual pulses can be observed. - Static design: the modern W65C02 variant used here can hold its clock at any level without losing register contents, unlike the original 1975 chip.
- Reset sequence: pulling reset low and releasing it starts a seven-clock-cycle sequence that loads the program counter from the reset vector.
- Reset vector: the two bytes at addresses
$FFFCand$FFFDtell the processor where to start executing code. - Read/write signal: a dedicated pin tells external circuitry whether the processor is currently reading from or writing to the data bus.
- Opcode
$EA: with the data bus resistors used in the video, the processor reads the same byte on every cycle, which happens to decode as the no-op instruction.
Walkthrough
Powering and wiring the bare chip (1:01)
The lecture goes pin by pin through the 6502 datasheet, connecting VDD and VSS to the power rails, then deciding what to do with each remaining pin. Inputs that matter for the chip to run, such as ready, the two interrupt lines, and bus enable, are tied high so they don't interfere. Outputs, including the sixteen address lines and status pins, are left unconnected for now since nothing depends on them yet.
Clock and reset wiring (4:07)
A separate 555-timer-based clock module (built in an earlier project) drives the PHI2 clock pin so pulses can be slowed down, halted, or single-stepped. The reset pin is tied high through a resistor with a push button to ground, so pressing the button forces a reset while releasing it lets the processor run normally.
Reading the address bus with an Arduino (8:18)
Rather than using a logic analyzer, which is overkill for a slow, hand-clocked circuit, the sixteen address lines are connected to digital input pins on an Arduino Mega. A simple sketch loops through the pins, reads each as a bit, and prints the 16-bit pattern to the serial monitor once per clock cycle, triggered by an interrupt on the clock line.
Adding the data bus and read/write signal (13:38)
The eight data bus pins and the read/write pin are wired to more Arduino inputs. The sketch is extended to accumulate the address and data bits into integers and print them as hexadecimal, along with an R or W showing whether the processor is reading or writing. At this point the data pins are unconnected, so the processor reads meaningless "garbage" whenever it tries to fetch data.
Hard-wiring a predictable data value (18:46)
Each data pin is tied to ground or 5 volts through a resistor so the processor always reads the same fixed byte ($EA) from the data bus. This makes the processor's behavior far more predictable: it starts counting addresses steadily instead of behaving erratically.
Tracing the reset sequence and first instructions (20:47)
Single-stepping the clock through a reset shows the seven-cycle reset sequence, followed by two reads from the reset vector addresses $FFFC and $FFFD. Because both reads return $EA, the program counter loads $EAEA, and the processor begins fetching from that address, where it keeps reading the same hard-wired byte. Looking it up in the datasheet's opcode table shows $EA decodes as the no-op instruction, so the processor simply loops doing nothing, advancing one address every two clock cycles.
Before you watch
- Familiarity with binary and hexadecimal number systems will help when reading the address and data bus values.
- Basic breadboard wiring and reading a component pinout from a datasheet are assumed.
- No prior 6502 or assembly knowledge is needed; this video builds the foundation for the rest of the series.
Check your understanding
- Why does the processor read the same value from the data bus in the second half of the video, and how does that make its behavior more predictable?
- What are the reset vector addresses, and what role do they play immediately after reset?
- Why did the lecture choose an Arduino instead of a logic analyzer to observe the address and data buses?
- What does the read/write pin tell you about what the processor is doing on a given clock cycle?
- Why does the no-op instruction take two clock cycles to complete on this chip?
Chapters
- 0:00 <Untitled Chapter 1>
- 1:16 put the microprocessor on a breadboard
- 1:22 connect that to the positive power rail of our breadboard
- 1:28 connect that to the ground rail on the breadboard
- 2:10 need to hook pin 2 to 5 volts
- 2:34 triggering an interrupt pin five
- 3:02 all outputs
- 3:54 connect pin 36 to 5 volts
- 4:26 output a 10 megahertz clock
- 5:18 using the modern static version of the 6502
- 6:15 tie it high through a 1k resistor
- 6:43 plug in five volts
- 7:14 connect a few of the address lines
- 7:17 connecting up the first five address lines
- 7:22 connect the other side of the leds to ground
- 8:42 hook them up to inputs on the arduino
- 9:11 hook those 16 address lines up to 16 of the digital
- 9:39 connected into 16 digital i / o pins of the arduino
- 10:03 loop through all 16 pins
- 10:59 initialize the serial port to 57600
- 11:17 open up the serial monitor
- 12:05 set the pin mode for clock
- 12:19 attach an interrupt to the the interrupt for the clock pin
- 12:51 print out the values of the address pins once per clock
- 13:06 bring up the serial monitor
- 13:58 list out all of the pin numbers for the data bus
- 14:19 set the pin mode for each of the eight data pins
- 14:36 print the eight data lines
- 15:03 start with the address equal to zero
- 15:54 print the address as a four digit hex
- 16:55 set the pin mode for the read / write pin
- 17:42 bring back our serial monitor
- 18:18 treating those 8 data pins as inputs
- 18:59 tying each to either ground or 5 volts through a 1k
- 19:17 drive the output either to 0 or 5 volts
- 19:34 hooked these resistors to your either ground or 5 volts
- 21:17 initialize the microprocessor
- 21:43 pulsed the clock seven times 1 2 3 4 5 6 7
- 22:21 advance the clock one more time
- 23:22 read the reset vector from from these two locations
- 23:55 sets its address pins to that address
- 24:43 pulse the clock
- 25:06 pulse the clock twice for it to advance
- 26:17 build your own simple computer with the 6502 microprocessor
From the YouTube description
Learn how computers work in this series where I build and program a basic computer with the classic 6502 microprocessor. More info: https://www.eater.net/6502
Part 2: https://www.youtube.com/watch?v=yl8vPW5hydQ
Part 3: https://www.youtube.com/watch?v=oO8_2JJV0B4
Part 4: https://www.youtube.com/watch?v=FY3zTUaykVo
Part 5: https://www.youtube.com/watch?v=xBjQVxVxOxc
Part 6: https://www.youtube.com/watch?v=i_wrxBdXTgM
Part 7: https://www.youtube.com/watch?v=omI0MrTWiMU
Support these videos on Patreon: https://www.patreon.com/beneater or https://eater.net/support for other ways to support.
------------------
Social media:
Website: https://www.eater.net
Twitter: https://x.com/beneater
Patreon: https://patreon.com/beneater
Reddit: https://www.reddit.com/r/beneater
Special thanks to these supporters for making this video possible:
Alex Catchpole
Armin Brauns
BakerStaunch
Beau-James Erion
Ben
Ben Dyson
Ben Kamens
Ben Williams
Bradley Pirtle
Christopher Blackmon
Clayton Parker Coleman
Daniel Tang
Dean Winger
Debilu Krastas
Dominic Kulmer
Dušan Dželebdžić
Eric Brummer
Eric Dynowski
Erik Broeders
Eugene Bulkin
fxshlein
HaykH
Ian Tait
Ivan Sorokin
JavaXP
Jay Binks
Jayne Gabriele
Jefferson Hunt
Jimmy Campbell
Joel Messerli
Joel Miller
Jordan Scales
Joshua King
Justin Duch
Kent Collins
Manne Moquist
Marcus Classon
Mats Fredriksson
Michael
Michael Burke
Michael Garland
Miguel Ríos
Nathan Wachholz
Nicholas Moresco
Onion Sniffer
Paul Pluzhnikov
Peter Simard
Randy True
Robert Butler
Sachin Chitale
Sergey Ten
SonOfSofaman
Stefan Nesinger
Stephen Smithstone
Steve Gorman
Thomas Ballinger
Vladimir Kanazir
xisente
Örn Arnarson
