The AVR ATXmega chip is a newer offering in Atmel’s AVR line. The Xmega is billed as a hybrid 8/16-bit MCU, which means you can use your normal development environment to program Xmegas (as compared to AVR32 and Atmel’s ARM line). Because the Xmega uses a different programming interface, it does require a programmer that can speak PDI, such as the AVRISP mk II or an AVRISP mkII clone like the one found in the LUFA package. However, it provides an amazing set of device peripherals that can definitely up the output of your next project. For example, it supports in hardware two mechanisms to shunt the CPU out of data transfers and interrupt processing to offload the MCU and allow it to do other things, greatly improving performance:
- Direct Memory Access (DMA) controller capable of transferring data between memories and peripherals (ie between the USB and USART) with minimal MCU intervention
- An Event System allows peripherals to trigger actions in other peripherals (think interrupts) without the need for the MCU to get involved directly. Peripherals supported include ADC, DAC, DMA, and all the ports.
Other peripherals and modules of particular interest include:
- AWex – Advanced Waveform Extension for extremely precise waveform generation
- Hi-Res – High Resolution Extension for AWeX and timers.
- IR Communications module
- AES and DES crypto engines
- External Bus Interface to fast-track external memory
- An Analog-to-Digital converter and Digital-to-analog converters
It has, of course, the other standard peripherals you’ve come to expect in an AVR such as TWI, SPI, USART, RTC, interrupts, internal clock sources with PLL, etc. Using the internal oscillator and no external crystal, the Xmega boasts system clock speeds of 32MHz. One of the downsides to the Xmega line, though, is the lack of any PDIP versions of the chips; all chips are surface mount TQFP/TQFN/BGA ranging from low-density 44-pin to high-density 100-pin configurations.
Not having a PDIP version makes it more difficult to get into the Xmega line because to prototype and program your Xmega you will need specific hardware that interfaces to the SMD (surface mount) chips. But if you don’t get into the Xmega line you are missing out on such good peripherals and coding fun, so what’s a guy to do?
This instructable will walk you through making a complete, working AVR Xmega programming and development board. This board will allow you to connect Xmega chips, program them, then put them in your device in the field (or in your house!).
Step: 1 Requirements
The Xmega programming and development board requires a few pieces of hardware to complete the build that you may or may not have lying about your place. First, the design was etched onto 1oz double-sided copper clad and a silk screen layer was then layered over the top. This entails having a 3.25″ x 3.75″ double-sided copper clad board (a 1/2oz board works well, too), your favourite etchant, soldering equipment, etc.
The second part includes the chip carrier, which can be purchased from futurelec.com. You may need the TQFP44 carrier for ATXmega32A4 and other TQFP44 chips, while the TQFP64 carrier can be used for the ATXmega64/128/256A3’s. From the website I mentioned in this paragraph, the cost is $1.20 and $1.30, respectively. That’s very economical for an adapter board.
Finally, you’ll need the electronic components that I use in this design. The components range from double-row female sockets to 10uF tantalum capacitors to 3mm LED’s. To avoid listing every part in my design here, I’ve attached a BOM at the bottom of the page.
I’ve skipped mentioning anything about software as that’s dependent on your style and flow. I prefer using NetBeans IDE with custom-compiled AVR GCC toolchain on a Solaris UNIX system, although AVR Studio, NetBeans, and Visual Studio are options on Windows. This is all ancillary to our hardware build that we’ll get into when you turn the page!
Step: 2 ATXmega Programming Board Design
My primary design for the board came from suggestions in Atmel’s AVR042: Hardware Considerations guide as well as eyeballing different reference designs. The board accepts DC power and has an on-board regulator for clean 3.3V power. I decided to use the internal 32MHz oscillator and only include a 32kHz watch crystal for real time clock management. It also has support for USART-to-USB via an FTDI chip on a USB BUB from Moderndevice.com for $14, so pin headers are on the board for that. I’m a big fan of visual indication of action, so I’ve included a green 3mm LED to indicate power and a red 3mm LED connected to the reset switch to verify a hard reset of the chip.
My primary goal, though, was to produce a board that allowed access to most all pins without having to setup the many decoupling capacitors needed for each new chip to be programmed. As mentioned, the programming interface is PDI because it doesn’t support SPI and I don’t have a JTAG debugger/programmer (it’s on my wishlist) so there’s no JTAG support on the board.
Included below are pictures of the latest design along with Eagle CAD schematic and board files. I’ve also created a panel of bottom, mirrored top, and silkscreen layers at 300dpi (consider printing at 1200dpi) in PDF format. This is what I use to print out on transparency or toner transfer paper, so I’ve included it as a convenience. Take a minute to look at the layout of the board.
Idioms of Hardware Design
If you’ve taken a minute to look at the board you’ve probably noticed that it can be broken into little pieces that I like to call Hardware Design Idioms (or Patterns). These are little circuits that you make over and over again for each (or many) designs. I’ve partitioned the whole design into the following idioms:
The power subsystem is the component I make the most on my boards because I’ve found pulling too many mA from USB can cause serious problems (I burned a USB hub once). Plus having its own power subsystem allows you to just hook it up to a DC wall wart from 5V to ~20V and run it stand-alone while you program. An external source of power is necessary if you’re using the AVRISP mkII as it doesn’t supply the board with power like some of the other programmers out there.
The basic design of the power component is simple and straight-forward. A DC jack accepts a plug that delivers power with a rather large polarized capacitor across the positive and negative rails. Run (+) into an LDO regulator of fixed 3.3V followed by two more filtering capacitors at 1uF and 0.1uF. They do not need to be polarized as the schematic suggests.
The final (+) rail out of the last capacitor is a very stable, regulated 3.3V. You may choose to use through-hole components over the SMD components I’ve used and that’s totally up to you. I use what I have on hand for the most part. I’ve also used a 27uH inductor on the AVCC port to make the analog power a little cleaner.
I’ve also included two other power constituents: a two-pronged header for exporting power, and a 3-pin jumper used to indicate whether the power is coming from the DC jack or from the USB. It’s your option. Picture below.
I almost always include a reset circuit in my designs. It’s handy. This hardware pattern consists of the following:
- Pull up !RESET to Vcc
- Connect one side of tactile switch to the !RESET with the other side connected to a resistor/LED pair going to ground.
- Strap a 0.1uF capacitor between both sides of the switch (ie both pins you used).
NOTE: Use caution with the capacitor option as it will disable the use of debugWIRE, if you use it. Then again, if you use it, you’ll have to add your own connector to the design.
Push the reset button, the red LED comes on, and release. The ATXmega chip is hardware reset and reboots. See the picture below.
In analog designs, decoupling (or bypass here) is used to shunt high-frequency signals on the power line to ground. This is found at the analog Vcc input. In digital designs, the purpose is different. The amperage draw from the MCU and onboard devices is an average and when many pins are in use and operation, the current draw can be hundreds of mA or more. The capacitors placed across the Vcc and ground act as mini reservoirs of charge that can supply a port the current it needs when the power supply is a distance away. It’s optimal to place these capacitors as insanely close to the port they are servicing as possible.
In my design, you’ll find the decoupling capacitors under the carrier chip (that is, between the dual-row sockets This inclusion is important at the ATXmega, AVR32, and ARM levels because many of these chips have many Vcc and AVcc connections that must all be decoupled. It’s a pain to do it manually….just don’t do it. Do it on the programming board and be done with it.
I often like to have an outlet for debug output. An LCD can be too restricting for getting lots of debug data from your firmware. Therefore, I often include a 6-pin right-angle pin header that interfaces to the Modern Devices’ USB BUB module. It allows you to simply write to your RS232 USART and is passed over USB via an FTDI chip. On the PC, I then use AVR Terminal to visualize my debug data. This is invaluable (for me, at least).
You may choose to remove this if you don’t have the USB capabilities, although for $14 the USB BUB is a great buy. Picture below.
Contrary to the hardware design found in many AVR designs, a 16MHz or 20MHz external crystal isn’t really used for the system clock on Xmegas. I use the internal 32MHz oscillator and only include a 32kHz watch crystal for use in real time clock timekeeping. It’s not necessary to use, but it’s on board if you need timekeeping functionality. Again, it’s parallel capacitive and uses two small (usually 18pF to 22pF) capacitors to GND.
As an added benefit, the PLL can use the external 32kHz crystal for runtime compensation of temperature and drift, thereby further enhancing the accuracy of the 32MHz oscillator.
Now, what would a programming board be without a programming interface? Here we use a simple 2×3 male pin header; the same as used for SPI programming. Check below for the pinout of the PDI interface. I simply provide power and make the two appropriate PDI connections and call it a day. PDI eliminates the need for SPI isolation resistors.
So, for the ATXmega programming/devel board, you’ll find it bristling with socket headers. There are four (2 in parallel) dual-row 2 x 8 female headers to accept the 2×8 male headers from the Xmega carrier board. I’ve also tried to bring out as many MCU pins to headers for access in development and these can be found in the single row female headers around the outside edges. These are marked with a silk screen layer indicating what pin is brought out to which socket.
Step: 3 Build your board
Your mission, should you chose to accept it, is to print to toner transfer paper (with or without your modifications), transfer to your copper clad board, etch and drill — or follow whatever established etching protocol you use. Although I’ve successfully etched 0.12 traces, you will notice I enlarged the traces and pads for easier homemade etching. When you are finished the board should look something like the pictures below.
At this point (or before I silkscreen), I take steel wool and buff both sides while wearing nitrile gloves to give the copper a super shine and remove any built-up oxidation or oil from fingerprints.
Pin your vias first (since homemade etching doesn’t through-hole plate, I’ve found it more effective to solder a wire from top to bottom layers. Next place your SMD components, if you have any, followed by resistors, capacitors, switches. Finally, place your taller components, such as the headers and power jack. Before you power it, place standoffs in the corners.
Your finished board might look like the one below.
Step: 4 Carrier Board
Because the Xmega line is available only in SMD packages, there must be some way to get the target MCU onto the programming board BUT still be able to remove it and place it in a production device. It was an important design feature that the programming board not be a one-shot programming device for one soldered SMD chip. To accomplish this, I use a carrier board. Check out the pictures.
Soldering TQFP44/48/64 chips is surprisingly simple.
- Wipe off the carrier board to remove dirt, dust, and fingerprint oil.
- Put a light coat of solder flux over the pin pads on the carrier board
- Place the MCU in the correct orientation on the board (notice where pin 1 is) and hold it down. I use the head of an eraser on a pencil because it has good grip but is soft on the chip.
- After ensuring all pins are aligned on their correct pads, solder one corner.
- Get solder on your gun and run it across the pins quickly. Don’t worry about cross connects. Make sure all pins have solder.
- Take solder wick and wick up any excess solder on all four sides.
- Check your work with a loupe or high-power magnifying glass.
Now that you have your Xmega MCU soldered into it’s carrier board, solder in 2 x 8 male headers with the connections pointing out the bottom of the carrier. See the pics below. Once you’ve done this your carrier board is finished. This is the component that you can add and remove to your programming board and production device.
Next step: get it goin’ on!
For more detail: Build an AVR Xmega Prototyping Board using AVR microcontrollers