Introduction to Atmega 8/16/32

AVR was developed by  Atmel in 1996 as a single chip microcontroller. AVR is a family of 8-bit  microcontrollers that are based on modified Harvard architecture of type RISC(Reduced Instruction Set Computer) which works on executing simplified instructions in a regular clock cycle following a pipelining approach.

Classification of AVR series:

tinyAVR – the ATtiny series

  • 5–16 KB program memory
  • 6–32-pin package
  • Limited peripheral set

megaAVR – the ATmega series

  • 4–256 KB program memory
  • 28–100-pin package
  • Extended instruction set (multiple instructions to handle large memory operations)
  • Extensive peripheral set

XMEGA – the ATxmega series

  • 16–384 KB program memory
  • 44–64–100-pin package (A4, A3, A1)
  • 32-pin package: XMEGA-E (XMEGA8E5)
  • Extended performance features like DMA, “Event System”, cryptography 
  • Extensive peripheral set with ADC

ATMega 16:

It is essential to first understand the Pin Out diagram of ATMega 16.

Features of Atmega16

I/O and Packages

  • 32 Programmable I/O Lines
  • 40-pin PDIP

Power Consumption @ 1 MHz, 3V, and 25°C for ATmega16L

  • Active: 1.1 mA
  • Idle Mode: 0.35 mA
  • Power-down Mode: < 1 µA

Peripheral Features

  • Two 8-bit Timer/Counters with Prescalers & Compare Modes
  • One 16-bit Timer/Counter with Prescaler, Compare Mode, and Capture Mode
  • Real Time Counter with Oscillator
  • Four PWM Channels
  • 8-channel, 10-bit ADC
  • 8 Single-end Channels
  • 7 Differential Channels in TQFP Package Only
  • 2 Differential Channels with Programmable Gain at 1x, 10x, or 200x
  • Byte-oriented Two-wire Serial Interface
  • Programmable Serial USART
  • Master/Slave SPI Serial Interface
  • Programmable Watchdog Timer with Separate On-chip Oscillator

In order to connect AVR microcontroller with a PC for programming, an AVR programmer is required i.e. USBASP.

The programmer consists of a USB cable used to connect with PC/laptop and an SPI cable used to connect to the MUC.

Programmer Pins:

  • MISO (Master Input Slave Output)
  • MOSI (Master Output Slave Input)
  • SCK (Serial Clock)
  • RST (Reset)  
  • VCC (+5 v)
  • GND(0 v)

AVR Registers

All ports of AVR are 8-bit long and every port consists of three registers. Each constituting bit in these registers configure pins of the particular port.

In each register, Bit0 is associated with Pin0 of the port, Bit1 is associated with Pin1 of the port, it goes like wise for all other bits.

The three registers that comprise one port are as follows:

  • DDRx register
  • PORTx register
  • PINx register

Here, x can be replaced by A, B, C, and D as per the Port being used.

DDRX

DDRX are Data Direction Registers that perform the function of configuring the Pins as either input or output.

‘1’ implies that the corresponding pin is configured as output.

‘0’ implies that the corresponding pin is configured as input.

Let’s take an example:

DDRx=0b00010011

Here, the 1st,2nd,and 5th pin of PORT X have been configured as output, while the remaining pins have been configured as input i.e. these are ready to accept data.

PORTX

Ports are directly connected to the pins. If the corresponding DDR pin is configured as output, then these registers are used to provide value to the connected device (such as LEDs, Motors etc.).

Eg: If you want to pass ‘1’ at 5th pin of X PORT of the microcontroller which is connected to a device(LEDs/Motors),  it should be set as:

                                    PORTx=0b00010000;

But, before passing this value the 5th pin of X port should be configured as an output using the DDR of the PORT.

PINX

If the DDR pin is configured as an input, then these registers are used for deriving the value from the connected device (such as sensors).

Eg: If you want to read ‘1’ at 5th pin of X PORT of the microcontroller which is connected to a device (sensors), it should be set as:

                                 PINx=0b00010000;

But, before reading the value from the 5th pin of X port, the corresponding pin should be configured as an input using the DDR of the PORT.

0 Comments

Leave a Reply

Your email address will not be published. Required fields are marked *