Basics of atmega16/32

February 8, 2009 at 23:36 (microcontroller)

OVERVIEW:

Atmega16/32 is atmel product. they are of megaAVR series , they have 16Kb and 32Kb Flash memory resp. like other AVR uc they are ISP(in system programmable ) i.e u can program it without taking it out of the system.

Features:

  • 16/32 Kb In-System Self-Programmable Flash
  • 1024 Bytes EEPROM
  • Two 8-bit Timer/Counters with Separate Prescalers and Compare Modes
  • One 16-bit Timer/Counter with Separate Prescaler, Compare Mode, and Capture Mode
  • Four PWM Channels
  • Programmable Serial USART
  • Internal Calibrated RC Oscillator
  • Power-on Reset and Programmable Brown-out Detection
  • 32 Programmable I/O Lines

and many more…

PROGRAMMING:

As mentioned above it has 32 I/O lines that means it has 4 I/O ports(A,B,C,D).Every i/o port has 3 registers associated with each ports.These three registers are

  • DDRx(data direction register)
  • PINx
  • PORTx

x -A,B,C,D

DDRx(DATA DIRECTION REGISTER ):

This register configures data direction of port pins , means by using this register microcontroller decides whether this port will be used as input port or output port. In 8051 if we will declare any port as FF it becomes input port but in atmega it is opposite if we declare FF it becomes output port .

e.g To make all pins of  port D as input pins

DDRD=0b00000000

If we want to make first 4 pins of portc as input and remaining 4 as output then

DDRC=0b00001111

PINx register:

PIN(port IN) used to read data from port pins

e.g To read data from portA

DDRA=0b00000000

Y=PINA  // data from port A will be stored in variable Y

PORTx register:

PORTx is used for two purpose-

  1. TO O/P DATA: when port is configured as output.when corresponding bits in DDR is set 1.
    DDRA=0b11111111x=0b10101010PORTA=x  // now content of port a will be AA
  2. To activate or deactivate pull up registers: This when u configure a port as input port. In input mode , when pull up is enabled , defaulted as 1. So, even if you dont connect anything to the pin and if you try to read it , it will read as 1. Now , when you drive pin to zero , only then it  will read as 0.

e.g

  • To make portA as i/p with pull-up enableDDRA=0b00000000
    PORTA=0b11111111
    y=PINA
  • To make portA as tri-stated i/p
    DDRA=0b00000000
    PORTA=0b00000000

Using this basic knowledge we can easily write a program(I/O) for atmega.

u can also view this post on

http://expertscolumn.com/content/basics-atmega1632

 

………………….if you found this tutorial helpful or have any suggestions … do leave a comment.

14 Comments

  1. kt said,

    Please see my comment in your previous entry.
    This tutorial was helpful for a quick brush up.

  2. Sushanta Kumar Sahu said,

    Thanks man, I had been looking for a tutorial to program my avr. Now you have given a basis to understand further. But I feel you need to teach us more. There are not many guys accessible to dissipate their knowledge. Thanks for your help.

  3. sanket said,

    hi,
    thanks for such a good, clear explanation of these basics.
    but i also wanted some tips on how to choose a particular microprocessor for a particular application and how to interface the Atmega 16/32 with the PC for loading the program onto the microcontroller. it would be wonderful if you could give some information regarding these.
    thanking you.

  4. Interface the Atmega 16/32 with the PC « Praveendb’s Weblog said,

    […] ATMEGA32 is a 8-bit AVR microcontroller with 32K Bytes In-system Programmable Flash. In Atmega32pins pin no.14 and 15 are RxD and TxD resp. For basics of atmega32 click here […]

  5. Mahi said,

    Really a clear explanation u have given ,thanx man

  6. scott said,

    mate, awesome, have been looking for something clean and simple all day

    cheers
    scott

  7. hawk said,

    its really helpful man…
    thanx a lot

  8. Abhinav said,

    Thank u very much dude !!!
    This help me alot to understand …
    Keep up the nice work …

  9. Shagec said,

    Thanks man.teach the information that u know,is a great job.

  10. santosh said,

    nice material, keep it up

  11. rama brahmam said,

    it is absolutely nice for the basic knowledge.it is so nice if u add some more information about programming

  12. vadiraj said,

    its good information..thank you..

  13. GODLESS said,

    Very helpful information..thanks a lot

Leave a reply to kt Cancel reply