0% found this document useful (0 votes)
0 views70 pages

Embedded Systems (Class) - Copy (2)

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
0 views70 pages

Embedded Systems (Class) - Copy (2)

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 70

AVR Architecture

 Von Neumann

 Harvard

Abrham Debasu (Assistant Professor)


QN

What is the difference between these two architecture?

Which architecture is effective?

Abrham Debasu (Assistant Professor)


Von Neumann Machine

How many registers found in von Neumann machine?

Abrham Debasu (Assistant Professor)


Register Organization

AC

MQ
MBR
IR

IBR
PC and MAR

Abrham Debasu (Assistant Professor)


How von Neumann machine works?

Abrham Debasu (Assistant Professor)


How IBR increase computational time?
Abrham Debasu (Assistant Professor)
When Fetching cycle is completed?

Abrham Debasu (Assistant Professor)


Abrham Debasu (Assistant Professor)
Von Neumann block diagram of AVR

MC
Memory

Program/Instruction
Bus

Data

Abrham Debasu (Assistant Professor)


Von Neumann AVR

Single R/W memory

Single bus

One clock cycle

No complicated circuit

Abrham Debasu (Assistant Professor)


Harvard Architecture block diagram

Instruction/ Program

MC

Data

Abrham Debasu (Assistant Professor)


Harvard AVR

Different memory for data and Instruction or program

Different bus

Two clock cycle

Complicated circuit

Abrham Debasu (Assistant Professor)


Which model is suitable?

It depends on the problem domain

If there are numbers of embedded system so Harvard


is better

For only finger print reader Von Neumann is


suitable

Abrham Debasu (Assistant Professor)


AVR Microcontroller Architecture

I/O Status Register


……..

Program
memory
PC
or Register file

ALU
Flash memory
32KB
Data
Memory
Instruction
register

Instruction
Decoder
Abrham Debasu (Assistant Professor)
Which type is it?

How do we know?

How it works?

What will be the incrementing size


of PC?

Abrham Debasu (Assistant Professor)


Execution cycles of AVR Microcontroller

Instruction Fetching Cycle (IF)


Execution Cycle

Similar with IAS or Von Neumann machine/8086MP

Abrham Debasu (Assistant Professor)


Instruction Fetching Cycle (IF)

Program counter
Program
Memory
Read Update

Instruction Register

Instruction Decoder

Abrham Debasu (Assistant Professor)


Execution Cycle

Write Write

ALU
Register File Memory

Process Write

 Register operand fetch (ROF)


 ALU execution
 Result write back (RWB)

Abrham Debasu (Assistant Professor)


Addressing Modes
What is addressing mode ?
 A mechanism by which the microcontroller get an operand
 Immediate Mode

 Register Mode

 Register Mode

 Data Direct Mode

 Data Indirect Mode

 Data indirect with displacement

 Read about data indirect pre increment and decrement


Abrham Debasu (Assistant Professor)
Immediate Addressing Mode

LDI Dest, Src

Dest = Register from R16 to R31

Src=K= immediate

Abrham Debasu (Assistant Professor)


Register Mode
15 0
f1 Register File

OP

In MP MUL BX but in AVR INC R20

Abrham Debasu (Assistant Professor)


Data Direct Mode
31 16
Inst Memory
Data Memory

15 0

OP

Abrham Debasu (Assistant Professor)


Data Indirect Mode
15 0
Inst Register Memory

@ OP

Abrham Debasu (Assistant Professor)


Data indirect with displacement
15 0
f2 f1 DMEM

Register File

OP

Abrham Debasu (Assistant Professor)


Research points

Embedded system for Amharic OCR

Designing Scale and position invariant figure print Embedded system

Enhancing humanoid robot embedded system using KNN for……


Environmental Monitoring

Enhancing embedded vision system using image processing for color detection,
An Automatic Recognition of Fake Birr Note Using Raspberry Pi and ML

Embedding machine learning to embedded system for <agriculture>, <health> <IOT>

Abrham Debasu (Assistant Professor)


Chapter 3

Instruction Set

Abrham Debasu (Assistant Professor)


What is instruction sets

 A binary pattern

 Memory Reference instruction


 Register Reference Instruction
 I/O (SFR) Reference instruction

Abrham Debasu (Assistant Professor)


QN

How we can differentiate the given instruction?

Suppose that 1110111000101101

What type of instruction is it ?

Abrham Debasu (Assistant Professor)


Memory Reference Instruction

15 14 12 11 0
I OPCODE Memory Address

 OPCODE= 000-110
 I= Addressing mode
 If I=0 Direct
 If I=1 Indirect

Abrham Debasu (Assistant Professor)


Register Reference Instruction

15 14 12 11 0
0 OPCODE (111) Register operation

Abrham Debasu (Assistant Professor)


I/O (SFR) Reference Instruction

15 14 12 11 0
1 OPCODE (111) I/O Operation

Abrham Debasu (Assistant Professor)


AVR instruction sets

 Data transfer instruction


LDI, LDS, MOV…

 Arithmetic instruction
ADD, SUB, MUL, INC, DEC….
 IN and OUT
 Bit and Bit test (Reading Assignment)

Abrham Debasu (Assistant Professor)


LDI (LOAD IMMIDIATE)

Format

LDI Rd,K

Note that K is 8 bit


0-255 (decimal)
00-FF(Hex) and Rd should be R16 to R31

LDI R20, 0X25, Load the immediate value 25 in hex to R20

We cannot load values into registers R0 to R15 using LDI


