Arduino Projects    |   Raspberry Pi  |     Electronic Circuits    |    AVR    |    PIC    |    8051    |    Electronic Projects   |   Free TI Design & Simulation Tools 

AVR Microcontroller

Written By: 
Akshay Daga
Microcontroller: Microcontroller can be termed as a single on chip computer which includes number of peripherals like RAM, EEPROM, Timers etc., required to perform some predefined task.
 
Architecture of AVR Microcontroller Architecture of AVR Microcontroller
 
Does this mean that the microcontroller is another name for a computer…? The answer is NO!
The computer on one hand is designed to perform all the general purpose tasks on a single machine like you can use a computer to run a software to perform calculations or you can use a computer to store some multimedia file or to access internet through the browser, whereas the microcontrollers are meant to perform only the specific tasks, for e.g., switching the AC off automatically when room temperature drops to a certain defined limit and again turning it ON when temperature rises above the defined limit.
 
There are number of popular families of microcontrollers which are used in different applications as per their capability and feasibility to perform the desired task, most common of these are 8051, AVR and PIC microcontrollers. In this article we will introduce you with AVR family of microcontrollers.
History of AVR
AVR was developed in the year 1996 by Atmel Corporation. The architecture of AVR was developed by Alf-Egil Bogen and Vegard Wollan. AVR derives its name from its developers and stands for Alf-Egil Bogen Vegard Wollan RISC microcontroller, also known as Advanced Virtual RISC. The AT90S8515 was the first microcontroller which was based on AVR architecture however the first microcontroller to hit the commercial market was AT90S1200 in the year 1997.
 
AVR microcontrollers are available in three categories:
1.      TinyAVR – Less memory, small size, suitable only for simpler applications
2.      MegaAVR – These are the most popular ones having good amount of memory (upto 256 KB), higher number of inbuilt peripherals and suitable for moderate to complex applications.
3.      XmegaAVR – Used commercially for complex applications, which require large program memory and high speed.
The following table compares the above mentioned AVR series of microcontrollers:
 
Series Name
Pins
Flash Memory
Special Feature
TinyAVR
6-32
0.5-8 KB
Small in size
MegaAVR
28-100
4-256KB
Extended peripherals
XmegaAVR
44-100
16-384KB
DMA , Event System included
 
 

Comments (37)

 I m reading  ATMega 16 but

 I m reading  ATMega 16 but there is quite difficutly I  felt while reding the intrrupts

plz give me easy tutorial for this.

elobrate yourself.. where

elobrate yourself.. where exactly you got struct

 

check the link it is a very nice example for reading intrrupt(serial intrrupt):

http://www.engineersgarage.com/embedded/avr-microcontroller-projects/int...

 it will be better if we

 it will be better if we provided the programming of AVR in assembley, as it will help us to learn both programming and instruction set of AVR ( step by step working of AVR)

I want compiler for AVR

I want compiler for AVR ATMEGA32 kindly sent .

                  Thank u

 

you can use AVR studio4...

you can use AVR studio4... plz ask queries on forums

Or u can use CAVR, some site

Or u can use CAVR, some site give it for free

Tutorial was nice can put

Tutorial was nice can put some stuff regarding programing in assembly and C

 

Hi,    i request u to provide

Hi,

 

 i request u to provide tutorial of AVR ATMEGA32  in the quite easy language and the easy view.

 plz.

 

Hello,   i request u to

Hello,

 

i request u to provide tutorial of PIC MICROCONTROLLER  in the quite easy language and the easy view.

 plz.

  send me avr interview

 

send me avr interview questions and answers

i want tutoriyal about

i want tutoriyal about avr,pic,vlsi.plz send to my mail id

I WANT SPI,EEPROM PROGRAMMING

I WANT SPI,EEPROM PROGRAMMING IN ATMEGA32 IN C.

IT IS VERY NICE..

IT IS VERY NICE..

i want RTC interface

i want RTC interface programming for AVR(ATMEGA16) can u plz send me

its some example, i used

its some example, i used DS1307 and 74595 as serial to parallel data, i compiled it with CAVR

if you little bit not understand, you can contact me at facebook with ID denianwar@yahoo.com

 

#include <mega16.h>
#asm
   .equ __i2c_port=0x12 ;PORTD
   .equ __sda_bit=3
   .equ __scl_bit=2
#endasm
#include <i2c.h>
#include <delay.h>
#define SDI PORTC.0   //serial data input
#define LCLK PORTC.1  //latch clock
#define SCLK PORTC.2  //serial clock

// DS1307 Real Time Clock functions
#include <ds1307.h>

// Declare your global variables here
char hh,mm,ss,jam,menit,a,b;
void geser(char data, char n)
{ unsigned char hasil,coun;  
    for (coun =0 ;coun <=n; coun++)
    {
        SCLK=0;
        hasil= (data << coun) & 0x80;
        if(hasil==0x80)
        {SDI=1;}
        else
        {SDI=0;};
        SCLK=1;
        delay_us(1);
        SCLK=0;  
        delay_us(1);
    };       
 }   

