AVR Microcontrollers
Atmel have a very good range of AVR 8-bit microcontrollers which will run C quickly and are cheap, small & easy to use. The tool chain is good quality and free, it includes an extensive C library (see below). Most of these uPs operate off 1.8V - 5V supplies (but there are 2.7-5V variants, so check carefully which you order). See power supplies.
See this page for all you need to know to add an AVR microcontroller to a design.
Some of the newer devices (ATxMega) have 12 bit A->D & D->A peripherals, all devices have 10 bit A-D, timers, UARTs, etc. Check availability.
RAM size tends to be small (1K-4K) but bigger in the new ATxmega range, available 2Q 2009.
See Atmel for full device parametrisation. See Farnell for device availability & pricing.
For small designs consider the following, all have 1.8-5v supplies and most 28 pin PDIP (through-hole) packages for easy prototyping though surface mount versions and also packages with more pins are available. Also note the 2.7-5v variants which will run at double the clock speed.
Device | EEPROM | RAM | Flash | Price (1 off) | |
AtMega48PV-10PU | 512B | 1K | 4K | £1.68 | PDIP28 |
AtMega88PV-10PU | 512B | 1K | 8K | £2.32 | PDIP28 |
AtMega168PV-10PU | 512B | 1K | 16K | £2.68 | PDIP28 |
AtMega324PV-10PU | 1K | 2K | 32K | £4.19 | PDIP40 |
AtMega645V-8AU | 2K | 4K | 64K | £10 | 64 pin SMT |
See the GNU AVR LIBC documentation for a lot of AVR-specific useful functions. Specifically note: avr/interrupt.h, util/delay.h, math.h, avr/eeprom.h, avr.crc16.h
See the AVR HOWTO for Tool chain notes.
See the AVR LCD Howto for interface to LCD modules + sample code
See the AVR Serial Howto for sample serial link code for using UARTs
Hardware Interface
The table below lists the most common types of hardware interface required from a uP and notes solutions:
Interface | Standard solution |
Digital I/O | GPIO pins provide digital input and output. Inputs can have programmed pull-up resistors so switshes etc can be connected with no extra components. Outputs can drive LEDs etc. Normally maximum drive current is in logic 0 state but logic 1 drive can also be quite good. |
Interrupt | Interrupts from internal peripherals are available through software. If you need an external interrupt line make sure you find out which (normally just 1 or 2) GPIOs can be configured as external interrupt. |
A->D (high resolution) | Use external sigma-delta A->D e.g. 16 bit ADS1110. Note this will be slow, 100SPS or less. lower sample rates give higher resolution. Advantages are that this device is very easy to make work. Disadvantage it must use I2C see below. |
A->D (low resolution) | built-in A->D on AVR - 10 bits resolution |
D->A (slow) | PWM output from AVR,filtered, 12 bits + resolution |
D->A (fast) | 5 bits resolution - use resistors on GPIO pins high resolution - use separate DAC (not usually needed) |
Buttons | Use GPIO connected to nXm matrix of switches - no external components required - software scans switches. |
LEDs | drive single LEDs directly from GPIO |
LCD display | 16X2 (other sizes available) ASCII character display with standard 4
bit interface bus. See AVR LCD Howto. NB - All LCD modules require 5V supply. |
I2C (TWD) device | I2C AKA TWD bus is a 3 wire bus used by many peripheral
chips. AVR supports this but note that it is used for AVR programming
(ISP). Therefore if it is to be used for device interface AVR
programming should be done via JTAG instead or else a jumper used to
deselect any connected peripherals while the AVR is being programmed. The only disadvantage of JTAG is that it requires a larger header. |
GPIO expansion | Either get an AVR chip with more pins & GPIOs, or use I2C. I2C has the advantage that I/O expander chips can be placed on the board where required making routing easier. The daisy-chained serial interface signals are low cost. For example the PCF8574P is cheap and readily available, but requires 2.6-5v supply. Software interface to this is chip easy. |
USB interface | Use FTDI UM-232R DIP modules. Provide USB<-->serial link. 4 wire
connection to ARM with no additional hardware required. PC software
needs to interface to VCOM port (all languages can do this). See AVR Serial Howto for USART code that can drive a serial link. Note that AVR with built-in USB interface are also available. These will be more complex to use than FTDI module. |
Logic Level translation | 74HCT series CMOS logic on 5v has inputs which interface with CMOS
supplied down to 2.4v - this is an easy route for up conversion of
outputs. CD40109 - quad translator in DIP package, 3-5v->5-10v or 5-10V->3-5V. Will interface to Zigbit supplied at 3-3.3v but not work down to 1.8v. (In practice this may work down to 2.5V - try it to see). GTL2002 - dual voltage translator in tiny SMT package. 1.2v-10V ->1.2-10V (i.e. anything!). An 8 bit version of this device exists but only in a tiny SMT package with leads so close they will not be solderable - do not use this! See power supplies for more information |