Getting started with Xmega: programming hardware


(first update pass of iPhone-written draft)

Atmel’s new AVR Xmega chips use a new programming interface called PDI (Program and Debug Interface) that has both advantages and disadvantages vs. the older ISP protocol used by the original AVR series. The main advantages are the reduced pin count, and the use of the same 2×3 pin connector (if you’re confused, read on…). The disadvantage is that it’s a new protocol that isn’t quite as well supported yet.

While the old ISP protocol is basically SPI with the chip-select line driving RESET, for a total of 6 lines (GND, VCC, SS/RESET, SCK, MISO, MOSI), the PDI protocol is bidirectional synchronous serial, using only 4: GND, VCC, CLK, DATA. This reduction in pin count has two advantages: the number of pins used on the actual chip is lower, and custom programming interconnects can get smaller. The main effect of this on the Xmega is that the PDI lines are strictly dedicated to programming: no more carefully sharing the SPI bus with your real peripheral[s]!

Now back to the part about it being the same old connector: Atmel realized that everybody had developed a significant, um, “attachment” to both their existing programming tools and the connector itself (as opposed to say JTAG’s varied and invariably larger pinouts), and forcing everybody to buy brand new tools just wasn’t going to happen. They also determined that the bidirectional bus of PDI could be effectively implemented by some of their “older” tools!

As a result, they did something that seems far too rare in any industry: add new functionality to already-sold hardware by enhancing the firmware. Duh! you say, but you’d be surprised how often it doesn’t happen.

The gist of this all is that for the most part, any of Atmel’s tools in the last several years have been updated to program the Xmega’s. Off the top of my head (while sitting on a ferry…) at least these programmers are supposed to work:

– Dragon

All these programmers use the STK500 protocol with an “XPROG” extended mode, which grants access to all the newer memory (flash) regions of the Xmega chips.

I haven’t particularly looked for any third-party support for the PDI protocol in other programmers, so at this point you’re mostly stuck with the above devices.  However, the AVR-ISP MkII isn’t really all that expensive, running $35.36 from Digikey.  While I applaud people who design their own bootstrap programmers and such, I really never got the obsessive need to spend so much effort to save a Jackson or two.  I know how much work it takes to implement a programmer like this, because I’ve been required to do so for some commercial projects.  I’m writing one right now as it turns out…  Development effort can run into the $1000’s if you value your time at all.

That being said, I am going to be writing my own PDI stack in the near future, because of the requirements of a commercial project very similar to the one that had me writing such code last time.  It will be released to the public in a form that I believe will be far more modular and easy to integrate into other software projects.  More on that later.


One comment

  1. Very useful article , thank you.
    There is a Typo in the pin numbers on ATXmega44, Purple pin 35 is marked as 45.

Leave a Reply to jeffP Cancel reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: