ATmega16 AVR Training Kit Notes

ATmega16 Development Board (Futurlec)
with I/O expansion components fitted in prototyping area

2-line x 16-char LCD panel (Futurlec)
and 4x4 keypad (Jaycar)

These notes form part of a documentation package describing the assembly and operation of a micro-controller training kit. The package is intended for hobbyists and students learning electronics technology and/or embedded programming (firmware development).

The kit is designed around a pre-built micro-controller development board based on Atmel's ATmega16 AVR processor. The board is available from Futurlec. With the addition of an LCD panel and 16-button keypad, plus a few sundry components, a complete ATmega-AVR training setup can be assembled with little effort and at low cost. Basic soldering skills are necessary to wire up the "I/O breakout" circuits.

The ATmega16 board has a 34-pin header with all MCU port I/O signals available (except PD0 and PD1 which are dedicated to UART RX and TX). An identical connector in the user prototyping area of the board allows the I/O signals to be bridged to the peripheral components (7-segment LED, LCD panel, keypad, beeper, etc) via a short ribbon cable. The MCU board may then be used for a different purpose simply by disconnecting the ribbon cable bridging the two 34-pin headers. If/when the prototyping area is no longer needed, it may be removed from the main PCB using a hack-saw. Alternatively, you can save some time and effort by wiring the I/O expansion components and connectors (in the prototyping area) directly to the existing 34-pin port I/O header (pads on underside of the board), i.e. by not fitting a second 34-pin header in the prototyping area.

The Futurlec LCD panel connector strip should be wired 1:1 to a 16-way IDC connector via a short length of 16-core ribbon cable. Pin 1 is clearly marked on the LCD panel. Pins 15 and 16 are not connected -- these are reserved for a 5V back-light, which is not provided on the Futurlec part -- so you can use 14-core ribbon cable if you have some instead. Use a 16-core ribbon cable if you are using a different LCD panel which has backlight.

The "I/O breakout" schematic shows a 2.2k trimpot wired in series with a 6.8k fixed resistor for LCD contrast adjustment. These component values are not critical -- you can use a 2k or 5k trimpot with a 5.6k resistor. Most of the LCD contrast adjustment is in the range 0 ~ 1V, which is why I used a resistor in series with the trimpot. Most circuits I have seen use a 10k trimpot with no series resistor, but this makes the adjustment a bit too touchy.

To save the cost of a plug-pack power supply and to avoid the inconvenience of needing it, the ATmega16 board can be easily modified to be powered from a USB port on your PC. Remove the bridge rectifier (WO4), diode (IN4001), 5V regulator (7805) and heatsink from the board. Get a cheap USB cable (standard "A-B" type) and cut off the "B" connector at the "device" end. (The "A" connector is the flat one which plugs into the PC port.) Strip off about 25mm of the outer PVC sleeve and screen to reveal the four inner wires. The green and white wires are not needed, so trim them back. The black wire should be GND (0V) and the red wire should be VBUS (+5V). The black wire is connected to a GND point and the red wire is connected to Vcc (+5V) on the board. The cable may be soldered directly to the board, or you can fit a DC plug to the cable to match the DC input socket on the board. In this case, you need to solder some links on the board to connect the DC socket pads to GND and Vcc points. Wire links may be conveniently soldered onto pads left vacant by the removed components. Be careful not to accidentally plug a 12V PSU into the 5V input socket, as this will surely destroy the MCU and other chips!

Programming the ATmega16 chip

The ATmega16 board from Futurlec has a 10-pin box header for connection of a programming module, e.g. Atmel AVR-ISP mkII (~US$50), which plugs into a PC USB port. There are cheaper USB "ISP" programming devices available from various sources, some compatible with Atmel AVR Studio IDE, others not. Some require a special PC software utility, usually supplied with the device. Before buying a "3rd party" programming device, check with the supplier that the ATmega16 chip is supported by the device.

If you have access to a PC with a "real" parallel port*, there is no need to buy a programming module. The ATmega16 board comes with a parallel programming adapter/cable which connects directly to the PC parallel port. A freeware PC utility called "PonyProg" can be used to program the ATmega16 chip. *NB: USB-to-parallel (and USB-to-serial) adapters will not work with PonyProg.

Download PonyProg2000 utility here

Be sure to read all of the documentation provided before attempting to program the ATmega16 chip!

Contents of ATmega-AVR Training Kit documentation package

[* NB: Photo of LCD panel is upside-down in datasheet from Futurlec! Photo at top of this page is right way up.]


Alternative I/O port allocations

The keypad uses Port B; so does the SPI in-system programming (ISP) interface. The keypad will not interfere with programming, hence may remain connected, as long as keys are not pressed during program loading. There is a 'TEST' LED on the Atmega16 board connected to pin PB0 via a jumper header. The keypad uses PB0 as an input, so the LED is unlikely to interfere with keypad operation, but it is probably wise to disconnect the LED (i.e. remove the jumper).

If your application needs additional I/O capacity, the keypad may be disconnected from the Port B header giving access to the SPI bus (alternative pin functions for port B). The lower 4 bits of port B (PB0..PB3) may be used for SPI "slave-select" signals. An I/O expansion board interfaced to the SPI bus can provide a large number of additional I/O ports. Output ports can be implemented using serial-in-parallel-out (SIPO) shift registers (e.g. 74HC595); input ports using parallel-in-serial-out (PISO) shift registers (e.g. 74HC165).


Testing the completed hardware setup

A test program is provided to test the completed hardware setup including keypad and LCD panel. Load the test program (Keypad_LCD_test.hex) into the ATmega16 using whatever programming tool you have available. Disconnect the programming cable from the board after loading the code and press the RESET button.

After reset, the LCD panel should show "AVR Training Kit" on the upper line, with "Press DEBUG btn." on the lower line. (Adjust LCD contrast for optimum view.) The DEBUG LED should be lit. The 7-segment LED should be blank.

Press and release the BOOT/DEBUG button. The DEBUG LED should turn off and the LCD should show "Test keypad now" on the lower line. When a key is pressed, the corresponding number or letter should show on the 7-segment LED digit, and the beeper should make a short beep. While a key is held down, the decimal point (on 7-seg LED) should be lit. Keys 'B' and 'D' are represented in lowercase, i.e. 'b' and 'd'. The '#' key is represented by '=' and the '*' key is represented by an inverted 'u' (top 3 segments lit). The program remains in the keypad test loop until reset.


'AVROS' - AVR Operating System with resident debug facilities

Also available from the author is a C source code framework intended as a starting point for developing AVR firmware applications, using WinAVR (GNU AVR-GCC) under AVR Studio. AVROS uses the serial port (UART) for debug communications. A simple command set is provided to access MCU memory (program and data), registers and I/O ports. The generic target platform is the ATmega16, but the code is easily adaptable to other members of the ATmega-AVR microcontroller family. AVROS is a "work in progress" and should continue to evolve.

Download 'AVROS' V1.1 here


Author: M.J.Bauer :: www.mjbauer.biz :: Copyright 2011