at90usb162 gotcha: PC0 vs XTAL2

I spent a very long time trying to diagnose a board-level problem in my current project, an (almost all) surface-mount board based on the at90usb162. The board would reliably program over USB (which is very cool) but the programs I was running to blink the onboard LEDs would lock up. When I discovered that touching the body of the crystal would give me a slow-running program, I was convinced that I had bad placement of the crystal, or incorrect capacitors, or the like.

Finally after much head-scratching, I decided to restrict the DDRC to just some of the pins on the port -- before I'd set DDRC = 0xff. Well, it turns out that PC0 is a shared function with XTAL2. Apparently turning on bit 0 of DDRC turns this pin into an output, and makes the crystal stop running. Touching the crystal's can coupled 60Hz ambient noise into it, which was amplified enough to be treated like the external clock (I had suspected that the LEDs were blinking much slower than they should have been, but wasn't entirely sure)

Now I'm tempted to declare this board "working". whee!

Update, 2009-03-19: This board has been incorporated in a project. Yay!

Entry first conceived on 4 October 2008, 3:05 UTC, last modified on 15 January 2012, 3:46 UTC
Website Copyright © 2004-2017 Jeff Epler