You Can Program AVRs From The Commodore 64

These days, most of our microcontroller boards come with bootloaders so you can squirt hex into them straight over USB. However, you don’t need to do things this way. If you’re more old school, you can program your AVRs right from a Commodore 64. [Linus Akesson] shows us how.

Programming an AVR isn’t that hard. By holding the chip in reset, it’s possible to flash code via a serial protocol using just three wires. However, that’s pretty impractical to do with modern PCs — they don’t come with addressable IO pins anymore. Normally, you’d use a dedicated programmer to do the job, but [Linus] found his had died on a Friday night. So he set about turning his C64 into one instead.

He decided to use the pins of the C64’s Joystick Port 2, with pins 1, 2, 3, and 4 hooked up to SCK, MOSI, Reset, and MISO on the AVR, respectively. 5 V and Ground were also provided courtesy of the C64’s port. He then whipped up a simple bit of assembly code to read a bit of AVR hex and spit it out over the Joystick port following the in-circuit programming protocol. With a 1541 Ultimate to load files on to the C64 in hand, it was easy to pull his compiled AVR program off his modern PC, chuck it on the C64, and then get the old Commodore to program the AVR in turn.

It’s not the first time [Linus] has wowed us with a C64 in hand. If you’ve got your own fresh projects for the best-selling computer of all time, don’t hesitate to let us know!

10 thoughts on “You Can Program AVRs From The Commodore 64

    1. Well he did explain in the write-up, while AVR-dude nowadays also support RPi GPIO out-of-the-box, all his RPis were tied up or embedded in other projects.
      Which always seems to be the case, exactly when you need one.
      I’ve had a box of ~20 RPs around for years, unused. So I handed out maybe 2/3rds to friends and co-workers, figured I’d only need 4-5 for foreseeable future.
      A month or so later, vacation time (i.e. finally time to hack some projects) – all remaining RPs quickly got used up. Should’ve kept a few more spares…

  1. This brings up some memory of how I started with microcontrollers.
    Long time ago that stuff was (too) expensive and complex for me. Think about ceramic IC packages that had to be erased with UV light. Those were low production volume and a simple uC in ceramic package costed around EUR 50.

    Then came the PIC16F84. It cost a few euro’s and you could program it via a few wires hanging off an LPT port. It was also very affordable. I never got very far with that though, because you had to program in assembly and it was a quite bad instruction set too.

    And then, a few years later came the AT90S2313. Also programmable via some LPT wires but GCC was available. And that was pretty rare in those days. (There was also the AT90S1200, but without RAM it was not supported by GCC). That was when it was getting fun to get started with microcontrollers and I bought a bunch of them. One of the firsts programs I programmed was Atmel’s AN910, which was a better / faster programmer that worked over a standard serial port. Later I started using the USBasp from Thomas Fischl in an ATMEGA8 which did software bitbanging over 1.5Mbit/s USB. That was quite impressive back then, but now there are so many uC’s with USB that using bitbanging for USB is difficult to justify. It has serious software limitations (you have to service the USB port every ms)

    Back then the serial protocol for programming the AVR chips was also (briefly) mentioned in the datasheet. Later they started omitting that information, and for example debugwire had to be reverse-engineered:

    https://hackaday.com/2016/04/07/reverse-engineering-debugwire/

    https://hackaday.com/2018/04/24/dissecting-the-avr-debugwire/

    1. “Then came the PIC16F84. It cost a few euro’s and you could program it via a few wires hanging off an LPT port. It was also very affordable. I never got very far with that though, because you had to program in assembly and it was a quite bad instruction set too.”

      +1

      The PIC16F84 was like a spiritual predecessor to the Atmega328/Atmega168.
      The original was 16C84, the successor the 16F84A..

      That being said, the serial port programming via COM port was easily possible, too. An LPT port wasn’t needed.
      The trick for reliability was to use a battery rather than just stealing power from COM port.

      Programs like PICProg or IC‐Prog made programming really easy.
      I do miss the 16F84/16F84A. It was so much easier than using Arduino.
      Back then, we simply exchanged HEX files.

      http://qrp.gr/picprog/

        1. Yeah, that was utterly ridiculous virtue signalling and nothing more. That said, using “main” as the standard git branch name means less to type, I just ignore the dumb reason it was actually changed.

Leave a Reply

Please be kind and respectful to help make the comments section excellent. (Comment Policy)

This site uses Akismet to reduce spam. Learn how your comment data is processed.