char segment(char angka)
{  unsigned char a;     
                 switch (angka)
        {
                case 0: {a=0b00111111; break;}
                case 1: {a=0b00000110;break;}
                case 2: {a=0b01011011;break;}
                case 3: {a=0b01001111;break;}    
                case 4: {a=0b01100110;break;}
                case 5: {a=0b01101101;break;}   
                case 6: {a=0b01111101;break;}
                case 7: {a=0b00000111;break;}
                case 8: {a=0b01111111;break;}    
                case 9: {a=0b01101111;break;}
                //case 'A': {a=0b00000001;break;}
                //case 'B': {a=0b00000010;break;}
                //case 'C': {a=0b00000100;break;}
                //case 'D': {a=0b00001000;break;}
                //case '*': {a=0b00001001;break;}
                //case '#': {a=0b00100010;break;}
                case 'e': {a=~0b01000000;break;}
                case '0': {a=0b00000000;break;}
                //else:  {a=0b00000000;break;}
                }    
                return a;
}

void blank()
{char a;
LCLK=0;
 for(a=0;a<2;a++)
 {
 geser (segment('0'),7);
 }
LCLK=1;
}

void tampil(char a,char b,char c)
{


       PORTA=0b11111110;
       LCLK=0;
       geser(segment(a/10),7);
       geser(segment(a/10),7);
       LCLK=1;
       delay_ms(1);
       blank();
       
       PORTA=0b11111101;
       LCLK=0;
       geser(segment(a%10),7);
       geser(segment(a%10),7);
       LCLK=1;
       delay_ms(1);
       blank();
        
       PORTA=0b11111011;
       LCLK=0;
       geser(segment(b/10),7);
       geser(segment(b/10),7);
       LCLK=1;
       delay_ms(1);
       blank();
       
       PORTA=0b11110111;
       LCLK=0;
       geser(segment(b%10),7);
       geser(segment(b%10),7);
       LCLK=1;
       delay_ms(1);
       blank();
       
       PORTA=0b11101111;
       LCLK=0;
       geser(segment(c/10),7);
       geser(segment(c/10),7);
       LCLK=1;
       delay_ms(1);
       blank();
       
       PORTA=0b11011111;
       LCLK=0;
       geser(segment(c%10),7);
       geser(segment(c%10),7);
       LCLK=1;
       delay_ms(1);
       blank();
       
       PORTA=0b10111111;
       LCLK=0;
       geser(segment(0),7);
       geser(segment(0),7);
       LCLK=1;
       delay_ms(1);
       blank();
       
       
}

void padam(char a,char b,char c)
{

       PORTA=0b11111110;   
       LCLK=0;
       geser(segment(a),7);
       LCLK=1;
       delay_ms(1);
       
       PORTA=0b11111101;
       LCLK=0;
       geser(segment(a),7);
       LCLK=1;
       delay_ms(1);
        
       
       PORTA=0b11111011;
       LCLK=0;
       geser(segment(b),7);
       LCLK=1;
       delay_ms(1);
        
       
       PORTA=0b11110111;
       LCLK=0;
       geser(segment(b),7);
       LCLK=1;
       delay_ms(1);
        
       
       PORTA=0b11101111;
       LCLK=0;
       geser(segment(c),7);
       LCLK=1;
       delay_ms(1);
        
       
       PORTA=0b11011111;
       LCLK=0;
       geser(segment(c),7);
       LCLK=1;
       delay_ms(1);
       
       
       
}
void main(void)
{
PORTA=0xFF;//switching
DDRA=0xFF;

PORTB=0xff;//push button
DDRB=0b00001111;
 
PORTC=0xFF;//data serial
DDRC=0xFF;

PORTD=0x00; //DS1307
DDRD=0xFF;


// I2C Bus initialization
i2c_init();

// DS1307 Real Time Clock initialization
// Square wave output on pin SQW/OUT: Off
// SQW/OUT pin state: 0
rtc_init(3,0,1);
//rtc_set_time(00,00,00);
awal:
PORTB.0=0;
PORTB.1=0;
while (1)
      {
      // Place your code here
      rtc_get_time(&hh,&mm,&ss);
       tampil(hh,mm,ss);
       if(PINB.5==0){goto setjam;}
       
       if ((mm==40)&&(ss==00)){goto buzz;}
      }
 
buzz:
for(b=0;b<=10;b++)
{
PORTB.0=0;
PORTB.1=0;
for(a=0;a<=50;a++)
{
 rtc_get_time(&hh,&mm,&ss);
 tampil(hh,mm,ss);
}
PORTB.0=1;
PORTB.1=0;
for(a=0;a<=50;a++)
{
 rtc_get_time(&hh,&mm,&ss);
 tampil(hh,mm,ss);
}

}
PORTB.0=0;
PORTB.1=0;
goto awal;
     
setjam:
jam=hh;
menit=mm;
while(1)
{
    for(a=0;a<=20;a++)
 {
  tampil(jam,menit,ss);
 }
 
 for(a=0;a<=20;a++)
 {
  padam('0','0','0');
 }
 
 
  if(PINB.6==0)
 {tampil(jam,menit,ss);
  jam=jam+1;if(jam==24){jam=0;}
  hh=jam;
 }
 
 if(PINB.7==0)
 {
  menit=menit+1;if(menit==60){menit=0;}
  mm=menit;
 
 }
 
 
 
 if(PINB.5==0)
 {tampil(jam,menit,ss);
  rtc_set_time(jam,menit,00);
  rtc_get_time(&hh,&mm,&ss);
  for(a=0;a<=20;a++)
 {
  tampil(hh,mm,ss);
 }
  goto awal;
 }
 }
      

}

