The idea is to use a Raspberry Pico board to generate a clock signal that could be directly connected to the clock pin of a microprocessor.
It is a square wave generator that can generate frequency from 1 Hz to 127 Mhz, the maximum frequency you can get from a Raspberry Pico GPIO pin configured as PWM.
Picoclock-mini is based on Picoclock by dotdust. It was changed to remove the display and reduce button count to three.
- Toggle: Toggle running frequency between FREQ_LOW and FREQ_HIGH
- Start/Stop: Start and stop the clock to allow the user to freeze the 6502 in the current state. This will work only if you use a modern 6502 with a fully static design (e.g., W65C02S6TPLG-14 from The Western Design Center, Inc.)
- Pulse: Pushing this button will generate a transition from low to high and high to low on the clock output pin. This allows you to single-step the 6502 microprocessor.
The main.py file contains the following configuration:
# GPIO pin mapping
PIN_CLOCK = 0 # Output pin for generated clock signal
PIN_BUTTON_TOGGLE_FREQ = 16 # Toggle button
PIN_BUTTON_START_STOP = 17 # Start/Stop button
PIN_BUTTON_PULSE = 21 # Pulse button
PIN_LED = 25 # On board led (on if the clock is running)
You can modify these according to your taste.
FREQ_LOW = 2 # Low frequency setting in Hz
FREQ_HIGH = 1000 # High frequency setting in Hz
MAXIMUM_PWM_FREQUENCY = 127_000_000 # Maximum PWM frequency in Hz (RP2040 max is 125MHz)
This is the circuit I have designed.
You will find the Kicad files for this "project" in the kicad directory.
This is what you will need to build a picoclock:
- One solderless breadboard.
- One Raspberry Pi Pico (SKU: RPI-PICO).
- Three button switches. Choose some that can fit on the breadboard easily.
- Three 220 ohm resistors.
The circuit is so simple that you will not need help putting it together. Below is a picture of my final assembly (if you can say "final" to any personal project).
You will need to set up the Raspberry Pi Pico for MicroPython development. You can find detailed instructions here: MicroPython
I have used Visual Studio Code for development and testing. Even if I prefer to work with PyCharm, the Visual Studio Code MicroPython extension is much better than the one you will find on PyCharm. The Visual Studio Code extension I have used is MicroPico.
Just upload the project to your Raspberry Pico, and you will be ready.
While writing the software, I discovered that the Pico PWM can not generate frequencies below 8 Hz. This is why I had to use PWM for frequencies greater than 10 Hz and a Timer for frequencies below or equal to 10 Hz. Interestingly enough, I did not have the same problem using a Raspberry Pi Model 3b.
In order to connect picoclock to a 6502 board, that does not already have a clock, you need to follow two simple steps:
- Connect the Raspberry Pi Pico GP0 pin to the 6502 PHI2 pin. (PHI2 pin is pin 37 on the 6502 microprocessor)
- Connect picoclock ground to the 6502 ground.
This project is not up to par with others built by much more experienced people out there. It is something that works for me and that I wanted to share.
It is also expensive compared to other square wave generators you can build or buy. I always use these kind of projects to learn something.
This work is licensed under the MIT License.
