JOY2PIC: a PIC Programmer on the Joystick Port
- Year
- 2016
- Type
- DIY project
- Category
- Microcontroller programmer
- Manufacturer
- Homebrew (Daniel Serpell, dmsc; PCB by Michael St. Pierre, MyTek)
- Tags
- diy, joystick-port, pic, programmer, icsp, firmware, tk-ii, mytek, dmsc, open-source, beginner
Overview
Several modern Atari add-ons, including the TransKey-II keyboard interface, the UGV video board and the 1088XEL/XLD and 576NUC+ motherboards, use small Microchip PIC microcontrollers. Those chips need flashing, and most people's PIC programmers are tied to a PC. JOY2PIC turns the Atari itself into the programmer.
It was a joint project, begun in December 2015, between Daniel Serpell (AtariAge: dmsc), who wrote the software and much of the hardware design, and Michael St. Pierre (mytek), who laid out the PCB and added more PIC models to the device list. Its first purpose was to let DIY builders update TK-II firmware cheaply. St. Pierre believes it was the first Atari-to-PIC programmer, and probably the first to use a joystick port.
How it works
PIC chips are programmed in circuit (ICSP) over a serial clock-and-data link, and entering programming mode needs a raised programming voltage (VPP). JOY2PIC uses one of the joystick port's four I/O lines to drive a small voltage tripler that produces what the PIC needs to enter ICSP mode. The other three lines talk to the PIC. Everything else is done in software, so the hardware is just a handful of parts, and it could even be built on a breadboard.
Serpell paced the bit-banging at one WSYNC per clock transition, about 7.7 kbaud. Each word takes 28 bits plus 3 ms of programming time, so 2K words of PIC memory flash in roughly 15 seconds.
Parts (original JOY2PIC)
| Ref | Part |
|---|---|
| JOY1 | DE-9 female solder-cup connector |
| ICSP | right-angle break-away header (VPP, VDD, VSS, DAT, CLK) |
| R1, R3 / R2 | 2.2 kΩ / 1 kΩ |
| C1–C5 / C6 | 0.1 µF / 4.7 nF |
| D1–D4 | 1N914 or 1N4148 |
| Q1, Q2 / Q3 | PN2907A / PN2222A |
| D5 | red LED |
Schematics and Gerbers are on the AtariBits site. OSH Park sells bare boards, three at a time.
JOY2PIC-STIK is a later version with a zero-insertion-force socket. It programs 8-, 14- and 18-pin PIC12 and PIC16F devices out of circuit with no cables, adapters or jumpers, and uses the same programming circuit, so all the flashing files work with both.
Software
Serpell's atari-picprog package (GPL, 2016, built with cc65 and MADS) runs entirely on the Atari:
- READHEX reads a Microchip
.HEXfile, asks which PIC model you are using, and writes a new Atari executable that contains the firmware and the programming code. For example,READHEX SAMPLE.HEX SAMPLE.COMfrom the BW-DOS prompt. - Run the result, press START, and the background colour flashes while it programs.
- PICREAD reads back and displays a PIC's memory.
- SETVPP switches on the programming voltage so you can measure it with a meter before you trust the programmer with a chip.
The firmware downloads on AtariBits, for TK-II, the 1088XEL/XLD and the 576NUC+, already come as ready-made ATR and XEX flashing files, so you only need READHEX for your own HEX files.
Tips
- When flashing a TK-II board in circuit, St. Pierre's instructions say to remove POKEY first.
- Check VPP with SETVPP before the first real job.
- The supported devices cover PICs with USB, RS-232, I²C and SPI interfaces, so JOY2PIC is useful beyond Atari projects too.
Credits
- Picture: The original JOY2PIC: a DE-9 plug on one end and a six-pin ICSP header on the other. — Michael St. Pierre (MyTek), AtariBits (CC BY-SA 4.0 (per AtariBits site notice))
- AtariBits — JOY-2-PIC Microchip PIC Programmer (with Daniel Serpell's PicProg notes) — Michael St. Pierre (MyTek), AtariBits (CC BY-SA 4.0 (per AtariBits site notice))
- dmsc/atari-picprog README (GitHub) — GitHub project authors
- AtariBits — TK-II main page (flashing instructions: remove POKEY) — Michael St. Pierre (MyTek), AtariBits (CC BY-SA 4.0 (per AtariBits site notice))
