Thursday, June 18, 2009

SMT USB AVR Programmer With ATTINY2313SO

Thanks to : Ayman El-Khashab, phd, pe

Here is the first iteration of the AVR µISP programmer. This is based on the usbtinyisp from adafruit, that was in turn based on Dick Streefland's USBTiny and the USB stack at www.obdev.at. but smaller and with all SMT parts except for the 10 and 6 pin headers.

I chose to spin my own design since I wanted to use it in a few different modes.First, I wanted to use a standard ISP cable. Second, I wanted to be able to insert pins from the programmer into boards without requiring the ISP header pins populated. Third, I wanted the capability to attach QFP and SOIC clips. And finally, by placing a female connector on the bottom of the programmer, it is possible to place the entire programmer atop a board header.


There are only a few differences in this design

100 Ω series resistors instead of 1500 Ω
Mini USB connector
Blue LED instead of green
Pin mapping of the AVR is slightly different

The entire board is 46mm x 20mm (about 1.8" by 0.8"). The hex code is available below, but if you want to build the code yourself, be certain to use GCC 3.x version. The 4.x versions do not do well with the AVR code size and this program is extremely tight in the ATTiny2313. Secondly, you will need a way to load the initial firmware into the AVR. I used my old standby, the SP12 that I have used for several years.

Since it is based on other designs, this one works with the avrdude programmer as well. Unfortunately the USB organization has come down on the people parcelling out PIDs, so you may have a difficult time getting another one if you so desire.

In addition to using this for programming AVRs, it may be used as a generic SPI controller or JTAG interface. It does not have enough pins for TMS, TCK, TDI, TRST, and TDO. However, many parts (and every Xilinx part I've ever used) do not have a TRST so with just the 3 outputs and 1 input it is possible to program Xilinx FPGAs and CPLDs. You may need a pullup on TDO. Then you can use the playxsvf program to sent a bitstream to the part. I currently use a variant of this for programming the ps3toothfairy devices. I implemented the same thing with the SP12, but it is parallel only and support for parallel ports is dwindling.

Modifying the code

If you decide to make some design changes and spin your own board, you'll need to edit the c code and the header file. The pins are well labeled except for a couple of writes to PORTD. Just search for PORTD in the spi.c code and update for your particular configuration. It is wise to read through the USB headers as well as the usbtiny.h file to understand what you can and cannot change in your design.

If you build the code and it is too large for the device, you have a couple of options. If it is a few bytes off, you can try reducing the string size in usbtiny.h. If it is much too large, you probably have something wrong in your compile or build settings. Check the makefile and be certain you aren't building with the gcc 4.x toolchain.

You can operate the device with avrdude. You may need to add in usb support depending on your platform (it is needed for cygwin).

Anyway, enjoy and thanks to the folks that made previous designs possible.

Build it

Here are pictures of the schematic and gerbers. Download the design below. We may make some available for purchase (especially since you need some method to initially program the micro). The build is not difficult with an iron, but it is likely easier with a toaster oven or hotplate reflow. (I've built a couple all with an iron in a couple of minutes). Click the images to get a larger view. The crystal goes either direction since the pins are at the corners.





Here is the BOM. None of the parts are particularly critical, other than you need to make sure to get the proper footprint.



Downloads

Note that updates were made to the Eagle files after the prototype and I haven't fabbed any from this design yet. It should work (as it was just moving some traces), but as with anything you download, trust-but-verify.

Firmware Source & Hex Code
Eagle Sch & PCB

License

The USBtiny software is licensed under the terms of the GNU General Public License as published by the Free Software Foundation, either version 2 of the license, or (at your option) any later version. A copy of the GPL version 2 license can be found in the file COPYING.

No comments:

Post a Comment