ATmega128 Resources

This page has resources to get started on using the Atmel ATmega128 microcontroller. You will find a sample schematic, board layout, and source code, as well as information about the free software tools you can use to create your own board.

ATmega128 Development Board

The ATmega128 is a popular microcontroller for its generous program memory and RAM, as well as the typical hardware features you'd expect from an advanced microcontroller. The ATmega128 is also more expensive than your typical microcontroller, and is best suited for more advanced tasks such as a robot controller or an embedded webserver. If you don't need all of the features of the ATmega128, I recommend you check out the ATmega8.

Getting Started:

Your first stop should be the ATmega128 product datasheet (found on Atmel's website). Download it and make friends with it. Then navigate to BDMICRO's website and check out the MAVRIC-IIB. I highly recommend that board for any project it will fit in. Of course, you can design your own board (possibly for less), but the MAVRIC-IIB board also makes a great starting point when deciding what features you would like to include on your board. BDMICRO provides great documentation on their website, as well as excellent code samples. Finally, browse to to get the software and other resources for programming the Atmel series.

Programming your board:

You have some sample code now, but how do you compile it? How do you get the compiled program into your Atmel? You'll find plenty of options at the avrfreaks website, possibly too many. I recommend you start with the gcc-avr compiler. You can get it as part of the WinAVR package. WinAVR combines the most useful programming tools in a package for Windows. On Linux, you can use crossdev along with avr-libc to build for the AVR series, just as you would use the standard gcc tools to build applications for your computer. Be sure to check with your distribution to see if there's already a prepackaged solution for you. For example, Gentoo users emerge crossdev, then
crossdev --target avr
to build the avr environment. Linux users usually already have a prefered coding environment that they use for gcc. That same environment (vim, emacs, etc) will work just fine when coding for the AVR series. Commercial compilers also exist, but I think you'll find the gcc-avr compiler more than adequate.


The Atmega128 is usually programmed by In-System Programming (ISP) or with the JTAG interface. ISP is a great low cost solution to programming your microcontroller. You can get an ISP programming cable around $12 from Spark Fun Electronics that works with the free program, PonyProg2000, available on Windows and Linux. Both serial and parallel versions are available. If you don't have a serial port on your computer, don't bother with a USB to serial adapter - more than likely it won't work! With the ISP programmer you can read, program, and change fuse (config) bits on your microcontroller. The ISP cable, however, does not allow for debugging. For debugging your code interactively, you'll need to use the JTAG interface. Spark Fun also has JTAG programmers. JTAG programmers do everything ISP programmers can do, and also allow stepping through your code. The JTAG programmers start at around $50, but some work on USB in case you have a laptop without those precious ports. I recommend you start with the ISP cable, because it's inexpensive. Output to an LCD screen for debugging. An LCD screen is more useful on a robot where your controller board cannot always be tethered to your computer for debugging:

Hitachi HD44780 LCD

LCD screens are inexpensive, you can find them for less than $10 with a nice backlight. Look for Hitachi HD44780 compatibles with an LED backlight, positive contrast voltage, STN type display. Those work and look the best. Here is some source code for a Hitachi compatible display:

lcd.c source file
lcd.h source file

The source files can be included in your projects and compiled by the gcc-avr compiler. Please read the source carefully and change the PORTA define statement to the port your display is attached to on your ATmega128.

Designing your own board:

If you must design your own board (I know how you feel), you'll need some CAD software. There are several free choices, but I highly recommend EAGLE. This excellent software is available in a free version for non-profit use on the Linux, OSX, and Windows platforms. Like any CAD software, there is a steep learning curve, but it's worth it. Don't bother with the tutorial, download the full manual and keep it handy. With EAGLE, you can download and view the development board I created on the top of this page:

devboard schematic (EAGLE format)
devboard board layout (EAGLE format)

I still recommend you start by looking at the schematic for the MAVRIK-IIB board because it's a little simpler, but you may find some useful ideas on mine as well. If you design and build your own board, you'll need to set the fuse (config) bits on the ATmega128 the first time you program it. Here's what you should see in PonyProg2000 to correctly program a board running at 16MHz.

I hope this page provided a useful starting point in your ATmega128 project. If you are building a robot, be sure to check out my Autonomous Robot FAQ and motor driver boards! You can email me at dubel at ufl dot edu to report errors or request additional information.

June 18, 2005 William Summerfield Dubel IV