Programming
The
ATmega2560
on the Arduino MEGA ADK comes pre-burned with a
bootloader
(the same
on Mega 2560) that allows you to upload new code to it without the use of an external
hardware programmer. It communicates using the original
STK500v2
protocol (reference,
C
header files).
You can also bypass the boot
loader and program the microcontroller through the ICSP (In-
Circuit Serial Programming) header using
Arduino ISP
or similar; see
these instructions
for
details.
The
ATmega8U2
firmware source code is available
in the Arduino repository.
The
ATmega8U2
is loaded with a DFU boot
loader, which can be activated by:
On Rev1 boards: connecting the solder jumper on the back of the board (near the map of
Italy) and then resetting the 8U2.
On Rev2 or later boards: there is a resistor that pulling the 8U2/16U2 HWB line to ground,
making it easier to put into DFU mode. You can then use
Atmel's FLIP software
(Windows) or
the
DFU programmer
(Mac OS X and Linux) to load a new firmware. Or you can use the ISP
header with an external programmer (overwriting the DFU boot
loader).
Automatic (Software) Reset
Rather then requiring a physical press of the reset button before an upload, the Arduino
MEGA ADK is designed in a way that allows it to be reset by software running on a connected
computer. One of the hardware flow control lines (DTR) of the
ATmega8U2
is connected to
the reset line of the
ATmega2560
via a 100 nanofarad capacitor. When this line is asserted
(taken low), the reset line drops long enough to reset the chip. The Arduino software uses
this capability to allow you to upload code by simply pressing the upload button in the Arduino
environment. This means that the bootloader can have a shorter timeout, as the lowering of
DTR can be well-coordinated with the start of the upload.
This setup has other implications. When the MEGA ADK is connected to either a computer
running Mac OS X or Linux, it resets each time a connection is made to it from software (via
USB). For the following half-second or so, the bootloader is running on the MEGA ADK.
While it is programmed to ignore malformed data (i.e. anything besides an upload of new
code), it will intercept the first few bytes of data sent to the board after a connection is
opened. If a sketch running on the board receives one-time configuration or other data when
it first starts, make sure that the software with which it communicates waits a second after
opening the connection and before sending this data.
The MEGA ADK contains a trace that can be cut to disable the auto-reset. The pads on
either side of the trace can be soldered together to re-enable it. It's labeled "RESET-EN".
You may also be able to disable the auto-reset by connecting a 110 ohm resistor from 5V to
the reset line; see this forum thread for details.
www.ekt2 .com
Electronics
Katrangi
Trading