LDI R5,0X79 (Invalid)

Abrham Debasu (Assistant Professor)


LDI (LOAD IMMIDIATE)

How it Works

Program PC
memory Register file

ALU
32KB

Instruction
register
LDS (Load Instruction from data space)

It loads one byte from an address of data memory to the GPR

After execution both data memory and GPR consists of same value

Format
LDS Rd,K
K should be an address between 0x0000 to 0xFFFF

An immediate value cannot be stored directly to SRAM. But we can


use GPR

Abrham Debasu (Assistant Professor)


LDS (Load Instruction from data space)

How it works

Program PC
memory Register file

ALU
32KB Data
Memory
Instruction
register

Abrham Debasu (Assistant Professor)


ADD

or

Abrham Debasu (Assistant Professor)


ADD

How it works

I/O Status Register

Program
memory Register file

ALU
32KB Data
Memory
Instruction
register

Abrham Debasu (Assistant Professor)


INC
Single operand instruction

Format
INC Rd ; 0<=Rd<=31

Example
INC R20; R20=R20+1

Abrham Debasu (Assistant Professor)


IN (Input from I/O location)

Load one byte from I/O to GPR

Format
IN Rd, K
K should be port of I/O

Example

IN R20, 0x16; copy the contents of I/O location 16 in hex to R20

Abrham Debasu (Assistant Professor)


How it works

I/O

Program
memory Register file

ALU
32KB

Instruction
register

Abrham Debasu (Assistant Professor)


OUT (Output to I/O location)

To store GPR values to I/O

Format
OUT A, Rd; A is I/O port

Example
OUT 0x16, R20

Abrham Debasu (Assistant Professor)


Chapter 4

PIN CONFIGURTION

Reading assignment

Abrham Debasu (Assistant Professor)


Pinout Description of AVR Microcontroller

Abrham Debasu (Assistant Professor)


Abrham Debasu (Assistant Professor)
Chapter 5

Branch, Call and Delay loop

Abrham Debasu (Assistant Professor)


CALL and LOOP in 8086 MP

DOS FUNCTION CALLS (INT 21H)

DOS function calls preserve the contents of all the registers except the
AH register and any other register or registers in which they explicitly
return data.

Call the above function found in AH Register

Abrham Debasu (Assistant Professor)


TERMINATE PROGRAM (INT 21H or 4CH)

Assembly Language C Language Meaning

mov AH , 4Ch exit(0) Program terminates normally


int 21h or int 20

Abrham Debasu (Assistant Professor)


CHARACTER INPUT

The Codes The Result

mov AH, 01h The program is waiting for the input. Once a
int 21h user presses a key, the ASCII Code of the
input character is returned in the AL register
and the input character is displayed as well.

Abrham Debasu (Assistant Professor)


CHARACTER OUTPUT

The Initial requirement The result

AH = 02h The character stored in DL will be


displayed.
DL = Character or ASCII Code

LOOP
Execute the given statement until CX=0
COMPARE (CMP)
Destination –sources and check the final result
No where stored the final result only checking the sign flag

Abrham Debasu (Assistant Professor)


EXAMPLE

Abrham Debasu (Assistant Professor)


AVR branches

BREQ - Branch if Equal

Tests the Zero flag (Z) and branches relatively to PC if Z is set to 1. If the instruction
is executed immediately after any of the instructions CP (Compare)

Abrham Debasu (Assistant Professor)


BRNE - Branch if Not Equal

Tests the Zero flag (Z) and branches relatively to PC if Z is cleared. If the

instruction is executed immediately after any of the instructions cp.

Read chapter 3 of Mohammed Ali AVR microcontroller Book

Abrham Debasu (Assistant Professor)


Laboratory session

Abrham Debasu (Assistant Professor)


Basics of Arduino UNO

Is a microcontroller (open source hardware) for prototyping)

It uses a simplified version of c++ language

Abrham Debasu (Assistant Professor)


Major components of Arduino UNO

Abrham Debasu (Assistant Professor)


Microcontroller

It is the brain of the Arduino


Consists of 28 pins
It uses Atmega 328P (microcontroller produced by Atmel

Abrham Debasu (Assistant Professor)


Atmega 328P Microcontroller
Has the following components
Flash Memory
RAM
CPU
EEPROM

Atmega328P

Abrham Debasu (Assistant Professor)


Working with ultrasonic sensor

Abrham Debasu (Assistant Professor)


How Does it Work?

Abrham Debasu (Assistant Professor)


Materials
 HC-SR04 ULTRA SONIC SENSOR
 JUMPER WIRES

 ARDUINO UNO
 ARDUINO IDE SOFTWARE

Abrham Debasu (Assistant Professor)


Abrham Debasu (Assistant Professor)
Abrham Debasu (Assistant Professor)
Abrham Debasu (Assistant Professor)
Working with ultrasonic sensor and LED light

 HC-SR04 ULTRA SONIC SENSOR


 ARDUINO UNO
 JUMPER WIRES
 ARDUINO IDE SOFTWARE
 LED LIGHT FOR NOTIFICATION

Abrham Debasu (Assistant Professor)


Abrham Debasu (Assistant Professor)
Abrham Debasu (Assistant Professor)
Seven segment display

Abrham Debasu (Assistant Professor)


Hardware Required
•1 x seven segment display (common cathode)

•1 x Arduino

•1 x breadboard

•Regulators

•jumper wires

Abrham Debasu (Assistant Professor)


Abrham Debasu (Assistant Professor)

You might also like