Tuesday, 27 May 2014

Major overhaul using an AVR XMega 64 pin QFN microcontroller

Away from home, away from my paints, and unable to mess about with my electronics, with only access to the interwebs to keep amused, I've been thinking about my latest board game design.

Originally we used two PIC microcontrollers, and used through-hole chips, so that the playing surface required only a small gap for the soldered pins (rather than a massive chip getting in the way). Two 28-pin PICs, using up 24 i/o lines on each gave us 48 inputs and worked really well.

The nagging doubt about running serial/UART on two chips with no crystal meant a number of re-designs, before we finally settled on a single microcontroller and no less than six 8-bit shift registers. But with a few days to think about it (and no internet connection on a three-hour train journey, but a PIC microchip database installed on a smartphone) I decided that a far better/easier solution would be a single, 64-pin microcontroller.

We've already created a few working board sections using direct connections to input pins (albeit with two micros instead of just one) so we know it works. And a single 64-pin chip is not much more expensive than a 28-pin DIP/soic version, and removes the need for the extra shift registers.

A quick flip through the PIC microchip database and I found the 16F1526 which seemed like a perfect match. Except for one thing... it's tiny! Below is the board, redesigned for a 64-pin TQFP. After completing the entire redesign, I checked the datasheet for the 16F1526 and found the pin-pitch is not 0.8mm but a tiny 0.5mm between centres!


Any number of PIC datasheets later and I found that all of the 64-pin versions have a pin-pitch of just 0.5mm. Which, in turn, means that the maximum trace size is just 0.25mm (with gaps of 0.25mm between pins). For homebrew etching, we really try to stick to 0.5mm where possible, dropping to 0.38mm where necessary (and as small as 0.3mm where absolutely critical). But 0.25mm just feels like a step too far.



We really needed to find some alternative 64-pin chips with a reasonable 0.8mm pin-pitch. Which, sadly, means leaving PICs behind for this prototype.

As it happens, AVR have produced a range of chips which match exactly what we're looking for. They're called the XMega and they're not pin-compatible with other 8-bit AVR chips (as used on the Arduino boards). They don't even use the Arduino IDE for programming. But they do meet all our criteria!


To make the XMega "modular" AVR have completely redesigned the pin layout (so the pins for the UART are the same on PORTC as they as for PORTD and PORTE, for example). The chip also uses a different programming technique - a two-wire PDI programming interface, rather than the traditional ICSP programming lines. In short, it's a completely new microcontroller.


It was only after re-routing a lot of traces and finding I was a few pins short that I actually took note of the pinout for the XMega. It has a lot more power/ground pins than most microcontrollers, and dedicated programming pins. As I was keen to keep the oscillator pins free for adding a crystal (though this particular chipset does have an auto-calibrating digital oscillator so it may end up being unnnecessary) I counted up just the dedicated i/o pins.

Of the 64 pins available, there are exactly forty-eight i/o lines. Phew!
An hour or so of dragging traces around and I got what looks like a reasonable layout


So that's the layout down, and - in theory at least - everything looks like it should work. All that's needed now is to get hold of one of these chips and have a go at programming it! There's a PCB-based programmer at Farnell for about £25 and the AVR Studio is a free download. I grabbed both, and bought a few chips, so hopefully I'll have everything needed to code up these new chips as soon as I get back to Nerd Towers!

Progress will, as usual, be posted here (although it may be interspersed with other random crap along the way).