Combination AVR ICSP Programmer and Serial Echo Debugger
This project is a tool that helps build other projects. It has two functions:
- In Circuit Serial Programmer for AVR chips, perfect for Arduino programming.
- Serial Echo between the USB connector and a 2 wire Rx/Tx pair, perfect for debugging projects that lack USB.
A nice wooden enclosure, engraved front panel, and handy connector options round out the device.
Grumpenspiel has many projects that use MIDI IN listening on the Arduino hardware serial Rx pin. This pin must be disconnected for uploading new firmware over USB. The “fun” of unplugging this wire from my breadboard wore off quickly. Even putting a switch on the line to make it easier, just too error prone, sitting there wondering why programs will not upload, only to see the wire or switch in the wrong position.
In Circuit Serial Programming is one way around this. I bought an inexpensive USBAsp. It worked a few times and then became a problem. Had to keep redoing the firmware on it. Then it fell apart physically. ENOUGH!
An Arduino can serve as the programmer. The Arduino IDE even ships with a neat little sketch that does the job. I’ll build one myself!
6 pin connections are all you need, plus some LED indicators for mode, errors, and programming activity. Remember that it overwrites the bootloader on the target board, so if you ever want to program the traditional way via USB, you need to reinstall the bootloader (using your programmer).
Building upon the woes of using the hardware serial rx pin, we move to data communication. I make heavy use of Serial.print() statements for debugging programs. Some projects have a serial interface for configuration data. The nice and easy connection to the desktop workstation via USB goes out the window if you’re using Rx for something else.
Software Serial is an option. Use any two I/O pins and a software library, you can send serial data to the outside world. When put into Echo mode, my new toy will set up the normal USB serial connection with the computer, and also set up a Software Serial port to listen to the client program, passing the two ports through to each other.
World’s Best Workshop Assistant
Daddy?! When are you going to be done soldering so we can go PLAY?!?!
The standard 6-wire programmer cable is the flat ribbon cable with 2x3 DIL polarized female connector. Arduino Uno and Nano both include a header that breaks out the necessary 6 pins. Beautiful.
Sometimes I feel limited by the length of 6-pin ribbon wires. Some projects become unwieldy to squeeze the programmer in there. Plus I’m not totally happy with how non-easy it is to connect/disconnect the things. A bit too much friction and force, and some cheap headers with sliding pins make me want something different.
ISP Echo also includes an 8-pin RJ-45 connector, the same used for ethernet. The first 6 pins follow the spec for AVR ISP programming.
This covers the programming mode. For echo mode, she has two options for serial communication, selectable with a sliding switch.
- Serial connection on pins 11 and 12. These pins are already connected to the target board for ISP purposes. In echo mode, the target can make use of its own pins 11 and 12 and we’re all set. This is nice and compact, requires no extra wiring, but it does tie the target board into using 11 and 12 for serial.
- Some projects might need 11 & 12 for another purpose. In that case, the remaining 2 pins on the RJ-45 connector can be used. The target board can connect these to any two pins of choice and ISP Echo will echo from there.
I haven’t come up with a project yet that cannot use 11 and 12 for this purpose, but the switch is there for future use.
The enclosure is made out of Poplar wood, leftovers from Cow Baby Drum Set. Pockets were mill out of top and bottom using my CNC router. The two halves were sanded to a kinda parallelogram shape, on accident. The table for my belt sander had shifted out of square and by the time it became apparent, didn’t want to lose any more available size or waste wood. The wonky shape adds to the charm.
- 4 wood screws hold top and bottom together. Holds drilled and countersunk on the drill press.
- Wood stained with pre-conditioner followed by Varathane Special Walnut (2 coats), makes even this cheap Poplar look beautiful. Sealed with Polycrylic (4 coats).
- Control panel details were laid out in Inkscape.
- Text and ovals converted to GCode using F-Engrave.
- Holes converted to GCode in Easel.
- Oramask on the face before carving.
- GCode fed to GRBL CNC router via bCNC.
- Quite the tool chain, but comes out amazing.
- Testors Enamel paints for the details, followed by some more Polycrylic (2 coats).
- Hand filed the corners of square holes for perfect fit of switches and connectors.
- Cyanoacrylate glue holds all the electronic components in the front panel.
- Hand cut the hole for the USB connector with a utility knife and push razor.
I just love how these wooden enclosures come out, even for utilitarian tools like ISP Echo. Looks pretty sitting on an otherwise “engineery” desk.
Schematic and Circuit
Eagle schematic .sch file is available in the GitHub repository.
The circuit was prototyped on solderless breadboard. I especially wanted to verify that using pins 11 and 12 for both ISP programming and serial communication wouldn’t be a problem.
Plus the LED indicators for Rx/Tx communication needed some experimentation. Not wanting to delay at all since Software Serial comms are active, I simply set the pin high for a single instruction cycle and then immediately turn it off. Had to experiment with the two specific LEDs I’d be using to get the current limiting resistor just right. Very low values since these are never continuously on, only for a single instruction cycle per serial byte that passes through.
For Software Serial, had a bear of a time figuring out why garbage came in when disconnected. Solution was pullup resistors on Rx pins (12 and 5). ISP programming proved to work just fine with MISO (Arduino pin 12, AVR ISP pin 1) pulled up, renewing my vigor for the project.
The final circuit is built on perf-board. Every time I do one of these I swear its my last. These ones that have no connections, just isolated copper pads. Whenever I have a project that feels “simple” enough I try to use up my inventory of these puppies. Either a PCB (best) or at least Perma-Proto board that saves from manually cutting, twisting, aligning every single connection. BUT…its done and more importantly…it works.
Arduino .ino source code is available in the GitHub repository.
The firmware for this guy was pretty simple since Arduino provides the ArduinoISP example out of the box. I started with that and added in a mode selector.
To make things really simple, I only have it read the selectors at startup. I could have made it change mode on the fly but this was just cleaner.
Press the reset button on the front panel to reboot the chip and read any changes in settings.
Normal Arduino bootloader takes a few seconds to initialize, which is cumbersome when you consider the workflow for this guy.
1) Enter programming mode 2) Upload new code to target board 3) Enter echo mode 4) Target board outputs debugging statements that inspire program changes 5) Go to step 1, repeat until happy program
Resetting over and over invokes the Arduino bootloader over and over, along with the few second delay while the bootloader looks for incoming new program instructions. That few seconds multiplied by the workflow described above makes me sad.
So I temporarily rigged a separate Arduino as a programmer, used that to overwrite the bootloader on ISP Echo. Beautiful! Now a reset is near instant and I’m on to programming my new projects with ease.