Breadboarding the Arduino- part 1
A few weeks ago, I purchased 10 Atmega328P's from Mouser, naively thinking it would be easy enough to get them working on a breadboard as an Arduino sans the fancy (expensive) board. I was planning to use an FTDI USB to TTL serial data cable to bootload (I bought a 5V one, then realized that the two 3.3V ones I already had would work fine- lesson one of this saga). I also bought a some 16MHz crystals and the appropriate capacitors.
At this point, I want to extend my thanks to whomever it was that decided a 6-pin AVRISP compatible ICSP header would be a value-add to the Arduino. I know that 95% of the Arduino users out there will NEVER use it, but I am very grateful.
So, first hurdle- I figure I'll take one of the 328s and upgrade my Arduino (it was one of the, what, six? Duemilanove's that shipped with a 168 from the factory). Supposedly, the Arduino IDE has the capability of loading the bootloader onto a blank chip through an AVRISP, but I'll be buggered if I could get it to work. After a little bit of monkeying around with it, I gave up, admitted defeat and downloaded AVRStudio. I highly recommend this route if the IDE bootloader program (using AVRDUDE) doesn't work right away- the pain level of a ~100MB download is much lower than trying to debug AVRDUDE- at least, on my internet connection.
At any rate, I had no Atmega328 Arduino to snoop, and nobody, nowhere, had clearly and definitively stated what the configuration bits are supposed to be. So, for posterity, I do that here, now (note that they've changed since I first posted this):
Extended- 0xFD
High- 0xDA
Low- 0xC6
EDIT: Note that these settings ARE NOT the settings suggested in the "boards.txt" file in the hardware\arduino directory. My suggested low bits- 0xC6 instead of 0xFF- will allow more types of crystals or resonators to work, at the expense of a slightly increased power draw. If you're THAT WORRIED about power draw, you're probably already digging deep enough that you've figured all this out, already.
EDIT: Note that these settings ARE NOT the settings suggested in the "boards.txt" file in the hardware\arduino directory. My suggested low bits- 0xC6 instead of 0xFF- will allow more types of crystals or resonators to work, at the expense of a slightly increased power draw. If you're THAT WORRIED about power draw, you're probably already digging deep enough that you've figured all this out, already.
I made a few educated guesses and got values which more or less seemed to work, and then I grabbed the bootloader binary from its home deep in the catacombs of the Arduino application folder. Success! I could upload and run sketches with my new 328 enhanced Duemilanove. Flushed with my success, I immediately launched into the next portion of the project: getting a breadboarded 328 loading sketches through the FTDI cable and the IDE.
At this point, and exactly how I managed to do this remains unclear to me, I proceeded to brick all three of my remaining 328s (I know, I bought 10, but I sold 6 to friends). I know I somehow wrote inappropriate fuse bits to the config registers, but I don't quite know how I did that, let alone how I managed to do it to all three. I can only assume that, briefly, I was MONUMENTALLY stupid.
So, of course, I began a bit of yak shaving. First, I tried my JTAG-ICE mkII, but that only works on JTAG capable parts (which the 328 is not). I THOUGHT it might have HV capability (Microchip's equivalent, the ICD2, does), but alas, no. Finally, thanks to Jeff Keyzer's excellent tutorial on making an Arduino into a high-voltage programmer (only high-voltage programming can resurrect an Arduino under some circumstances; for instance, if the reset pin is disabled), I was able to bring the chips back from the purgatory I thought I'd condemned them to forever.
So, here I sit, at 2:30 in the morning, weeks after starting all of this, about to embark on the next step: getting the parts to work on a breadboard, through the IDE, with minimal "tricks" involved. I will mention that I've been at this point before- before I bricked the chips, I had put them in a bread board and started tinkering, but I just couldn't get the thing to work. We'll see if this turns out any better- with luck, the next post will be a post-mortem on why it failed before and what I did right this time.
Comments
Post a Comment