avr main =>
how-to => AVR type selection
(Diese Seite in Deutsch:
How-to select an optimal AVR type for my hardware needs
Arduino-owners and -users do not need to read this. The answer to
the question is always and in any case ATmega328 for them. So you
Arduino-addicted people: stop reading, otherwise you might run into
trouble, as you will learn some things that you might have thought
that those are not possible with your Arduino.
The others, that want use their own brain instead, have a problem
here: Do I have to download hundreds of device handbooks and read
through thousands of pages to just find out, which of the several
hundred AVR types fit my needs best? No. There is a simpler tool
that allows to find that out. It is the AVR simulator avr_sim,
available here as
Windows- or Linux-executable or as Lazarus source code, to be
compiled on your own.
1 Starting the device-selector
After starting avr_sim you'll see this window (or a similar screen).
The menu is small, only two entries. And of course, the first entry
"Project" is the one you'll need. If you click the entry
"New" as sub-menu of "New" the following window
The marked button starts the device-selector. And this looks like this:
This window has lots of entry fields:
- To the left above you can select from which of the several
AVR types the selector shall choose from. if you click on
"Select all", you'll get lots of more AVR types
in the window in the middle.
- Below that the "Package" selection allows to
select from the package types you want to work with.
- Below that the "Required properties" with lots
of different entries spans. Some of those are discussed in
- The window in the middle lists all types of AVRs that
are compatible and fulfill all the selected requirements.
The button "Show failed" below the list allows
you to inspect why some AVR types are not listed any more
and which (first) criterion wasn't fulfilled.
If you click on a certain AVR type in the list, here an
ATtiny4 in a SOT package, you'll see its pin assignments
in the window on the right. If no assignment has been
made yet, the possible pin assignments appear in capital
letters, separated by blanks. Assigned pins, such as the
VCC, GND and RESET pin, appear as "Vcc",
"Gnd" and "Reset" and only the assigned
2 Selecting clock options
If we assume we want to build a clock. In that case we need an
external crystal or an external crystal oscillator, because the
internal RC oscillator is inaccurate for that purpose. In that
case we click into the "Required hardware properties"
window ande here onto the needed "Clock options":
either we select "External oscillator" or "External
crystal". This removes all types of AVRs from the list that
do not have an "XTAL1" or, in case of an external crystal,
do not have an "XTAL2" pin as well. "Show failed"
and the button "Remove package messages" shows all these
Below the criterion list the window shows all those AVR types that
do not have both XTAL pins.
This is a suitable example how fast and simple the device-selector
has found this out, without the need to consult more than hundreds
of device handbooks.
In all types that we can select by clicking the list in the middle
now have the pins XTAL1 and XTAL2 assigned to this function, all
other potential assignments do not appear any more.
3 Assigning I/O-pins
Three different options allow to assign I/O-pins and their in- and
This assignment is not so trivial as it looks like, especially if
single pins in a port are already assigned to another function, which
cannot be moved to another pin location.
- 8-bit-I/O: This assigns one or more complete I/O-ports to be
I/O. All other potential assignments do not appear any more.
- 4-bit-I/O: This assigns one or more 4-bit-nibbles as I/O,
which can be either in the lower or in the upper half of a port.
- 1-bit-I/O: This assigns one or more single pins to be I/O.
These pictures show the potential original pin assignments on the
left and one single I/O pin, the two different assignments of a
4-bit-port and an 8-bit-port.
The two different assignments of the 4.bit-port were achieved
by setting the ISP pins Mosi, Miso and Sck as exclusive. This
forces the selector to place the 4-bit-port to the lower nibble
in port A.
4 Assigning external interrupts
Two types of external interrupts are possible: Ints and Pcints.
Both can be assigned, but both are different. Ints are fixed
to certain pins, while Pcints can be moved.
Assigning Pcints, if more than one Pcint channel is available,
selects pins in all available channels until the number of needed
Pcints is assigned (if those are not already blocked by other
5 Other functions
There are more functions that can be applied:
- minimum sizes of flash memory, EEPROM and SRAM can be
- needed AD-conversion channels,
- Timer-pins for compare match switching for A (OCnA) and
B (OCnB) as well as Timer input pins (Tn) can be required,
- up to two UARTs and sync-serial-interfaces can be required,
- Analog-comparer, and
- AC- and DAC-output pins can be required.
6 Combinations of all
Of course, all named requirements can be selected in parallel,
and are assigned by the selection algorithm. Here, the
following combination has been selected:
Those who can do all that faster with a paper and a pencil
can contact me.
- one external Int,
- exclusive ISP pins,
- an external crystal as clock,
- one 8-bit-port, one 4-bit-port and numerous single I/O pins,
- a few AD-converter pins,
- one analog comparer,
- an 8-bit-Timer/Counter with output on A,
- a UART with RX and TX.
Much success by selecting your personal optimal AVR type. With
the opportunity to copy all those windows to the clipboard or to
copy the whole window as screenshot, you can document the
selection process and you can use these information later on.
To the top of that page, to the Q+A page
©2021 by http://www.avr-asm-tutorial.net