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:
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.Ñhese three registers are
x -A,B,C,D
:
Ñhis 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 .
DDRD=0b00000000
If we want to make first 4 pins of portc as input and remaining 4 as output then
DDRC=0b00001111
K
DDRA=0b00000000
K
1.| ÑO O/P DAÑA: when port is configured as output.when corresponding bits in DDR is set
1.
DDRA=0b11111111x=0b10101010PORÑA=x // now content of port a will be AA
2.| Ño activate or deactivate pull up registers: Ñhis 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
Using this basic knowledge we can easily write a program(I/O) for atmega.
«««««««.if you found this tutorial helpful or have any suggestions « do leave a
comment.