Types of AVR Microcontroller – Atmega32 & ATmega8

ATmega32 – 8 Bit AVR Microcontroller

The AVR microcontrollers are based on the advanced RISC architecture. ATmega32 is a low power CMOS 8-bit microcontroller based on the AVR enhanced RISC architecture. AVR can execute 1 million instructions per second if cycle frequency is 1MHz.


40 pin DIP Photograph of ATmega32
40 pin DIP Photograph of ATmega32

Key Features:

  • 32 x 8 general working purpose registers.
  • 32K bytes of in system self programmable flash program memory
  • 2K bytes of internal SRAM
  • 1024 bytes EEPROM
  • Available in 40 pin DIP, 44 lead QTFP, 44-pad QFN/MLF
  • 32 programmable I/O lines
  • 8 Channel, 10 bit ADC
  • Two 8-bit timers/counters with separate prescalers and compare modes
  • One 16-bit timer/counter with separate prescaler, compare mode and capture mode.
  • 4 PWM channels
  • In system programming by on-chip boot program
  • Programmable watch dog timer with separate on-chip oscillator.
  • Programmable serial USART
  • Master/slave SPI serial interface

Special Microcontroller Features:

  • Six sleep modes: Idle, ADC noise reduction, power-save, power-down, standby and extended standby.
  • Internal calibrated RC oscillator
  • External and internal interrupt sources
  • Power on reset and programmable brown-out detection.
40-Pin DIP of ATmega32
40-Pin DIP of ATmega32

All the 32 registers are directly connected to the Arithmetic Logic Unit (ALU), allowing two independent registers to be accessed in one single instruction executed in one clock cycle.

The power-down saves the register contents but freezes the oscillator. All other chip functions will be disabled until the next external interrupt arises. Asynchronous timer allows the user to maintain a timer based in power-save mode while the rest of the device is sleeping.

ADC noise reduction mode stops the CPU and all I/O modules except ADC and asynchronous timer. In standby mode, except crystal oscillator the rest of the device is sleeping. Both the main oscillator and asynchronous timer continue to run in extended standby mode.

ATmega32 is a powerful microcontroller because of its in system self programmable flash on a monolithic chip, provides a high flexible and cost effective solution to many embedded control applications.

PCBWay
44-pad TQFP/MLF
44-pad TQFP/MLF

 

Pin Descriptions:

VCC: Digital voltage supply

GND: Ground

Port A (PA7-PA0): This port serves as analog inputs to the A/D converter. It also serves as an 8-bit bidirectional I/O port if the A/D converter is not used.

Port B (PB7-PB0) & Port D (PD7-PD0): It is an 8-bit bidirectional I/O port. Its output buffers have symmetrical drive characteristics with both high sink and source capability. As inputs, these are extremely pulled low if the pull-up resistors are activated. It also serves various special function features of the ATmega32.

Port C (PC7-PC0): It is an 8-bit bidirectional I/O port. If the JTAG interface is enabled, the pull-up resistors on pins PC5 (TDI), PC3 (TMS), and PC2 (TCK) will be activated.

Interfacing of JTAG using port C of ATmega32
Interfacing of JTAG using port C of ATmega32

Reset: It is an input.

XTAL1: It is an input to the inverting oscillator amplifier and input to the internal clock operating circuit.

XTAL2: It is an output from the inverting oscillator amplifier.

AVCC: It is the supply voltage pin for Port A and A/D converter. It should be connected to VCC.

AREF: AREF is the analog reference pin for the A/D converter.

ATmega32 Memories:

It is having two main memory spaces data memory and the program memory space. In addition it features an EEPROM memory for data storage.

In System Programmable Flash Program Memory:

ATmega32 contains 32Kbytes on-chip in system reprogrammable flash memory for program storage. Flash is organized as 16k X 16 and its memory is divided into two sections Boot program section and application program section.

ISP programmer circuit diagram
ISP Programmer Circuit Diagram

SRAM Data Memory:

The Register file, I/O memory, and the internal data SRAM are addressed by the lower 2144 data memory locations. The first 96 locations address the Register file and I/O memory, and the internal data SRAM is addressed by the next 2048 locations. Direct, indirect with displacement, indirect, indirect with pre-decrement, and in-direct with post decrement are the 5 different addressing modes for the data memory covering. The 32 general purpose registers, 64 I/O registers, and 2048 bytes of internal data SRAM are accessible by using these addressing modes.

Block diagram of ATmega32
Block diagram of ATmega32

EEPROM Data Memory:

It contains 1024 bytes of data EEPROM memory. It can be accessed as a separate data space in which single bytes can be read and written.

I/O Memory:

All I/Os and peripherals are placed in the I/O space. The I/O locations are accessed by the IN and OUT instructions, transferring the data between the 32 general purpose registers and the I/O space. I/O registers with in the address 00-1F are directly bit accessible using the SBI and CBI instructions.

ATmega8

Introduction

It is an 8 bit CMOS built microcontroller from the AVR family (developed by Atmel Corporation in 1996) and is built on the RSIC (Reduced Instruction Set Computer) architecture. Its basic advantage is it doesn’t contain any accumulator and the result of any operation can be stored in any register, defined by the instruction.

