Introduction to Atmega 16 Microcontroller
Advanced RISC Architecture specification
- Up to 16 MIPS Throughput at 16 MHz
- 16K Bytes of In-System Self-Programmable Flash
- 512 Bytes EEPROM
- 1K Byte Internal SRAM
- 32 Programmable I/O Lines
- In-System Programming by On-chip Boot Program
- 8-channel, 10-bit ADC
- Two 8-bit Timer/Counters with Separate Prescalers and Compare Modes
- One 16-bit Timer/Counter with Separate Prescaler, Compare Mode, and Capture
- Four PWM Channels
- Programmable Serial USART
- Master/Slave SPI Serial Interface
- Byte-oriented Two-wire Serial Interface
- Programmable Watchdog Timer with Separate On-chip Oscillator
- External and Internal Interrupt Sources
VCC: Digital supply voltage. (+5V)
GND: Ground. (0 V) Note there are 2 ground Pins.
Port A (PA7 – PA0)
Port A serves as the analog inputs to the A/D Converter. Port A also serves as an 8-bit bi-directional I/O port, if the A/D Converter is not used. When pins PA0 to PA7 are used as inputs and are externally pulled low, they will source current if the internal pull-up resistors are activated. The Port A pins are tri-stated when a reset condition becomes active, even if the clock is not running.
Port B (PB7 – PB0)
Port B is an 8-bit bi-directional I/O port with internal pull-up resistors (selected for each bit). Port B also serves the functions of various special features of the ATmega16 as listed on page 58 of datasheet.
Port C (PC7 – PC0)
Port C is an 8-bit bi-directional I/O port with internal pull-up resistors (selected for each bit). Port C also serves the functions of the JTAG interface and other special features of the ATmega16 as listed on page 61 of datasheet. If the JTAG interface is enabled, the pull-up resistors on pins PC5 (TDI), PC3 (TMS) and PC2 (TCK) will be activated even if a reset occurs.
Port D (PD7 – PD0)
Port D is an 8-bit bi-directional I/O port with internal pull-up resistors (selected for each bit). Port D also serves the functions of various special features of the ATmega16 as listed on page 63 of datasheet.
RESET: Reset Input. A low level on this pin for longer than the minimum pulse length will generate a reset, even if the clock is not running.
XTAL1: External oscillator pin 1
XTAL2: External oscillator pin 2
AVCC: AVCC is the supply voltage pin for Port A and the A/D Converter. It should be externally connected to VCC, even if the ADC is not used. If the ADC is used, it should be connected to VCC through a low-pass filter.
AREF: AREF is the analog reference pin for the A/D Converter.
Digital Input Output port :
So let’s start with understanding the functioning of AVR. We will first discuss about I/O Ports. Again I remind you that I will be using and writing about Atmega-16. Let’s first have a look at the Pin configuration of Atmega-16. Image is attached, click to enlarge.
You can see it has 32 I/O (Input/Output) pins grouped as A, B, C & D with 8 pins in each group. This group is called as PORT.
• PA0 – PA7 (PORTA)
• PB0 – PB7 (PORTB)
• PC0 – PC7 (PORTC)
• PD0 – PD7 (PORTD)
Notice that all these pins have some function written in bracket. These are additional function that pin can perform other than I/O. Some of them are.
• ADC (ADC0 – ADC7 on PORTA)
• UART (Rx,Tx on PORTD)
• TIMERS (OC0 – OC2)
• SPI (MISO, MOSI, SCK on PORTB)
• External Interrupts (INT0 – INT2)
Input Output functions are set by Three Registers for each PORT.
• DDRX —-> Sets whether a pin is Input or Output of PORTX.
• PORTX —> Sets the Output Value of PORTX.
• PINX —–> Reads the Value of PORTX.