Report By: URVASHI KHANDELWAL
• Embedded system
• AVR microcontroller
PIN and port Description
Hardware Interfacing and Coding
DEPARTMENT OF EMBEDDED SYSTEM
• An Embedded system is a combination of computer hardware and software which is designed to
perform many operations such as to access the data, process the data, store the data and also
control the data in electronics based systems. In embedded systems, software commonly known as
firmware Basically embedded systems are task specific devices
• Embedded system is defined as a way of working, organizing, performing single or multiple tasks
according to a set of rules
• Hence it covers all the industries like
- CONSUMER ELECTRONICS
• ATmega8 is a 8-bit microcontroller based on the AVR RISC
• By executing powerful instructions in a single clock cycle, the
ATmega8 achieves throughput approaching 1 MIPS per MHz
• Instruction in program memory are executed with single level
• This concept enables instructions to be executed in every clock
• High-performance 8 bit Microcontroller
• 32 x 8 General Purpose Working Registers
• Six ADC channels in PDIP package
• Internal Calibrated Oscillator
• 8K Bytes of Flash program memory
• 512 Bytes EEPROM (Electrically Erasable Programmable Read
• 1K Byte Internal RAM (Random Access Memory)
• Write/Erase Cycles: 10,000 Flash/100,000 EEPROM
• Data retention: 20 years at 85°C/100 years at 25°C
TYPES OF PACKAGES
• 28-pin PDIP (Plastic Dual In-line Package)
opaque molded plastic pressed around a tin-,
silver-, or gold-plated lead frame that supports the
device die and provides connection pins.
• 32-pin TQFP (Thin Quad film Package)
For easy soldering
• VCC Digital supply voltage
• 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
• AREF The analog reference pin for the A/D Converter
• AVCC The supply voltage pin for the A/D Converter
• Three ports i.e PortB, PortC, PortD -General Purpose 8 Bit
• Three registers associated with every port
DDRx – Data Direction Register
PINx – Port input
PORTx- Port output
*Note – ‘x’ is subscript and could be either of B, C, D
PORT B (PB7..PB0)
• Port B is an 8-bit bi-directional I/O port
• Can be used either as a input port or as output port ( direction
must be specified in programming)
USING EMBEDDED C
• Embedded C is nothing but a subset of C language which is
compatible with certain microcontrollers.
• Some features are added using header files like <avr/io.h>,
• scanf() and printf() are removed as the inputs are scanned from
the sensors and outputs are given to the ports.
• Control structures remain the same like if-statement, for loop,
AVR STUDIO 4.0
AVR studio is an Integrated Development Environment (IDE) by ATMEL for
developing applications based on 8-bit AVR microcontroller
PROTEUS 7 DESIGN SUITE
• this software helps programmers in hardware implementations.
• It provides a huge number of electronic components and
• REAL TIME ANOMATONS of the hardware designs.
• This is the perfect tool for engineers to test their microcontroller designs Before constructing a
physical prototype in real time
HOW TO WORK AT AVR STUDIO
Step1. Start AVR Studio on your
workstation. Select "New Project".
Type is "AVR-GCC". Project name:
"MyFirstProject". Check off the
"create folder" box. Modify the
location if desired.
Step2. Click "Next".
Step3. Debug platform
should be "AVR
Simulator". Device Is
Step4. Click Finish.
You will now be in the
Step5.Write the following
code into the window in the
middle of the screen (the
window for My FirstProject.c):
This is a quick and dirty way to turn both
This code tells all of Port B to become
outputs by writing 0xFF (binary 1111 1111)
to DDRB which is the data direction register
for port B.
Step 6.Compile the code with "Build -> Build" from the menu, or
the F7 shortcut for "Build". The bottom window will show the
progress and results. You should see "Build succeeded with 0
If there is an error, check your code for typos. The error message should give
you the offending line number
A successful compile will result in a .hex file being generated. This is the
binary code in a format ready to be burned into your AVR chip by the
programmer. (Think of the .hex file as a program that the target AVR chip can
run once we put it on there, sort of like writing to a memory card.)
You should be able to locate MyFirstProject.hex in your project dir. For me, it
was in "AVRsrcMyFirstProjectdefault".
Step 7. Now let's debug the code in the simulator to get a feel for
how it works.
Use "Build -> Build and Run" from the menu, or use the CTRL-F7
Note the following:
We have a yellow arrow at the current execution.
We have some debugging keys at the top (we want STOP and STEP INTO now).
We have "AVR SIMULATOR" at the bottom which is no longer greyed out.
Now click on the right pane on PORTB so we can look at it in the "I/O View". The bottom
right window will populate with DDRB, PINB, and PORTB. These represent some states of the
simulator's virtual ATTINY45 hardware.
Step 8. Step through the program line by line with "STEP INTO
Notice DDRB (direction of pins for PORTB: input or output) changes on
the bottom right after "DDRB = 0xff" is executed.
Step 9. Step again and notice that PORTB becomes set to 0xff (all
logical 1 output) when "PORTB = 0xff" is executed.
We are now at the end of the program. Click "STOP DEBUGGING" (the
blue square button on the menu bar ) or CTRL-SHIFT-F5 to stop the
debugger and chip simulator and return to the coding view.
SOME EXAMPLES USING
1. Blinking of even no. lights at port
HARDWARE INTERFACING'S AND CODING:
Seven Segment Interfacing with Microcontroller
LCD interfacing with Microcontroller