Avr Atmega8 PDF
Avr Atmega8 PDF
Avr Atmega8 PDF
The Atmel ®AVR® ATmega8A is a low-power CMOS 8-bit microcontroller based on the AVR
RISC architecture. By executing powerful instructions in a single clock cycle, the ATmega8A
achieves throughputs approaching 1 MIPS per MHz, allowing the system designer to optimize
power consumption versus processing speed.
The Atmel®AVR® AVR core combines a rich instruction set with 32 general purpose working
registers. All the 32 registers are directly connected to the Arithmetic Logic Unit (ALU),
allowing two independent registers to be accessed in one single instruction executed in one clock
cycle. The resulting architecture is more code efficient while achieving throughputs up to ten
times faster than conventional CISC microcontrollers.
The ATmega8A provides the following features: 8K bytes of In-System Programmable Flash
with Read-While-Write capabilities, 512 bytes of EEPROM, 1K byte of SRAM, 23 general
purpose I/O lines, 32 general purpose working registers, three flexible Timer/Counters with
compare modes, internal and external interrupts, a serial programmable USART, a byte oriented
Two-wire Serial Interface, a 6-channel ADC (eight channels in TQFP and QFN/MLF packages)
with 10-bit accuracy, a programmable Watchdog Timer with Internal Oscillator, an SPI serial
port, and five software selectable power saving modes. The Idle mode stops the CPU while
allowing the SRAM, Timer/Counters, SPI port, and interrupt system to continue functioning. The
Power-down mode saves the register contents but freezes the Oscillator, disabling all other chip
functions until the next Interrupt or Hardware Reset. In Power-save mode, the asynchronous
timer continues to run, allowing the user to maintain a timer base while the rest of the device is
sleeping. The ADC Noise Reduction mode stops the CPU and all I/O modules except
asynchronous timer and ADC, to minimize switching noise during ADC conversions. In Standby
mode, the crystal/resonator Oscillator is running while the rest of the device is sleeping. This
allows very fast start-up combined with low-power consumption.
The device is manufactured using Atmel’s high density non-volatile memory technology. The
Flash Program memory can be reprogrammed In-System through an SPI serial interface, by a
conventional non-volatile memory programmer, or by an On-chip boot program running on the
AVR core. The boot program can use any interface to download the application program in the
Application Flash memory. Software in the Boot Flash Section will continue to run while the
Application Flash Section is updated, providing true Read-While-Write operation. By combining
an 8-bit RISC CPU with In-System Self-Programmable Flash on a monolithic chip, the Atmel
ATmega8A is a powerful microcontroller that provides a highly-flexible and cost-effective
solution to many embedded control applications.
The Atmel AVR ATmega8A is supported with a full suite of program and system development
tools, including C compilers, macro assemblers, program debugger/simulators, In-Circuit
Emulators, and evaluation kits.
FEATURES OF ATMEGA8
• High-performance, Low-power Atmel®AVR® 8-bit Microcontroller
• Advanced RISC Architecture
– 130 Powerful Instructions – Most Single-clock Cycle Execution
– 32 x 8 General Purpose Working Registers
– Fully Static Operation
– Up to 16MIPS Throughput at 16MHz
– On-chip 2-cycle Multiplier
• High Endurance Non-volatile Memory segments
– 8KBytes of In-System Self-programmable Flash program memory
– 512Bytes EEPROM
– 1KByte Internal SRAM
– Write/Erase Cycles: 10,000 Flash/100,000 EEPROM
– Data retention: 20 years at 85°C/100 years at 25°C(1)
– Optional Boot Code Section with Independent Lock Bits
• In-System Programming by On-chip Boot Program
• True Read-While-Write Operation
– Programming Lock for Software Security
• 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 ADC in TQFP and QFN/MLF package
• Eight Channels 10-bit Accuracy
– 6-channel ADC in PDIP package
• Six Channels 10-bit Accuracy
– 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
• Special Microcontroller Features
– Power-on Reset and Programmable Brown-out Detection
– Internal Calibrated RC Oscillator
– External and Internal Interrupt Sources
– Five Sleep Modes: Idle, ADC Noise Reduction, Power-save, Power-down, and
Standby
• I/O and Packages
– 23 Programmable I/O Lines
– 28-lead PDIP, 32-lead TQFP, and 32-pad QFN/MLF
• Operating Voltages
– 2.7 - 5.5V
– 0 - 16MHz
The ATEGA-8 Development Board has been developed to allow the beginners to learn about
the architecture and the applications of the micro controller. The Board once connected to the
computer allows the developer to write his programs in Assembly of ATMEGA8 or in C
language and compile the program to generate the Hex file (using the IDE provided by Atmel).
The Hex file so generated can be downloaded in the Flash memory of the micro controller and
executed automatically
The Board is either provided as just aboard with necessary cables etc. or some time on demand
also enclosed in a wooden Box for protection. When the Board is provided as just a Board, the
supply can be tapped from the System through the USB cable provided.
If the Board is enclosed in a Box, then built in power supply is also provided at the bottom of
the Box. However the power supply of the Computer can still be used by changing the jumper at
the left bottom corner of the Board.
The Block Diagram of the Board is given below for your reference.
Vcc
ISP Connector
I2C Bus
LED3
USB Connector
LED ENABLE
LED2 JUMPER
USB
Excel Technologies
JP6
Vcc
INTERFACE
S5
LED1
Vcc(+5V)
PC4 PD4
PD1
PD0
PD5
PD6
PC5
JP5
PD7
EEPROM
Thermistor PB4
S6
1K NTC
2X16 LCD
PB5
PC0
S1 PB6
PD2
S2
Contrast
32KHz
Analog Vin2
PB7
PD3
(Same as PC2)
PB0
RESET PC6 LED5
PC3
PB1
PC2
JP2
Buzzer
LDR
Vcc
PB3 PC1
PB2
EXT
Vin1
S3/IRSENSOR ENABLE
Vcc
ENABLE
Jumper
JP7
JP4
S3
IR LED
+5V
IR ENABLE
S4
S4/IRLED
GND
AVR DEVELOPMENT BOARD ( ATMEGA 8)
Page 4
TV Remote Receiver
Vcc
AVR DEVELOPMENT BOARD ( ATMEGA 8)
1) POWER CONNECTION
The power to the Development Board can be provided either through USB Connector or through
External power supply selectable by a jumper JP1 at the left hand side lower bottom of the Board
If the Board is enclosed in a Box, then built in power supply is provided at the bottom of the
Box. This is essentially done to ensure the smooth functioning of the Board for long time as it
has been seen that some time the power of the USB gets weak and it is not able to supply full
current, so if the built in power supply is connected then this problem will never arise. However
any time the user wants to use the power of the USB, he can change the jumper as shown below
EXT PWR
POWER TO SYSTEM
USB PWR
2) OUTPUT LEDs
The Board has Five output LEDs LED1 to LED5 namely connected to the Pins PD7, PD6, PD5,
PD4 and PB0. Respectively ie
Note: All the above LEDs are Enabled through a jumper LED ENBL
3) INPUT SWITCHES
The Board Has six input switches S1 to S6 connected to the micro controller through PD2, PD3,
PB2, PB3, PC4 and PC5 respectively . The Keys switch S1 and S2 are connected directly to PD2
and PD3 respectively. But the other Keys S3 to s5 are connected through Jumpers as shown
below
SWITCH S3 PB3
JP4 TO IR LED
SWITCH S4 PB2
JP6
TO EEPROM
SWITCH S5 PC4
JP5 TO EEPROM
SWITCH S6 PC5
A 16*2 LCD Display ie 16 characters and two line Display is there on the Board with Back light
The Pin Diagram of the Display is explained here. The LCD is connected on four Data lines
D4 to D7 and the controls signals EN and RS are connected to PB4 and PB5 respectively
through Jumpers as shown below
EN 2
6
GND---RW
5 15
RS
4
NC
L
DO 7
D1 8 C
D2 9
PB4
10 D 3
PB5 D3
PD4
PD5 D4 11
PD6
PD7 D5 12 1
LCD D6 13
ENBLE 14 16
D7
5) BUZZER
A DC Buzzer is connected to theD7PB1 line through jumper JP2 as shown below. A low on PB1
will put the Buzzer in ON condition.
+5V PB1
1K Ohms
Buzzer JP2
6) INTERFACING ADC
ATMEGA 8 has in built six channels ( channel 0 to channel 5 ) of ADC of 10 bit accuracy. Out
of these only four channels are used on the Board using Pin PC0 , PC1, PC2 and PC3 of the
ATMEGA8 chip ( ie ADC0, ADC1, ADC2 and ADC3 ). The channel ADC0 and ADC1 are
used for sensing the Temperature and sensing the Light using the Thermister and the LDR
respectively. The other two channels are used for measuring the Analog Voltages.
The other ADC channel ADC3 is available at Pins VIN2 on the Board and one can connect
external Analog input on the pins VIN2. The circuit connections are shown here.
+5V
Pin--PC2
(ADC2) JP7
VIN1
Pin—PC3
(ADC3)
VIN2
An On Board Thermister of 1 K Ohms is provided on the Board for sensing the temperature
Thermister
1K Ohms
PC0 (ADC0)
4.7K
We know that the resistance of the Thermister varies linearly with the temperature.. If the Vcc is
+5V. The resistance of thermister is 1 K at 25 degrees, Measure the voltage Vo using ADC and
then calculate the resistance of thermister at room temperature
Rthermistor=(Vcc/Vmeasured−1)×4.7
An On Board LDR of 1 K Ohms is provided on the Board for sensing the Light
LDR ( RL in K Ohms)
PC1 (ADC1)
Vo
4.7K
The resistance of the Light Dependent Resistor (LDR) varies according to the amount of light
that falls on it. The relationship between the resistance RL and light intensity Lux for a
typical LDR is
With the LDR connected to 5V through a 4.7K resistor, the output voltage of the LDR is
Vo = 4.7 *5
4.7+ RL
Lux Vo
For a low cost LDR, at the same light intensity, the part to part variation in resistance can be as
high as 50%. Therefore such a low cost LDR is seldom used for measuring light intensity but
more for light presence/absence detection.
9) EEPROM INTERFACE
An EEPROM is available on the Development Board for storing and retrieving the data serially.
The two Lines SCL and SDA of the AVR ATMEGA8 are connected to the EEPROM as shown
below
S6 Key
Gnd
A0 1 4
2
WP JP5
A1 2 4 7
C SCL
Pin 28 of
A2 3 6
0 SDA AVR ( SCL )
Vcc 8 5
2
S5 Key
P 2.1
Pin 27 of
4
AVR ( SDA )
5
JP6
P 2.1
The user can write in to the EEPROM for storing his data and can retrieve the same as and when
required.
An IR Transmitter LED is connected to Pin PB2 through jumper JP4 as shown here.
TO S4 KEY
PB2
Vcc
IR LED
JP4
An IR Receiver sensor is also connected to the Pin PB3 through a jumper named
S3 / IR SENSOR
IR REMOTE RECEIVER
PB3
TO S3 KEY
S3 / IR
RECEIVER
ENABLE
The sample programs for the various Hardware are provided in the CD provided with the Kit
The CD also contains the AVR Studio and the Software ( Mega Load ) for downloading the
Hex file generated by the AVR Studio in the AVR ATMEGA8 chip. One just needs to use the
write the program in C language and compile the program using AVR Studio. This Hex file can
be down loaded in the on Board AVR chip using the Mega Load software.