You can find the source code and supplements for this
article in Workshop22.zip at www.nutsvolts.com.
SMILEY’S WORKSHOP ☺
could shine a UV lamp onto the memory and erase it.
This operation took a while, the software test procedure
generally went like this: fail, pull out the EPROM, stick it in
a UV eraser, go get a cup of coffee and watch a soap opera,
load the next iteration of the code using an EPROM
programmer, fail, pull out the EPROM ... it was actually
even more boring that it sounds. Then, some genius figured
out a way to erase the EPROM with electricity thereby
creating the EEPROM (the additional E stands for Electrical).
EEPROM is a kind of memory that won’t go brain
dead if you pull the alligator clip off the lantern battery,
and you don’t need a special eraser to erase it. The next
innovation was Flash EEPROM, more commonly known as
Flash memory. This memory was much cheaper than regular
EEPROM because it erased memory in large blocks rather
than a byte at a time. It’s the kind of memory you usually
find on memory cards and USB Flash drives. This innovation
is one of the reasons that we have AVRs. The guys who
designed the AVR wanted program memory that could be
both non-volatile and easily erasable, so they got with the
folks at Atmel (who were making cash on Flash). So, what
does this have to do with Baron Munchhausen? Well, the
AVR architecture has some special features that allow us
to use Flash memory as a bootloader.
All right, that was strange, but the points were: A
bootloader allows you to program a microcontroller without
an external programmer; and Flash memory is great for a
bootloader because it is non-volatile so you can use lantern
batteries and alligator clips without cursing and throwing things.
Chicken or Egg
A bootloader is a program that allows you to upload a
program without having an external programmer.
However, the bootloader IS a program, so how do you
program it onto a micro? Well, you use an external
programmer. But — you ask — if the reason for a
bootloader is so you don’t need an external programmer
... but you need one to put the bootloader on the micro ...
Wait a minute! This is confusing! The answer is that if you
have an external programmer, then you don’t need a
bootloader — but if somebody is kind enough to program
the chip with a bootloader for you, then you don’t need
an external programmer.
Last month, we relied on SparkFun ( www.sparkfun.com)
to put a bootloader on an ATmega328 for our
BreadboArduino. This month, we are going to look at how
to put a bootloader on an ATmega644. Atmel has several
really good programmers that would fit our needs: the
AVRISP mkII; the Dragon; and the STK-500 — in order of
cost and capability. Since we will be using ISP (In System
Programming), any of the three would suffice. I’ll go with
the mid-priced (~$50) option to save space.
Building the BeAVR on a Breadboard
To make this truly open source, I thought it best to
Sch. Part Description Mouser Part #
IC1 ATmega644 556-ATMEGA644-20PU
H1 Right Angle Header 517-500-01-36
Sch. Part Description SparkFun Part #
Q1 Crystal 16 MHz COM-00536
S1 Mini Pushbutton COM-00097
C1,C2 22 pF Capacitor COM-08571
C3,C4,C5 100 nF Capacitor COM-08375
R1 10K ohm Resistor COM-08374
R2,R3,R4 1K ohm Resistor COM-08980
LED1 Red LED COM-00533
Hook-up Wire (22AWG) PRT-08025
Table 1. BeAVR bill of materials.
build this first on a breadboard — which is about as open
as you can get — then next month, take the design to a
PCB. I had all sorts of fun building the prototype on a
breadboard. (And by fun I mean real pain and suffering.)
Since this is open source, you too get to share in the fun.
The BeAVR schematic shown in Figure 3 is much like
the BreadboArduino from last month with the ATmega328
swapped out for an ATmega644.
■ FIGURE 3.
May 2010 71