WHAT IS
MICROCONTROLLER?
A microcontroller (sometimes abbreviated µC or MCU)
is a small computer on a single IC containing a processor
core, memory, and programmable input/output
peripherals.
It is a decision making device used widely in embedded
systems and all intelligent devices.
BASIC BLOCK DIAGRAM OF
MICROCONTROLLER
DIFFERENCE BETWEEN
MICROCONTROLLER AND
MICROPROCESSOR
Microcontroller has I/O ports, Memory, timers etc all
integrated on chip itself
In Microprocessors, I/O ports, memory, timer etc are to
be connected externally
BLOCK DIAGRAMS
WHAT IS 8-BIT
MICROCONTROLLER
8-bit means it can process 8-bit data per clock cycle
It has 8-bit data bus
It can process 1byte of data at a time
AVR ATMEGA-16
MICROCONTROLLER
HOW AVR ATMEGA16 GOT ITS
NAME
It was developed by Atmel Corporation
AVR implies it belongs to AVR family.
‘16’ in Atmega16 means this microcontroller has 16Kb of
flash memory
WHAT IS AVR?
AVR is a modified Harvard architecture , 8-bit RISC
single chip microcontroller.
It was developed in the year 1996 by Atmel Corporation.
SPECIAL FEATURES OF AVR
They are fast.
AVR Microcontroller executes most of the instructions in
single execution cycle.
AVRs are about 4 times faster than PIC.
They consume less power and can be operated in different
power saving modes.
INTRODUCTION TO ATMEGA16
• ATmega16 is a low-power CMOS 8-bit microcontroller
based on the AVR RISC architecture.
• By executing powerful instructions in a single clock cycle,
the ATmega16 achieves throughput approaching 1 MIPS
per MHz.
• In order to maximize performance and parallelism, the
AVR uses a Harvard architecture.
FATURES OF ATMEGA16
High-performance, Low-power AVR 16-bit
Microcontroller
Up to 16 MIPS Throughput at 16 MHz
32 x 8 General Purpose Working Registers
Internal Calibrated RC Oscillator
External and Internal Interrupt Sources
Data retention: 20 years at 85°C/100 years at 25°C
MEMORY SEGMENT
16K Bytes of In-System Self-programmable Flash
program memory
512 Bytes EEPROM (Electrically Erasable Programmable
Read Only Memory)
1K Byte Internal SRAM (Static Random Access
Memory)
PERIPHERAL FEATURES
• Two 8-bit Timer/Counters with Separate Prescaler, one
Compare Mode.
• One 16-bit Timer/Counter with Separate Prescaler,
Compare Mode, and Capture Mode.
• Real Time Counter with Separate Oscillator.
• Three PWM Channels.
• 8-channel 10-bit ADC in TQFP package
Byte-oriented Two-wire Serial Interface.
Programmable Serial USART.
Master/Slave SPI Serial Interface.
Programmable Watchdog Timer with Separate On-chip
Oscillator.
On-chip Analog Comparator.
TYPES OF PACKAGES
40-lead PDIP (Plastic Dual In-line Package)
44-lead TQFP (Thin Quad film Package)
HOW ATMEGA16 PDIP PACKAGE
LOOKS LIKE?
ATMEGA16 TQFP PACKAGE
PIN DIAGRAM OF ATMEGA16
PIN DESCRIPTION
VCC: Digital supply voltage 5V.
GND: Ground.
RESET: A low level on this pin for longer than the
minimum pulse length will generate a reset, even if
the clock is not running.
AREF: The analog reference pin for the A/D
Converter.
AVCC : The supply voltage pin for the A/D
Converter, Port C (3..0).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.
PORTS
There are 4 ports in ATmega16: Port A, Port B, Port C
and PORTD.
Three registers are associated with every port.
DDRx – Data Direction Register
PINx – Port input
PORTx- Port output
Where x would be either A,B,C or D.
PORT x(PX0-PX7)
It is a 8-bit bi-directional I/O port.
It has internal pull up resistors(selected for each bit).
It can be used either as a input port or as output port
( direction must be specified in programming).
REGISTERS TO COMMUNICATE
WITH I/O PORTS
To communicate with the ports of Atmega16, we use
three registers:
PINx
PORTx
DDRx
Where x would be either A,B,C or D.
DDRx REGISTER
It stands for Data Direction Register.
It is used to define Port as Input or Output.
In order to make Port as Input Port: DDRx=0x00 (In
Hexadecimal)
DDRx=0b00000000(In Binary)
In order to make Port as output Port: DDRx=0xFF (In
Hexadecimal)
DDRx=0b11111111(In Binary)
PORTx REGISTER
If DDRx=0xFF(Output port).
Writing logic 1 to PORTx will make output high i.e 5v
for that particular pin.
Writing 0 to PORTx will make output low i.e 0v for that
particular pin.
If DDRx=Ox00(Input port)
If corresponding PORTx bit is set to 1, Internal pull up
resistors are enabled i.e if we do not connect this pin to
anything it still reads as 1.
If corresponding PORTx bit is set to 0, internal pull up
resistors are disabled i.e the pin will enter a high
impedance state and will become unpredictable.
PINx REGISTER
It reads data from the port pins.
If any/all bits of DDRx is set to 0(input)for a particular
pin, we can read data from PINx
If any/all bits of DDRx is set to 1(output), then reading
PINx register gives the same data which has been output
on that particular pin.
THANK YOU