Getting used to AVR
Datasheet. A datasheet is a document provided by the manufacturer of an IC that gives information about various Pins of those IC’s and their function.
To learn AVR Microcontrollers, it is necessary to have that particular Microcontroller’s Datasheet with you. The datasheets are available for free on the Internet.
Our programming platform shall be WinAVR, which is also a free software available on the internet.
The best way to learn using a microcontroller, for a newbie, is using a development board. You could either make one on your own or buy them online. It’s best to buy one, it reduces the errors that might arise out of incorrect hardware connections. So, if you are looking to buy a development board, you can buy them from robokits.co.in, thinklabs.in...there are many other websites too. There are different types of programmers available. Please make sure that you know which programmer is used to program your board. It may be different for different boards.
The 1st thing that you need to be familiar with is a microcontroller’s Inputs and Outputs.
We will be considering Atmega16 throughout the course of this series. The PIN DIAGRAM of Atmega16 and Atmega32 are identical.
(click on the photo to enlarge it)
As can be seen the pins for both the IC’s are identical. The only major difference is that ATmega16 has 16K Bytes of In-System programmable flash memory while an ATmega32 has 32K Bytes of flash memory.
ATmega16 (and ATmega32) has a total of 40 pins, of which 32 can be used as Input or output. These pins are divided into 7 ports
PORTA- 8 pins ( PA0 to PA7)
PORTB- 8 pins ( PB0 to PB7)
PORTC- 8 pins ( PC0 to PC7)
PORTD- 8 pins ( PD0 to PD7)
Each of these ports is associated with 3 registers: DDRx, PORTx, PINx, where ‘x’ stands for the port name (A,B,C or D). e.g DDRA, PORTA, PINA etc.
NOTE: While programming, DDRx,PORTx,PINx are always written in capitals.
DDR stands for Data Direction Register. It decides whether a particular pin will act as input or output.
(please note that PIN refers to the register and pin refers to some pin of the microcontroller)
Since a Port has 8 pins, all the registers, DDR,PORT,PIN are 8 bit register. Each bit corresponds to a pin of that particular port. Consider the example of port A
(click on the photo to enlarge it)
MSB stands for Most Significant Bit. LSB stands for Least Significant Bit.
No comments:
Post a Comment