Sunday, April 1, 2012

USBtinyISP

I got the USBtinyISP (kit) from Adafruit.  I wanted to use it for Arduino stuff - burning bootloaders and uploading "sketches" to ATmega328P's for "stand-alone" projects.  As Arduino-besotted as they are over there, I think it was primarily intended for other, AVR functions.  Adafruit doesn't have it with the rest of the USBtinyISP info, but the Arduino IDE's "boards.txt" file needs several lines added to it:
##############################################################
usbtiny328.name=[usbtinyisp]ATmega328
usbtiny328.upload.using=usbtinyisp
usbtiny328.upload.maximum_size=32768
usbtiny328.build.mcu=atmega328p
usbtiny328.build.f_cpu=16000000L
usbtiny328.build.core=arduino
[ Special thanks to http://blog.lincomatic.com/?p=10 ]

Construction was easy enough.  The instructions are online.  I used jumpers for R4 & R7, the supplied resistors are for use with their "POV Dongle".  The LEDs didn't align with the holes in the project box.  (I might go back and epoxy them in place and lead out wires to the board.)
I have some Arduino clones that I was going to experiment with and the USBtinyISP brought to my attention the fact that they were stuffed with ATmega328's not ATmega328P's. They have different device signatures and the stock Arduino IDE expects a P signature.
"Non-P" devices can be programmed by modifying the avrdude.conf file.
In the ATmega328 section, find and change signature = 0x1e 0x95 0x0f (the P signature) to signature = 0x1e 0x95 0x14 (non-P)
As it is, I don't think that file can be set to have both, so you have to go back & forth to accomodate.
Once uploaded via the ICSP, the bootloader is overwritten and from thereon that IC cannot be uploaded to via the FTDI/serial, not till the bootloader is burned back onto the device.
As mentioned, the USBtinyISP can also be used to burn the bootloaders, but I had to clear a hurdle there, too.  I did a lot of head-scratching and forum posting that got me nowhere and then it struck me - set the Arduino IDE's "Board" option (in Tools) back to the appropriate board.  Once I did that, the bootloading went right.
The advantage to using the ICSP is that the programme starts faster, having no bootloader to run through, and the serial port / UART is committed solely to the project (with no conflicts with the FTDI.). Supposedly, ISP/ICSP uploads to the IO board are faster, but I don't see it.