Architecture

Architecture
Architecture

Memory

It consists of 8KB of flash memory, 1KB of SRAM and 512 Bytes of EEPROM. The 8K flash is divided into 2 parts- lower part used as boot flash section, and upper part used as application flash section. The SRAM contains 1K bytes along with 1120 bytes of general purpose registers and I/O registers.  The lower 32 address locations are used for 32 general purpose 8 bit registers. The next 64 address are used for I/O registers. All the registers are connected directly to the ALU. The EEPROM is used to store user defined data.

Input/output ports

It consists of 23 I/O lines with 3 I/O ports, named B, C and D. Port B consists of 8 I/O lines, Port C consists of 7 I/O lines and Port D consists of 8 I/O lines.

Registers corresponding to any portX(B,C or D) are:

DDRX: Port X data direction register

PORTX: Port X data register

PINX: Port X input register

Timers and Counters

It consists of 3 timers with comparable modes. Two of them are 8 bit whereas the third one is 16 bit.

Oscillators

It incorporates internal reset and oscillator which makes it possible to eliminate the need for any external input. The internal RC oscillator is capable of generating internal clock which can run at any frequency of 1MHz, 2MHz , 4MHz or 8MHz as programmed. It also supports external oscillator with maximum frequency of 16MHz.

Communication

It provides both synchronous and asynchronous data transfer schemes through USART(Universal Synchronous and Asynchronous Receiver Transmitter), i.e. communication with modems and other serial devices. It also supports SPI(Serial Peripheral Interface) used for communication between devices based on the master-slave method. Another type of communication supported is the TWI(Two wire Interface). It allows commutation between any two devices by using 2 wires along with a common ground connection.

It also has a comparator module integrated in the chip to provide comparison between two voltages connected to the two inputs of the Analog comparator through the external chips.

It also contains a 6 channel ADC out of which 4 have 10 bit accuracy and 2 have 8 bit accuracy.

Status Register: It contains information about the currently executed arithmetic instruction set.

ATmega Pin Diagram:

ATmega Pin Diagram
ATmega Pin Diagram

One of the important features of ATmega8 is that except 5 pins, all other pins support two signals.

  • Pins 23,24,25,26,27,28 and 1 are used for port C, whereas pins 9,10,14,15,16,17,18,19 are used for port B and pins 2,3,4,5,6,11,12 are used for port D.
  • Pin 1 is also the Reset pin and a applying low level signal for a time longer than the minimum pulse length will generate a reset.
  • Pins 2 and 3 are also used for serial communication for USART.
  • Pins 4 and 5 are used as external interrupts. One of them will trigger when interrupt flag bit of status register is set and the other will trigger as long as the interrupt condition prevails.
  • Pins 9 and 10 are used as external oscillator as well as timer counters oscillators where the crystal is connected directly between the pins. Pin 10 is used for crystal oscillator or low frequency crystal oscillator. If the internal calibrated RC oscillator is used as the clock source and the asynchronous timer is enabled, these pins can be used as a timer oscillator pins.
  • Pin 19 is used as Master Clock output, slave clock input for SPI channel.
  • Pin 18 is used as Master clock input, slave clock output.
  • Pin 17 is used as Master data output, slave data input for SPI channel. It is used as a input when enabled by a slave and is bidirectional when enabled by the master. This pin can also be used as a output compare match output, which serves as an external output for the timer/counter compare match.
  • Pin16 is used as a slave select input. It can also be used as a timer/counter1 compare match by configuring the PB2 pin as an output.
  • Pin15 can be used as an external output for the timer/counter compare match A.
  • Pins 23 to 28 are used for ADC channels. Pin 27 can also be used as Serial interface clock and pin 28 can be used as serial interface data
  • Pins 13 and 12 are used as Analog Comparator inputs.
  • Pins 11 and 6 are used as timer/counter sources.

 Microcontroller Sleep Modes

The Microcontroller operates in 6 sleep modes.

  • Idle Mode: It stops the functioning of the CPU, but allows operation of SPI, USART, ADC, TWI, Timer/Counter, and Watchdog and interrupts system. It is achieved by setting SM0 to SM2 bits of MCU register flag to zero.
  • ADC Noise Reduction Mode: It stops the CPU but allows functioning of ADC, external interrupts, timer/counter2 and watchdog.
  • Power down Mode: It enables external interrupts, the 2-wire serial interface, watchdog while disabling the external oscillator. It stops all generated clocks.
  • Power save Mode: It is used when Timer/Counter is clocked asynchronously. It halts all clocks except clkASY.
  • Stand By mode: In this mode, the oscillator is allowed to operate, halting all other operations.

Applications Involving Atmega8

Blinking LED

Applications involving Atmega8
Blinking LEd Schematic

The program is written using C language and is first compiled as .c file. The ATMEL software tool will convert this file to a binary ELF object file. It is then again converted to hex file. The hex file is then passed to the microcontroller using the AVR dude program.

Photo Credit:

Comments are closed.