only xmega devices have DAC. 

only xmega devices have DAC. 

hi sir,sen me avr interview

hi sir,
sen me avr interview questions

If you want to get read, this

If you want to get read, this is how you should write.

What are difference between

What are difference between AVR Programmable and USART?
in a project, is it need use both? Thanks. :)

can we write more than 16KB

can we write more than 16KB of code in ATmega 16 because the hex file generated by my code is of 32 KB and it still works on my MCU. plz help

please

please check http://www.engineersgarage.com/forums/avr/how-read-hex-file

it will clear your doubt.

how to convert 8051 programs

how to convert 8051 programs to atmega8 microcontroller ?i have codes for digital lock and visitor counter written in assembly c for 8051 ,now

i hav to convert it to atmega8 since i cant use 8051 for my project, pls help me

can you upload any example or

can you upload any example or fully listing program? i wish i can help you, denianwar@yahoo.com

i wish 2 make a digital

i wish 2 make a digital visitor counter on atmega8...can u plz give code in embedded C language..at moment i m making a single direction entrance in which i just need 2 count n show number of persons entering (no complication of bidirection or controlling any other peripherals..!!)

but i m using 2 IR transmitter n reciever which will show that the person has entered after he has crossed both I R sensors..how do i code it..?

 

 start--> person crossing both I R sensor--> YES increment the counter n display on 7 segment display.

                                                              

                                                              -->NO show previous counted value itself on 7 segment dislay.

 

 

plz help me...!!!

great article, its help me to

great article, its help me to teach microcontrol in my class, thanks www.engineersgarage.com

can any one please tell me

can any one please tell me how to use internal eeprom for storing files of smaller size ..i m using atmega16 ...my project includes buttons , 16x 2 lcd , atmega16 .....i hav to do three things.....

1.display hello message

2.to retrieve files from eeprom

3. send them via blue tooth

i m now in  storing files in eeprom

 

pls help me this is my final year project..........

thnx in advance

hellomy project includes

hello

my project includes atmega16 ,lcd,buttons for navigation

my project is store files in eeprom , then retrieve them and send via bluetooth..,,,i need help in this  3 things

help this is my final yr project ..

thnx in advance

can ne one provide some

can ne one provide some example for navigation button (up,down.ok.back )..................

Respected sir,i wish 2

Respected sir,

i wish 2 implement digital visitor counter using Atmega8. can u plz suggest me the module to b used in infra red transmitter n reciever? i was thinking of using opamp as comparator and giving its output 2 atmega8. but i m unable 2 form its circuit diagram. can u plz help me with it immediately.

 

 

ur help wil b invaluable. plz. help..its urgent...!!!

can somebody send me

can somebody send me tutorials for interfacing a 16*2 lcd with atmega8??

help is highly appreciated

thanks in advance

i want to more about AVR

i want to more about AVR microcontrollers

can any one help me to

can any one help me to interface DC1307 real time clock display on LCD and controllerd by key pad ?

can u please send me the code

can u please send me the code of RTC interfacing with AVR atmega16 working code with circuit diagram fast as i am in urgent....!!!

 

can u please send me the code

can u please send me the code of RTC interfacing with AVR atmega16 working code with circuit diagram fast as i am in urgent....!!!

 

I want to read atmega 16

I want to read atmega 16 timers coading  concept in a detail and ni  very simple way.....plz suggest me...i am very confused with this topic.....

I am using ATmega16

I am using ATmega16 microcontroller,will any one please help me to write a program code for switching the Boost(Dc-Dc) converter

Hi.. I am new in

Hi.. I am new in microcontroller, and i have a confusion about Timers and Timer Interrupts. Please help me to understand it, means whats the difference between using Timer to give delay and as interrupt..

You are here