Avr Microcontrollers

A series of 8-bit RISC microcontrollers (MCUs or micros) from Atmel. The MCU used on ArduinoBoards. Supported by an open toolchain, see AvrBuild and AvrProgrammer.

ATtiny series

Small packages and less I/O.

ATtiny24/44/84

               o
         VCC 1 - 14 GND
D0/XTAL1/PB0 2 - 13 PA0/AREF/D10(A0)
D1/XTAL2/PB1 3 - 12 PA1/AIN0/D9/A1
RESET/PB3    4 - 11 PA2/AIN1/D8/A2
D2/PB2       5 - 10 PA3/T0/D7/A3
D3/A7/PA7    6 - 9 PA4/USCK/SCL/D6/A4
D4/A6/PA6    7 - 8 PA5/DO/MISO/D5/A5

ATtiny25/45/85

                       o
D5/A0/RESET/ADCO/PB5 1 - 8 VCC
D3/A3/XTAL1/ADC3/PB3 2 - 7 PB2/SCL/SCK/D2/A1
D4/A2/XTAL2/ADC2/PB4 3 - 6 PB1/MISO/D1
GND                  4 - 5 PB0/MOSI/SDA/AREF/D0

ATtiny2313/4313

               o
RESET/PA2    1 - 20 VCC
D0/RXD/PD0   2 - 19 PB7/SCL/SCK/D16
D1/TXD/PD1   3 - 18 PB6/MISO/D15
D2/XTAL2/PA1 4 - 17 PB5/MOSI/SDA/D14
D3/XTAL1/PA0 5 - 16 PB4/D13
D4/PD2       6 - 15 PB3/D12
D5/PD3       7 - 14 PB2/D11
D6/PD4       8 - 13 PB1/AIN1/D10
D7/PD5       9 - 12 PB0/AIN0/D9
GND         10 - 11 PD6/D8

ATmega series

Bigger package and more I/O including ADC.

ATmega48/88/168/328

Used in most ArduinoBoards.

              o
 RESET/PC6  1 - 28 PC5/SCL/A5
 D0/RXD/PD0 2 - 27 PC4/SDA/A4
 D1/TXD/PD1 3 - 26 PC3/A3
 D2/PD2     4 - 25 PC2/A2
 D3/PD3     5 - 24 PC1/A1
 D4/PD4     6 - 23 PC0/A0
 VCC        7 - 22 GND
 GND        8 - 21 AREF
 XTAL1/PB6  9 - 20 AVCC (need to be within 0.3V of VCC)
 XTAL2/PB7 10 - 19 PB5/SCK/D13
 D5/PD5    11 - 18 PB4/MISO/D12
 D6/PD6    12 - 17 PB3/MOSI/D11
 D7/PD7    13 - 16 PB2/D10
 D8/PB0    14 - 15 PB1/D9

ATmega1280

Ports and Registers

In the pinout diagrams above Ax and Dx represent Arduino analog and digital pins respectivly in case it is used. Arduino on ATtiny is a separate project and not included in the official Arduino release. How to control the pins via Arduino won't be discussed here. It is well documented in http://arduino.cc/en/Reference/HomePage.

All else is AVR pin names as in the datasheets. AVR pins are organized in ports named A to D. Which ports/pins actually exist depend on the type of AVR in use.

Every port has 3 registers associated with it, DDRx, PINx, PORTx. Substitute x with A through D. These are used to control the pins.

                       DDRx.n
                          |
                          v
                         /-|
MCU Pin n of Port x ----<  |<-- PORTx.n
                      |  \-|       |
                      |            |
                      |  VCC       |
                      |   |        |
                      |   \        |
                      |    \ <-----/ (1 closes switch)
                      |   o
                      |   |
                      |   -
                      |   R (pull-up resistor)
                      |   -
                      |   |
                      \--------> PINx.n

The possible combinations can be arranged in a table:

                DDRx = 0            DDRx = 1
PORTx = 0        high-Z             output 0
PORTx = 1    read with pull-up      output 1

http://www.embedds.com/controlling-avr-io-ports-with-avr-gcc/

The ATMega MCUs also have analog input and output via a built in ADC (Analog-Digital Converter). The different analog pins are multiplexed to the same ADC.

http://www.avrfreaks.net/forum/tut-c-newbies-guide-avr-adc?name=PNphpBB2&file=viewtopic&t=56429

Interupts

PWM Pins

http://aquaticus.info/pwm-configuration


[ AvrIndex | AvrBuild | AvrProgrammer | AvrAssembly ]


[ IndexPage | Edit on Github | Powered by PotBliki | © 2010-2014 Daniel Hjort - CC BY-SA 3.0 | http://danielhjort.net ]

blog comments powered by Disqus