Electronic – arduino – Programming Multiple ICs using single USBasp/SPI Bus and Arduino IDE

arduinospiusb

Hi and thanks for looking!

Background

After coding and designing a project with the Arduino hardware and IDE, I have been etching my own PCB with a single ATMega328 and related components for the particular project. I include on my boards a six-pin header to which I have been hooking up a generic USBasp programmer and then flash the IC with new code written in the Arduino IDE.

This all works great.

Problem

I am now building a more advanced circuit that requires five ATMega328 ICs–each with it's own code that is unlike the code on the other ICs. I need to be able to flash all five IC's from the single USBasp/SPI six-pin connection, but I don't have a clue how.

I realize that it would be easier to just use a single IC with more pins, but that is not an option for now.

Question

Using my single USBasp/SPI six-pin connection, how can I flash multiple ATMega328 IC's with their respective code that I have written in the Arduino IDE?

Best Answer

I would take the USBAsp firmware and modify it to run on yet another AVR chip on your board that would manipulate the reset lines of each of your five target Atmegas individually. You would need to work out a way of selecting which target to program. If you are using AVRDUDE as your programmer you could use it's "-x extended_param" for this.