embedded system and avr

31
SOFCON TRAINING PRESENTATION Embedded system Report By: URVASHI KHANDELWAL

Upload: urvashi-khandelwal

Post on 27-Jan-2017

342 views

Category:

Engineering


4 download

TRANSCRIPT

Page 1: embedded system and AVR

SOFCON TRAINING PRESENTATION

Embedded system Report By: URVASHI KHANDELWAL

Page 2: embedded system and AVR

CONTENT• Embedded system Introduction Applications• AVR microcontroller Introduction Features PIN and port Description Embedded C Hardware Interfacing and Coding

Page 3: embedded system and AVR
Page 4: embedded system and AVR

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

- BIOTECHNOLOGY

-TELECOME

- MILTARY

- AUTOMOBIEL

- CONSUMER ELECTRONICS

Page 5: embedded system and AVR

APPLICATION

Page 6: embedded system and AVR

AVR (ADVANCED VIRTUAL RISC) ATMEGA 8

MICRO-CONTROLLER

Page 7: embedded system and AVR

INTRODUCTION

• ATmega8 is a 8-bit microcontroller based on the AVR RISC architecture

• 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 pipelining

• This concept enables instructions to be executed in every clock cycle

Page 8: embedded system and AVR

FEATURES

• High-performance 8 bit Microcontroller• 32 x 8 General Purpose Working Registers• Six ADC channels in PDIP package• Internal Calibrated Oscillator

Page 9: embedded system and AVR

MEMORY SEGMENTS

• 8K Bytes of Flash program memory• 512 Bytes EEPROM (Electrically Erasable Programmable Read

Only Memory)• 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

Page 10: embedded system and AVR

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

Page 11: embedded system and AVR

PIN OUTPLASTIC DUAL IN-LINE PACKAGE

Page 12: embedded system and AVR

PIN DESCRIPTION

• 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 running

• AREF The analog reference pin for the A/D Converter• AVCC The supply voltage pin for the A/D Converter

Page 13: embedded system and AVR

• Three ports i.e PortB, PortC, PortD -General Purpose 8 Bit bidirectional I/O

• Three registers associated with every portDDRx – Data Direction RegisterPINx – Port inputPORTx- Port output

*Note – ‘x’ is subscript and could be either of B, C, D

PORTS

Page 14: embedded system and AVR

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)

Page 15: embedded system and AVR

REGISTER DESCRIPTION OF I/O PORTS

Page 16: embedded system and AVR

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>,

<util/delay.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,

do-while etc.

Programming Microcontroller

Page 17: embedded system and AVR

SOFTWARE’S USED:

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

Page 18: embedded system and AVR

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".

1. 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.

Page 19: embedded system and AVR

CONTD…

Step3. Debug platform should be "AVR Simulator". Device Is "ATMEGA 8".Step4. Click Finish. You will now be in the IDE.

Page 20: embedded system and AVR

CONTD…

Page 21: embedded system and AVR

CONTD…

.

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 LEDs on.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.

Page 22: embedded system and AVR

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 warnings.If there is an error, check your code for typos. The error message should give you the offending line numberA 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 "AVR\src\MyFirstProject\default\".

Page 23: embedded system and AVR

CONTD….

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 shortcut.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.

Page 24: embedded system and AVR

CONTD…

Step 8. Step through the program line by line with "STEP INTO (F11)" button.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.

Page 25: embedded system and AVR

SOME EXAMPLES USING EMBEDDED C1. Blinking of even no. lights at port

Page 26: embedded system and AVR

HARDWARE INTERFACING'S AND CODING:

Seven Segment Interfacing with Microcontroller

LCD interfacing with Microcontroller

Page 27: embedded system and AVR

7 SEGMENT DISPLAY

Page 28: embedded system and AVR

CONTD…

Page 29: embedded system and AVR

LCD(4-BITS) INTERFACING

PB0/ICP114

PB1/OC1A15

PB2/SS/OC1B16

PB3/MOSI/OC217

PB4/MISO18

PB5/SCK19

PB6/TOSC1/XTAL19

PB7/TOSC2/XTAL210 PC6/RESET 1

PD0/RXD 2

PD1/TXD 3

PD2/INT0 4

PD3/INT1 5

PD4/T0/XCK 6

PD5/T1 11

PD6/AIN0 12

PD7/AIN1 13

PC0/ADC0 23

PC1/ADC1 24

PC2/ADC2 25

PC3/ADC3 26

PC4/ADC4/SDA 27

PC5/ADC5/SCL 28

AREF21

AVCC20

U1

ATMEGA8

D714

D613

D512

D411

D310

D29

D18

D07

E6

RW5

RS4

VSS

1

VDD

2

VEE

3

LCD1LM016L

Page 30: embedded system and AVR

LCD(8-BITS) INTERFACING

D714

D613

D512

D411

D310

D29

D18

D07

E6

RW5

RS4

VSS

1

VDD

2

VEE

3

LCD1LM016L

PB0/ICP114

PB1/OC1A15

PB2/SS/OC1B16

PB3/MOSI/OC217

PB4/MISO18

PB5/SCK19

PB6/TOSC1/XTAL19

PB7/TOSC2/XTAL210 PC6/RESET 1

PD0/RXD 2

PD1/TXD 3

PD2/INT0 4

PD3/INT1 5

PD4/T0/XCK 6

PD5/T1 11

PD6/AIN0 12

PD7/AIN1 13

PC0/ADC0 23

PC1/ADC1 24

PC2/ADC2 25

PC3/ADC3 26

PC4/ADC4/SDA 27

PC5/ADC5/SCL 28

AREF21

AVCC20

U1

ATMEGA8

Page 31: embedded system and AVR

THANK YOU…