Basics of atmega16/32
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-
- 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 - 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.
kt said,
March 25, 2009 at 11:55
Please see my comment in your previous entry.
This tutorial was helpful for a quick brush up.
Sushanta Kumar Sahu said,
March 29, 2009 at 10:28
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.
sanket said,
May 8, 2009 at 19:51
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.
praveendb said,
May 18, 2009 at 20:25
visit https://praveendb.wordpress.com/2009/05/18/interface-the-atmega-1632-with-the-pc/
Interface the Atmega 16/32 with the PC « Praveendb’s Weblog said,
May 18, 2009 at 20:19
[…] 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 […]
Mahi said,
May 29, 2009 at 23:11
Really a clear explanation u have given ,thanx man
scott said,
November 23, 2009 at 18:52
mate, awesome, have been looking for something clean and simple all day
cheers
scott
hawk said,
March 11, 2010 at 12:01
its really helpful man…
thanx a lot
Abhinav said,
June 18, 2010 at 10:59
Thank u very much dude !!!
This help me alot to understand …
Keep up the nice work …
Shagec said,
October 15, 2010 at 20:55
Thanks man.teach the information that u know,is a great job.
santosh said,
February 1, 2011 at 16:34
nice material, keep it up
rama brahmam said,
March 11, 2011 at 12:44
it is absolutely nice for the basic knowledge.it is so nice if u add some more information about programming
vadiraj said,
April 7, 2011 at 18:02
its good information..thank you..
GODLESS said,
June 23, 2011 at 10:58
Very helpful information..thanks a lot