This shows you the differences between two versions of the page.
Both sides previous revision Previous revision Next revision | Previous revision | ||
products:atmega32u4breakout:index.html [2011/02/06 00:38] ladyada |
products:atmega32u4breakout:index.html [2016/02/09 22:46] (current) ladyada |
||
---|---|---|---|
Line 1: | Line 1: | ||
- | {{ :products:atmega32u4breakout:headerplaced_t.jpg |:products:atmega32u4breakout:headerplaced.jpg}} | + | This tutorial has moved to [[https://learn.adafruit.com/atmega32u4-breakout|https://learn.adafruit.com/atmega32u4-breakout]] |
- | + | ||
- | ====== About the Atmega32u4 Breakout board+ ====== | + | |
- | + | ||
- | We like the AVR 8-bit family and were excited to see Atmel upgrade the series with a USB core. Having USB built in allows the chip to act like any USB device. For example, we can program the chip to 'pretend' its a USB joystick, or a keyboard, or a flash drive! Another nice bonus of having USB built in is that instead of having an FTDI chip or cable (like an Arduino), we can emulate the serial port directly in the chip. This costs some Flash space and RAM space but that's the trade-off. | + | |
- | + | ||
- | The only bad news about this chip is that it is surface mount only (SMT), which means that it is not easy to solder the way the larger DIP chips are. For that reason, we made a breakout board. The board comes with some extras like a fuse, a 16mhz crystal, USB connector and a button to start the bootloader. | + | |
- | + | ||
- | ===== Why not use a Teensy ===== | + | |
- | + | ||
- | We've also carry a similar board from PJRC called the [[http://www.adafruit.com/index.php?main_page=product_info&cPath=16&products_id=199|Teensy]]. The Teensy uses the same chip so you may be wondering, why did we design a different-but-still-basically-the-same board? We've used the Teensy in a few projects and like it a lot but there are a few details that we wanted to change. We wanted... | + | |
- | + | ||
- | * ...a bootloader that would work with **avrdude** since that is our preferred software | + | |
- | * ...another LED, for power-good indication | + | |
- | * ...a 500mA fuse on the USB power-source pin | + | |
- | * ...mounting holes so we could attach it easily | + | |
- | * ...reprogramming ISP header so we could program the board directly without the bootloader | + | |
- | * ...a larger reset button | + | |
- | * ...all the pins broken out for use with a breadboard | + | |
- | + | ||
- | That doesn't in any way mean that it is better or replaces the Teensy. Here are some reasons we will still use the teensy for many projects | + | |
- | + | ||
- | * It's really really small. A third the size of this breakout | + | |
- | * The bootloader that is programmed in uses only 512 bytes (instead of 4K) | + | |
- | * It works nicely with Teensyduino and auto-resets right before programming | + | |
- | + | ||
- | ====== Assembly ====== | + | |
- | + | ||
- | {{ :products:atmega32u4breakout:atmega32u4_med.jpg |:products:atmega32u4breakout:atmega32u4_lrg.jpg}} | + | |
- | + | ||
- | The breakout is almost completely assembled. We don't solder on the header or 6-pin ISP connector since we find its easy to do but hard to undo, in case you want to put different headers on, or just connect up wires directly. | + | |
- | + | ||
- | The board ships with a strip of header, you can simply break the header into two pieces and place them in a breadboard | + | |
- | + | ||
- | {{ :products:atmega32u4breakout:header_t.jpg |:products:atmega32u4breakout:header.jpg}} | + | |
- | + | ||
- | Then place the board on top and solder it in place | + | |
- | + | ||
- | {{ :products:atmega32u4breakout:headerplaced_t.jpg |:products:atmega32u4breakout:headerplaced.jpg}} | + | |
- | + | ||
- | ====== Design Specifications ====== | + | |
- | + | ||
- | This breakout board is designed to make it easy for you to get started with the Atmega32u4, a USB-native 8 bit AVR microcontroller. We tried to keep the design simple, while taking care of all the details so that you can focus on your project's firmware and hardware. | + | |
- | + | ||
- | ===== Microcontroller ===== | + | |
- | + | ||
- | The main chip is an ATmega32u4, an 8 bit AVR-core processor which has the bonus of a USB core built in. This makes writing USB native programs such as serial ports, mouse/keyboard, mass-storage-controller, MIDI, etc very easy. The chip has 32K of flash and 2.5K of RAM. The microcontroller is clocked at 16 MHz with an on-board crystal. | + | |
- | + | ||
- | ===== Power ===== | + | |
- | + | ||
- | The board is powered by the USB port at 5V. There is a 500mA polyfuse to protect your computer from a shorted circuit. If you'd like to run the board off of another voltage, you can do that by cutting the **VCC** solder jumper bridge underneath and connecting an external voltage to pin #2 of the ISP header. Note that running the board at 3.3v @16mhz is considered overclocking. We do it for prototypes and it seems to work fine but its out of spec! | + | |
- | + | ||
- | There is a 3V pin from the microcontroller's internal regulator (USB signals are at 3V) you can use this for maybe 10mA or so, it might work as a reference voltage) | + | |
- | + | ||
- | ===== Bootloader ===== | + | |
- | + | ||
- | You don't need an AVR programmer to use this board, we put a nice bootloader on there already! The bootloader is activated by pressing the bootloader button. You can tell the bootloader is active when the **green 'Boot' LED pulses/breathes** The board will then show up as a Serial or COM port, and you can use **avrdude** to program it. The 'programmer name' is **avr109** so for example, to test you should run **avrdude -p m32u4 -P COM3 -c avr109** which will initialize the bootloader. | + | |
- | + | ||
- | {{ :products:atmega32u4breakout:avr109.gif |}} | + | |
- | + | ||
- | The bootloader will time out eventually (after about 10 seconds) | + | |
- | Because we are not using a USB/serial converter, bootloading is tremendously fast, we can program a full chip in under 2 seconds! | + | |
- | + | ||
- | The bootloader takes up the last 4K of FLASH, so be aware that you will only have 28K instead of 32K. We have found that this isn't very constricting as 28K is still plenty. If you'd like more space, you can always use the 6-pin ISP connector and an AVR programmer (which will delete the bootloader) | + | |
- | + | ||
- | <del>If you ever want to disable the bootloader you can cut the bottom 'HWB' jumper trace. This will disconnect the 'hardware bootloader' pin, you can then use the button as a plain reset button. | + | |
- | </del> For the first few runs of this board we set the fuses to still use the bootloader even with the HWB jumper cut, if you want to get rid of the bootloader, please set the fuses to remove the BOOTRST fuse. Sorry! | + | |
- | + | ||
- | If you're using windows, you will need an **inf** driver file, you can download it below (in the **Downloads** section) | + | |
- | + | ||
- | ===== USB Development ===== | + | |
- | + | ||
- | The very nice thing about this chip is the USB core built in which makes USB-device development easy. What makes it even easier & better is [[http://www.fourwalledcubicle.com/LUFA.php|the full USB stack already written for you by Dean Camera]]. Called [[http://www.fourwalledcubicle.com/LUFA.php|"LUFA"]], the package comes with tons of working examples for all sorts of USB devices and its compeltely open source. We use the firmware as a 'starting point' which we then expand upon. Please check it out and if you find it useful consider donating time (fixing bugs, improving documentation) or funds to Dean. | + | |
- | + | ||
- | ====== Using Teensyduino ====== | + | |
- | + | ||
- | If you are looking to use Teensyduino (a fork of the Arduino IDE that supports the 32u4 chip) exclusively [[http://www.adafruit.com/index.php?main_page=product_info&cPath=16&products_id=199|we suggest using the Teensy board]] as it supports auto-reset. However, if you've found some code [[http://ladyada.net/make/magstripe/index.html|such as one of our Teensy projects]] that you want to have work with the 32u4 breakout board, this can get you going | + | |
- | + | ||
- | + | ||
- | **[[http://www.ladyada.net/products/atmega32u4breakout/teensyduinov21.zip|If you're running Windows, you can just download this ready-to-go zip package. Uncompress it and inside will be an Arduino IDE that has all the following steps already done]]** | + | |
- | + | ||
- | ===== Install Arduino IDE + Teensyduino ===== | + | |
- | + | ||
- | * [[http://arduino.cc/en/Main/Software|Download the Arduino IDE from arduino.cc]] - as of this tutorial, **IDE v21** works best - its not the latest one so scroll down to find it | + | |
- | * Install Arduino IDE | + | |
- | * [[http://pjrc.com/teensy/td_download.html|Download Teensyduino from PJRC]] - as of this tutorial the latest working teensyduino is 0.9 | + | |
- | * Install Teensyduino into the Arduino IDE you just downloaded | + | |
- | + | ||
- | {{:products:atmega32u4breakout:install-teensyduino.gif|}} | + | |
- | + | ||
- | ===== Edit Boards.txt ===== | + | |
- | + | ||
- | We'll need to tell the IDE about this breakout board. Open up **Arduino IDE/hardware/teensy/boards.txt** | + | |
- | + | ||
- | Add the following text to the end of the file, save it | + | |
- | + | ||
- | <file>adafruit.name=Atmega32u4 breakout | + | |
- | adafruit.upload.protocol=avr109 | + | |
- | adafruit.upload.maximum_size=28672 | + | |
- | adafruit.upload.speed=57600 | + | |
- | adafruit.upload.disable_flushing=true | + | |
- | #adafruit.serial.restart_cmd=true | + | |
- | adafruit.serial.safe_baud_rates_only=true | + | |
- | adafruit.upload.avrdude_wrapper=avrdude | + | |
- | adafruit.build.mcu=atmega32u4 | + | |
- | adafruit.build.core=teensy | + | |
- | #adafruit.build.post_compile_script=teensy_post_compile | + | |
- | adafruit.build.serial_number=true | + | |
- | adafruit.menulist=usbtype,cpuspeed | + | |
- | adafruit.menu.usbtype.title=USB Type | + | |
- | adafruit.menu.usbtype.name0=Serial | + | |
- | adafruit.menu.usbtype.name1=Keyboard + Mouse | + | |
- | adafruit.menu.usbtype.name2=Disk(Internal) + Keyboard | + | |
- | adafruit.menu.usbtype.name3=Disk(SD Card) + Keyboard | + | |
- | adafruit.menu.usbtype.define0=-DUSB_SERIAL | + | |
- | adafruit.menu.usbtype.define1=-DUSB_HID | + | |
- | adafruit.menu.usbtype.define2=-DUSB_DISK | + | |
- | adafruit.menu.usbtype.define3=-DUSB_DISK_SDFLASH | + | |
- | adafruit.menu.usbtype.pref1.fake_serial=teensy_gateway | + | |
- | adafruit.menu.usbtype.pref2.fake_serial=teensy_gateway | + | |
- | adafruit.menu.usbtype.pref2.build.elfpatch=mktinyfat | + | |
- | adafruit.menu.usbtype.pref3.fake_serial=teensy_gateway | + | |
- | adafruit.menu.cpuspeed.title=CPU Speed | + | |
- | adafruit.menu.cpuspeed.name0=16 MHz | + | |
- | adafruit.menu.cpuspeed.name1=8 MHz | + | |
- | adafruit.menu.cpuspeed.name2=4 MHz | + | |
- | adafruit.menu.cpuspeed.name3=2 MHz | + | |
- | adafruit.menu.cpuspeed.name4=1 MHz | + | |
- | adafruit.menu.cpuspeed.pref0.build.f_cpu=16000000L | + | |
- | adafruit.menu.cpuspeed.pref1.build.f_cpu=8000000L | + | |
- | adafruit.menu.cpuspeed.pref2.build.f_cpu=4000000L | + | |
- | adafruit.menu.cpuspeed.pref3.build.f_cpu=2000000L | + | |
- | adafruit.menu.cpuspeed.pref4.build.f_cpu=1000000L | + | |
- | </file> | + | |
- | + | ||
- | ===== Fix avrdude and avrdude.conf ===== | + | |
- | + | ||
- | Arduino uses a **really** old version of Avrdude from 2007, before the chip existed. So we'll need to update it. | + | |
- | + | ||
- | Download the following zip file | + | |
- | {{:products:atmega32u4breakout:avrdude510.zip|AVRDUDE 5.10 (windows)}} | + | |
- | and uncompress it. Copy **avrdude.exe** to **ArduinoIDE/hardware/tools/avr/bin** and **avrdude.conf** to **ArduinoIDE/hardware/tools/avr/etc** | + | |
- | + | ||
- | ===== Update the Vendor ID ===== | + | |
- | + | ||
- | Open the file **Arduino\hardware\teensy\cores\usb_serial\usb_private.h** and find the lines | + | |
- | + | ||
- | <file> | + | |
- | // Mac OS-X and Linux automatically load the correct drivers. On | + | |
- | // Windows, even though the driver is supplied by Microsoft, an | + | |
- | // INF file is needed to load the driver. These numbers need to | + | |
- | // match the INF file. | + | |
- | #define VENDOR_ID 0x16C0 | + | |
- | #define PRODUCT_ID 0x0483 | + | |
- | </file> | + | |
- | + | ||
- | and change it to | + | |
- | + | ||
- | <file> | + | |
- | // Mac OS-X and Linux automatically load the correct drivers. On | + | |
- | // Windows, even though the driver is supplied by Microsoft, an | + | |
- | // INF file is needed to load the driver. These numbers need to | + | |
- | // match the INF file. | + | |
- | #define VENDOR_ID 0x239A | + | |
- | #define PRODUCT_ID 0x0001 | + | |
- | </file> | + | |
- | + | ||
- | + | ||
- | ===== Restart and test ===== | + | |
- | + | ||
- | If you are running the Arduino IDE, quit and restart | + | |
- | + | ||
- | Now you can select the Atmega32u4 breakout board from the Teensyduino Boards menu. | + | |
- | + | ||
- | {{:products:atmega32u4breakout:selectatmega32u4.gif|}} | + | |
- | + | ||
- | You don't need to run the Teensy loader as avrdude works perfectly well on its own. **You will need to press the bootloader button before uploading as we don't have an auto-reset function like the Teensy does.** | + | |
- | + | ||
- | + | ||
- | ====== Download ====== | + | |
- | + | ||
- | * [[http://www.adafruit.com/datasheets/atmega32u4cdc.inf|Bootloader INF file for windows (mac/linux don't need a driver)]] | + | |
- | * [[http://github.com/adafruit/Atmega32u4-Breakout-Board|Schematic and Board layout files]] | + | |
- | * [[http://github.com/adafruit/Atmega32u4-Breakout-Board/raw/master/atmega32u4bbsch.png|Schematic in PNG format]] | + | |
- | * [[http://www.fourwalledcubicle.com/LUFA.php|The LUFA USB-stack website]] | + | |
- | * [[http://github.com/adafruit/lufa-lib|Our minor fork to the LUFA core]] - this is where our bootloader lives (in Bootloaders/CDC) | + | |
- | * [[http://pjrc.com/teensy/teensyduino.html|Teensyduino from PJRC]] | + |