Você está na página 1de 2

ATmon - bootloader and monitor for ATmega32 by Marek Smid

ATmon is a bootloader and monitor tool for the Atmel ATmega32 microcontroller. It
consists of two parts: bootloader program for the MCU itself written in assembly, and a
Java application to be run on a PC for monitoring and programming the MCU. You need:
• BootLoader8.hex or bootloder16.hex
• RXTX library
• ATmon.jar
• m32def.inc
RXTX is a library for Java providing support for the serial port. (There is RXTX
homepage.) Windows users need to:
• copy RXTXcomm.jar from RXTX zip-file root to /jre\lib\ext/
• copy rxtxSerial.dll from RXTX zip-file windows directory to /jre\bin/

The "jre" directory is the root directory of Java Runtime Environment, and may look like:
C:\Program Files\Java\jre1.5.0_06. Download ATmon to an arbitrary directory on your
PC. You should be able to run it just by double-clicking it. In case it does not work, set
the correct action for JAR extension (Folder options / File Types), or you may use this
batch file put into the same directory. The bootloader has to be written to the MCU using
an ISP. Run AVRStudio and just open the AVR programmer without loading any project.
In the Flash box, select the downloaded Bootloader8.hex or bootloader16.hex, and
program it. The bootloader you use depends on the frequency of the crystal used by your
board. The frequency is written on the side of the crystal can. It will either specify
16.000MHz or 8.000MHz. Obviously, use bootloader16.hex for the 16MHz crystal or
bootloader8.hex for the 8MHz crystal. The bootloader communicates using baud-rate of

On the Fuses tab, select the following options, and program it:

• Boot Flash section size = 1024 words

• Boot reset vector enabled
• The clock fuse settings depend on the type of clock provided on your board.

1. For SunRom (CE2800) boards use Ext. Crystal/Resonator High

Freq: Start-up time 16CK + 4ms

2. For boards that have no clock provided use Int. RC Osc. 8 MHz

3. For boards with a crystal controlled clock oscillator use Ext. Clock
but only if the frequency is 8MHz. Otherwise, use Int. RC Osc. 8

On the Lock Bits tab, select the following option, and program it:

• Boot Loader Protection Mode 2: SPM prohibited in Boot Loader Section

Because the bootloader needs a few bytes of memory for itself, which are located at the
end of SRAM, the stack pointer initialization needs to be modified in order to skip these
bytes. You can either:

• In your stack initialization (ldi r16, low(RAMEND); out SPL, r16; etc...), replace
"RAMEND" with "RAMEND-0x20"
• Put the downloaded m32def.inc to your project folder.
This way, when you use directive .include "m32def.inc", the assembler will include the
local include file, instead of the default for the assembler.