
Connecting the Orangutan to a Computer
Programming the Orangutan X2
Running the Orangutan X2
The mega168 microcontroller is the programmer for the main mega644 MCU. The mega168 performs this function by emulating an
AVRISP programmer, which connects to a computer serial (COM) port and programs AVR microcontrollers via the SPI (serial peripheral
interface) port. Instead of a standard serial port, the Orangutan X2 uses a USB-to-serial bridge that allows a USB connection to look like a
COM port. Before connecting the Orangutan X2 to a computer, the driver must be installed to allow the computer’s operating system to
treat the USB connection as an old-fashioned serial connection. The driver and installation instructions are available on the Orangutan X2
web page.
Once the USB-to-serial driver is installed and the Orangutan X2 is connected, the mega168 can communicate with the computer through its
serial port, and the green LED next to the USB connector will be lit. When programming the mega644, the Orangutan X2 will look like an
AVRISP programmer; during normal operation, the mega168 can send and receive data to or from the computer (e.g. using a terminal
program) for debugging or other purposes.
The Orangutan X2 can be programmed using any platform for which there is a USB driver and for which there is AVRISP-compatible
programmer software. We recommend using Atmel’s AVR Studio, an integrated development environment (IDE) that works with the free
GCC C compiler and includes a simulator and other useful tools, includingAVRISPsupport.
To enter programming mode, hold down the reset/programming button (next to the USB connector) for more than half a second. The
buzzer will beep, and the yellow LED will turn on, indicating that you have entered programming mode. The mega168 will no longer
respond to commands from the mega644, and it will wait for programming commands from the computer via the USB connection. When
programming is in progress, the red LED will be lit. When programming completes, the mega644 is allowed to execute, but the mega168
will remain in programming mode until the reset button is pressed.
It is also possible to set the mega168 to always look out for programming commands. In that state, normal serial port use is unavailable, and
any incoming serial data is treated as coming from the computer programming software. When programming is requested, the mega168
will program the mega644 and then reset itself and the mega644, allowing full operation to resume immediately upon completion of
programming.
When programming the mega644, access to some fuse settings is not available. The most important setting is the clock source setting since
the mega644 must be set for an external resonator, and the mega644 provides a 20 MHz clock to the mega168. In general, the fuses should
only be changed rarely and with great care since the Orangutan X2 could become unresponsive.
Using the Orangutan X2 is generally identical to using any other mega644-based project, and most of the mega644’s resources are available
to the user. The exceptions are the reset system and the SPI port, which are connected to the mega168.
Because the mega168 and mega644 need to stay synchronized, it is not desirable to reset the mega644 independently. The reset button does
not connect directly to either processor’s hardware reset line. Instead, the mega168 monitors the reset button and determines when to reset
itself or the mega644. Typically, the mega168 will reset both processors, keep the mega644 reset while it initializes, and then finally allow
the mega644 to begin execution. The reset button will not work during programming.
The SPI port is the main connection between the two MCUs. During programming, the mega168 becomes the master; during normal
operation, the mega644 is the master and sends the mega168 commands via the SPI interface. The default setup of the Orangutan X2
assumes no other use of the SPI lines (the mega168’s slave-select line is pulled down by a resistor). The SS line can instead be connected to
one of the mega644 I/O lines, and the mega644 can then control multiple slave devices on the same SPI lines. It can also be desirable to use
the SS line even without additional SPI devices since the SS line provides added robustness to the protocol.
The mega644 to mega168 SPI interface is detailed in a separate document; please see the Orangutan X2 web page for more details.
Reset
SPI Port
© 2007 Pololu Corporation
http://www.pololu.com/
Pololu page 4 of 6 org03a