Embedded System and IOT Design Lakshmi Book
Embedded System and IOT Design Lakshmi Book
Page l of 440
SYLLABUS
ANNAUNIVERSITY, CHENNAI
EMBEDDED SYSTEMS AND IoT DESIGN
g
UNIT I 8051 MICROCONTROLLER [CHAPTERS 1,2, 3J 9
in
Microontröllers for an Embedded System 8051 - Architecture - Addressing Modes
er
-
Instruction Set Program and Data Memory - Stacks - Interrupts - Timers/Counters -
-
e
Serial Ports Programming.
in
UNIT II
EMBEDDED SYSTEMS [CHAPTERS 4, 5, 61 9
ng
Embedded System Design Process Model Train Controller ARM Processor
-
Instruction Set Preliminarics CPU – Programming Input and Output - Supervisor Mode
fE -
Exceptions and Trap -
Models for programs Assembly, Linking and Loading
- Program Level Performance Analysis.
O
Compilation Techniques
UNIT II
Structure ofa real- time system - Task Assignment and Scheduling - Multiple Tasks and
g
le
-
ad
–
YANG – IoT Platform Design Methodology IoT Reference Model
-
loT Reference Architecture loT Protocols MQTT,
XMPP,
Ta
Communication Model
Modbus, CANBUS and BACNet.
Page 2 of 440
CONTENTS
UNIT -I
g
Chapter 1
in
8051 MICROCONTROLLER
er
1.1-1.35
INTRODUCTION...
e
1.1 1.1
in
1.1.1 8051 Microcontrollers Fanily 1.2
ng
1.1.2 Comparison of Microcontroller with Microprocessor... 1.4
1.1.3 8051 Microcontroller Pin Diagram and Pin Descriptions 1.5
1.2
fE
MICROCONTROLLERS FOR AN EMBEDDED SYSTEM... 1.8
O
1.2.1 Applications of Embedded Products Using Microcontrollers.... 1.9
1.3 8051 ARCHITECTURE. 1.10
g e
1.4.2 1.14
ad
Chapter2
8051 INSTRUCTION SET..... ..2.1-2.56
2.1 INSTRUCTION SET OF 8051.. 2.1
2.1
2.1.1 Introduction.
<br>
Page 3 of 440
g
2.2.5 Data Exchange Instructions 2.12
in
ARITHMETIC INSTRUCTIONS. 2.13
er
2.3
2.3.1 ADD A, Ssource byte. -2.14
e
in
2.3.2 ADDC A, source byte 2.15
ng
2.3.3 SUBB A, source byte. 2.17
INSTRUCTIONS 2.24
u
2.4.4 CLR...
2.33
Ta
-2.4.5 CPL.
2.34
2.4.6 Rotate and Swap Instructions
.. 2.38
2.5 BIT- ORIENTED INSTRUCTIONS
2.38
2.5.1 CLR Bit
2.38
2.5.2 SETB bit...
2.39
ANL C, - bit...
2.5.3 Source
*.. 2.39
2.5.4 ORL C, source-bit.... 2.40
2.5.5 MOVdest-bit, source-bi..
<br>
Page 4 of 440
Contents |C3
g
2.6.3 JUMP Instructions 2.43
in
2.7 TWO MARKS QUESTIONS AND ANSWERS. 2.49
er
2.8 REVIEW QUESTIONS.... 2.56
e
in
ng
Chapter 3
fE ....
PROGRAM AND DATA MEMORY 3.1-3.44
PROGRAM AND DATAMEMORY: 8051 MICROCONTROLLER
O
3.1
EXTERNAL MEMORIES... 3.1
MEMORY ORGANIZATION:INTERNAL AND
e
2 3.1
3.1.1 Introduction...
g
Microcontroller.. 3.2
2 3.1.2 Program Memory (ROM) of 8051
le
3.3
3 3.1.3 Data Memory (RAM).
ol
Microcontroller.. 3.6
3.1.4 Interfacing External Memory with 8051
C
4 3.7
3.2 STACKS.
3.7
u
24 Introduction
3.2.1
3.8
ad
27:
3.2.2 PUSH and POP Operation:
3.9
30 3.2.3 Other Instructions.
iln
INTERRUPTS IN 8051
32 3.3 8051 INTERRUPTS (OR)
.... 3.9
m
MICROCONTROLLER
33 3.9
Introduction..
Ta
3.3.1
.34 3.10
3.3.2 Interrupt Service Routine (1SR)...
.3.11
.38 Steps in Executing,an
Interrupt.
3.3.3 3.12
!.38 Vèctored Interrupts.
3.3.4 Six Interrupts in the 8051: .
3.13
2.38 an Interrupt...
3.3.5 Enabling and Disabling 3.14
2.39 8051/52.
3.3.6 Interrupt Priority in the
3.15
2.39 3.4 PROGRAMMIG 8051 TIMERS: TIMERS
2.40
<br>
Page 5 of 440
g
Mode 2 Programming. 3.21
3.4.6
in
COUNTER PROGRAMMING 3.22
er
3.5
3.5.1 CIT bit in TMOD Register. 3.22
e
TCON Register: Timer/ Counter Control Register... 3.25
in
3.5.2
GATE = 1 in
TMOD.. 3.27
ng
3.5.3
3.6 8051 SERIAL PORT PROGRAMMING. 3.28
3.6.1 8051 Connection to RS232
fE 3.28
Baud Rate in 8051 3.29
O
3.6.2
3.6.3 SBUF Register.. 3.30
e
3.6.5 3.33
ol
UNIT -II
Ta
Chapter 4
EMBEDDED COMPUTING ,4.1-4.34
4.1 EMBEDDED SYSTEM DESIGN PROCESS 4.1
4.1.1 Introduction... 4.1
4.1.2 Steps. .4.2
4.1.3 Requirements 4.3
4.1.4 Specification 4.7
<br>
Page 6 of 440
Contents
C.5
4.1.5 Architecture Design
4.7
4.1.6 Designing Hardware and Software Components.
4.9
4.1.7 System Integration...
4.9
4.1.8 Fomalisms for System Design
4.10
4.1.9 Structural Description ..
4.10
g
4.1.10 Behavioral Description
in
4.15
4.2 DESIGN EXAMPLE: MODEL TRAIN CONTROLLER ....
er
4.18
4.2.1 Introduction..
e
4.18
4.2.2 Requirements.
in
4.20
4.2.3 Digital Command Control (DCC)....
ng
4.20
4.2.4 Conceptual Specification. 4.22
4.2.5 Detailed Specification
fE 4.25
4.3 TWO MARKS QUESTIONS AND ANSWERs.
O
4.31
4.4 REVIEW QUESTIONS.
4.33
g e
Chapter5
le
ol
Page 7 of 440
Chapter 6
CPUS 6.1-6.41
6.1 PROGRAMMING INPUT AND OUTPUT 6.1
6.1.1 Input and Output Devices... ...
6.1
g
Input and Output Primitives
in
6.1.2 6.2
Busy-Wait /O.
er
6.1.3 6.2
6.1.4 Interrupts.... 6.3
e
in
6.2 SUPERVISOR MODE. 6.8
ng
6.2.1 ARM Operating Modes.
6.8
6.3 EXCEPTIONS 6.9
6.3.1 Introduction..
fE 6.9
6.3.2 Exceptions and Modes.
O
6.10
6.4. TRAPS 6.11
e
6.11
le
6.15
ad
6.6.1 Introduction.
6.15
6.6.2 Assemblers.
6.18
iln
6.6.3 Linking
6.19
m
Page &
of 440
C'ontents C.7
6.8.4 Measurement-Driven Performance Analysis... 6.31
6.9 TWO MARKS QUESTIONS AND ANSWERS.
6.33
6.10 REVIEW QUESTIONS. ...
6.41
UNIT - II
g
in
er
Chapter 7
e
PROCESSES AND OPERATING SYSTEMS.... 7.1-7.26
in
ng
7.1 STRUCTURE OFAREAL-TIME SYSTEM. 7.1
7.1.1 Introduction. 7.1
7.1.2 Structure of Embedded System
fE 7.2
O
7.1.3 Structure of Embedded Real-time System.. 7.3
7.2 TASK ASSIGNMENT AND SCHEDULING 7.5
e
Introduction ..
g
7.2.1 .7.5
le
Page 9 of 440
g
in
er
Chapter 8
e
in
NETWORKS AND MULTIPROCESSORS ...8.1-8.32
ng
8.1 PRIORITY-BASED SCHEDULING 8.1
8.1.1 Introduction... fE 8.1
8.1.2 Rate-Monotonic Scheduling (RMS).. 8.2
O
8.1.3 Earliest-Deadline-First (EDF) Scheduling 8.5
8.1.4 Shared Resources. 8.6
g e
..... .8.11
8.3.1 Introduction.
Ta
Page 10 of 440
Contents C.9
8.5 REVIEW QUESTIONS.
8.32
Chapter9
MPSOCs AND SHARED MEMORY MULTIPROCESSORS...9.1-9.28
g
MPSoCs AND SHARED MEMORY MULTIPROCESSORS
9.1
.. 9.1
in
9.1.1 Introduction 9.1
er
9.1.2 Heterogeneous Shared Memory Multiprocessors. 9.2
e
9.1.3 Accelerators. 9.2
in
9.1.4 Accelerator Performance Analysis : .... 9,4
Scheduling and Allocation ...
ng
9.1.5 9.7
9.2 DESIGN EXAMPLE: AUDIO PLAYER fE 9.8
9.2.1 Theory of Operation and Requirements... 9.8
O
9.2.2 Specification .9.11
...
9.2.3 System Architecture.
e
9.12
g
...
9.3.1 Theory of Operation and Requirements. 9.14
u
9.3.4 9.18
9.3.5 System Integration and Testing. 9.18
m
Page 11 of 440
UNIT - IV
Chapter 10
INTERNET OF THINGS (IoTs) 10.1-10.37
g
10.1 INTRODUCTION. 10.1
in
10,1.1 Applications 10.1
er
10.1.2 Definition and Characteristics of loT
10.3
e
10.2 PHYSICAL DESIGN OF IloT. 10.4
in
10.2.1 Things in loT. 10.4
ng
10.2.2 loT Protocols.. 10.5
10.3 LOGICAL DESIGN OF loT. fE 10.11
10.3.1 loT Functional Blocks 10.11
O
10.3.2 loT Communication Models.
10.12
e
10.22
10.5:1 Introduction ....
10.22
m
Page 12 of 440
Contents
C.l1
10.5.11 Health &Lifestyle...
10.33
10.6 TWO MARKS QUESTIONS AND ANSWERS.
10.33
10.7 REVIEW QUESTIONS.
10.37
Chapter 11
g
.. 11.1- 11.40
in
MACHINE -TO- MACHINE (M2M)
er
11.1 loT AND M2M
Introduction..
11.1
e
11.1.1
in
11.1
11.1.2 M2M Architecture.
ng
.11.1
.
11.1.3 Difference between loT and M2M.. 11.3
11.1.4 SDN and NFV for loT
fE 11.4
O
11.2 loT SYSTEM MANAGEMeNT WITH NETCONF-YANG 11.9
11.2.1 Need for loT Systems Management 11.9
g e
11.4.2 11.21
11.4.3 loTReference Model: Domain Model 11.25
m
Page 13 of 440
UNIT -V
CHAPTER 12
IoT PHYSICAL DEVICES. 12.1-12.11
DEVICE. 12.1
BASIC BUILDING BLOCKS OF AN loT
g
12.1
in
Pi. 12.3
12.2 RASPBERRY
er
12.3
12.3 RASPBERRY PiBOARD
e
12.5
12.4 LINUX ON RASPBERRY Pi....
in
12.5
12.4.1 Introduction.
ng
12.5
12.4.2 Installation...
12.7
12.5 RASPBERRY Pi INTERFACES fE 12.9
12.6 PROGRAMMING RASPBERRY Pi WITH PYTHON
O
12.9
12.6.1 Controlling LED with Raspberry Pi....
12.10
e
12.10
12.7.2 Smart Cities.
ol
12.10
12.7.3 Environment
C
12.10
12.7.4 Agriculture.
12.10
u
12.11
12.9 REVIEW QUESTIONS..
iln
Page 14 of 440
UNIT-I
Chapter 1
g
in
8051 MICROCONTROLLER
e er
in
1.1 INTRODUCTION
ng
A Microprocessor:
The microprocessor is fE
general purpose digital computer central processing
a
Arithmetic
Working
Accumulator and logic
registers(s)
ol
unit
C
u
ad
iln
m
Stack Interrupt
Ta
Program
counter
Page 15 of 440
g
in
1.1.1 8051 Microcontrollers Family
er
a Definition:
e
in
The microcontroller incorporates all the features that are found in
ng
microprocessor, but they are designed to work as a true single-chip system
that is, it can integrate all the devices needed for a system on a single-chip
fE
which is optimized for specific applications.
O
The basic functional units of a microprocessor will be ALU,set of
registers,
timing and control unit. The microcontroller will have these functional
e
and EPROM/EEPROM.
ol
The first 8 bit microcontroller called 8048 was introduced by Intel in 1976 which
u
control general tasks. The 8051 is the original member of the 8051 family. Intel
ad
refers to it as MCS-51.
The 805l was designed for 8-bit nathematical and single bit Boolean
iln
operations. These families provide separate program and data nmemory which
m
Page 16 of 440
8051 Microcontroller
1.3|
16-bit unidirectional address bus.
- 32 bidirectional VO lines organized as
four 8-bit ports.
16 bit timners (usually 2, but may have more or less).
16-bit program counter and data pointer.
Interrupt structure with two priority levels.
g
in
- On chip oscillator and clock circuits.
er
Full duplex serial data transmitter/receiver.
Direct bit and byte addressability.
e
in
Binary or decimal arithmetic.
ng
Signed-overflow detection and parity computation.
Feature
ROM
fE Quality
4K bytes
O
RAM 128 bytes
Timer 2
e
I/O pins 32
g
Serial port
le
Interrupt sources 6
ol
The other two members in the 8051 family of microcontrollers are 8052 and
u
8031.
ad
Timers 2 3
Ta
I/O pins 32 32 32
Serial port 1 1
Interrupt sources 6 8 6
Page 17 of 440
g
in
Sr.NO Microprocessor Microcontroller
er
1. The functional blocks of a The microcontroller includes the
microprocessor are the ALU, functional blocks of a
e
in
registers, timing and control unit. microprocessor and in addition has
a memory, I/O interfacing circuit
ng
and peripheral devices such as
fE ADC, DAC, timer etc.
2. It has several instructions to move It has one or two instructions to
O
data between memory and CPU. move data between memory and
CPU.
e
3.
designing general purpose digital
le
instructions. instructions.
u
5. Memory and I/O devices access Less access time for built-in
ad
the
reliability.
Ta
Page 18 of 440
8051 Microcontroller
| 1.5|
1.1.3 8051 Microcontroller Pin Diagram and Pin Descriptions
The S0S1 miccontroller is a popular 8-bit microcontroller
widely used in
cmbeddcd systems. It has a 40-pin Dual In-line Package
(DIP) that provides
various inputs and outputs for communication with external devices.
g
in
(P1,0 1
er
40
P1.1 C2 PO.0 (AD0)
39
e
P1.2 3 P0.1 (AD1)
in
38
Port 1
P1.3 4 37 P0.2 (AD2)
ng
P1.4 5 36 P0.3 (AD3)
P1.5
P1.6
6 fE 35 PO.4 (AD4) Port 0
7 34 PO.5 (AD5)
O
P1.7 C8 33 P0.6 (AD6)
RST
e
32 PO.7 (AD7)
8051
g
(TXD) P3.1 11
30 ALE/PROG
ol
22
GND 20 21 P2.0 (A8)
pins.
<br>
Page 19 of 440
|1.6
Embedded Systems and 10T Design
as an
() iflogic I (one) is applied to the l/O port it will act input pin.
as an output pin.
(i) If logic 0 (zero) is applied to the l/O port it will act
Pin-9 (RST):
to its initial
It isReset pin, which is used to reset the 8051 microcontrollers
a
g
values when logic 1 is applied to this pin. It is an active-high input pin.
in
er
Pin 10 to Pin 17: Port-3
assigned to port 3 which is also a bidirectional I/O port like
e
-
Pin 10 17 are
in
port 1. This port performs some special functions like interrupts, control
ng
pins
signals, timer inpt, serial communication etc. The detail function of cach
arcgiven in 1able 1.3: fE
Pin No Symbol Use
O
10 RXD Serial data receive pin.
Serial data transmit pin.
e
11 TXD
g
1
External interrupt input.
ol
13 INTI
C
15 TI
ad
Table 1.3
Ta
These pins are used for interfacing external oscillator. Mostly, a quartz crystal
oscillator is connected here to get the system clock.
Pin 20 (GND):
Page 20 of 440
8051 Microcontroller
:
Pin 21 to Pin 28 Port 2
Pin 21 to Pin 28 are port 2 pins which is also a bidirectional
Input /0utput port
i.e., all pins of port 2 work as a input pin or as a output pins. But, this is only
possible when we are not using any external memory.
If we use external memory, then these pins will work as high order address bus
g
(A8 to Al5).
in
er
Pin 29 (PSEN)
e
PSEN stands for Program Store Enable. It is an active-low output
pin which is
in
used to read an external memory.
ng
Pin 30 (ALE/PROG)
fE
ALE stands for Address Latch Enable. It is an active-high input pin which is
O
used to distinguish between memory chips when multiple memory chips are
e
used.
g
It is also used to de-multiplex the multiplexed address and data signals available
le
at port 0.
ol
C
Pin 31 (EAVpp)
u
It is the External Access (EA) enable pin which allows external program
ad
Page 21 of 440
Pin 40 (Vcc):
This pin is used to provide (+5V) power supply to the 8051 microcontroller
circuit.
g
1.2 MICROCONTROLLERS FOR AN EMBEDDED SYSTEM
in
Embedded System:
er
An embedded system is combination of computer hardvare and sofhvare
a
e
a comnbination
designed for a specifc function. It is a computer system which is
in
memory, and input/output peripheral devices
of a computer processor, computer
ng
that has a dedicated function within a larger mechanical or electronic systen.
General
Data bus
fE
Purpose
O
Micro Serial
Processor I/O Timer
RAM ROM COM
e
Port Port
g
le
CPU
Address bus
ol
C
Microcontroller
iln
Serial
Ta
(b) Microcontrollers
Fig 1.3
Microprocessors and microcontrollers are widely used in embedded system
products.
<br>
Page 22 of 440
Example:
Aprinter is an example of embedded system since the processor inside it
g
performs only one task: getting the data and printing.
in
4 A Pentium-based PC, in contrast with the embedded system, can be used for any
er
number of applications such as word processor, print server, bank teller
e
terminal, video game player, network server, or internet terminal. It has RAM
in
memory and an operating system that loads a variety
ng
of applications into RAM
and lets the CPUto run them.
fE
A PC contains or is connected to various embedded products. Each one
peripheral has a microcontroller inside it that performs only one task.
O
Very often the terms embedded processor and microcontroller are used
e
functions on the CPU chip and let designer decide which features he/she wants to
use.
u
ad
() Home
m
answering machines, fax machines, home computers, TVs, cable TV tuner, VCR,
camcorder, remote controls, video games, cellular phones, musical instruments,
sewing machines, lighting control, paging, camera, pinball machines, toys,
exercise equipment.
(ii) office
Telephones, computers, securiy systems, fax machines, microwave, copier, laser
printer, color printer, paging.
<br>
Page 23 of 440
(ii) Auto
Trip computer, engine control. air bag, ABS, instrumentation, security system
entry.
g
1.3 8051 ARCHITECTURE
in
er
1.3.1 Introduction
e
8051 miicrocontroller is designed by Intel in 1981. It is an 8-bit microcontroller
in
which is built with 40 pins Dual Inline Package (DIP), 4K byte of on-chip ROM
ng
storage, 128 bytes of RAM storage, two 16-bit timers, one serial port, and four
ports all on a single chip. fE
It consists offour parallel 8-bit ports, which are programmable as well as
O
addressable as per the requirement. An on-chip crystal oscillator is integrated in
the microcontroller having a crystal frequency of 12 MHz.
g e
External
le
Interrupts
ol
for ON-CHIP
Interrupt ETC
program RAM
control TIMER O
code
u
Counter
TIMER
1J Inputs
ad
iln
System bus
CPU
m
Ta
30 PF:
30PF TXD RXD
Address/Data
4 to 30 MHz
Page 24 of 440
g
in
1.3.2 Functional Blocks
er
The basic functional blocks (or) components present internally
inside 8051
e
microcontroller architecture are as follows:
in
(0) CPU(Central Processing Unit):
ng
CPUacts as. a mind of any processing machine. It synchronizes and manages
fE
all processes that are carried out in microcontroller. User has no power to
control the functioning of CPU.
O
It interprets the program stored in ROM and carries out from storage and then
e
(ii) Interrupts:
C
Page 25 of 440
The timer and serial interrupts are internally produced by the microcontroler.
devices
whereas the external interrupts are produced by additional interfacing
or switches that are externally connected with the microcontroller. These
external interrupts can be level triggered or edge triggered.
(iii) Memory:
g
a program which guides the
in
For the operation of microcontroller, it requires
microcontroller to perform the specific tasks. For that, it uses a chip
mnemory
er
for the storage of the program.
e
in
Microcontroller also required meimory for storage of data and operands for
ng
the short duration. It uses code or program memory of 4 KB that is, it has
4 KB ROM and it also comprises of data memory (RAM) of 128, bytes.
fE
(iv) Bus:
O
Bus is a group of wires which uses as a communication channel to data
transfer. The different bus configuration includes 8, 16 or more cables.
e
(v) Oscillator:
Page 26 of 440
8051 Microcontroller
|1.13|
1.4 INSIDE THE 8051
1.4.1 Registers
# Registers are used to store information temporarily, while the information could
be a byte of data to be processed, or an address pointing to the
data to be
fetched.
g
in
In the Fig 1.5, the 8 bits ofa register are shown from MSB D7 to the LSB DO.
With an 8-bit data type, any data larger than 8 bits must be broken into 8-bit
er
chunks before it is processed.
e
in
most least
ng
significant bit significant bit
fE
D7 D6 D5 D4 D3 D2 D1 DO
O
Fig 1.5 8-bit register
e
The most widely used registers of the 8051 are A (accumulator), B, RO, R1, R2,
g
le
R3, R4, RS, R6, R7, DPTR (data pointer), and PC (program counter).
ol
A
C
u
ad
RO
iln
R1
m
R2
Ta
R3
R4
R5
R6
R7
Page 27 of 440
All of the above- registers are 8-bits, except DPTR and PC. The
accumulator
g
in
to point to the address of the next instruction to be executed.
er
A Data Pointer (DTPR):
e
It is used by the 8051 to access external memory using the address indicated by
in
DPTR register which is 16 bit, it can also be accessed as wo 8-bit registers,
ng
DPH and DPL, where DPH is high byte and DPL is the low byte.
DPTR DPH
fE DPL
O
PC PC (program counter)
g e
le
Fig 1.7
ol
a, The Program Status Word (PSW) register lso referred to as the flag register
which is an 8 bit register but only 6 bits are used by the 8051.
u
ad
CY AC FO RS1 RS0 OV P
m
Page 28 of 440
g
in
RS1 PSW.4 Register bank selector bit 1.
er
RS0 PSW.3 Register bank selector bit 0.
e
in
OV PSW.2 Overflow flag.
ng
PSW.1 User-definable bit.
P PSW.0 fE
Parity flag. Set/cleared by hardware each instruction
cycle to indicate an odd/even number of 1 bits in the
O
accumulator.
e
Fig 1.8Bits of
the PSW Register
g
A Flags:
le
The two unused bits are called as user-definable flags and the remaining four
ol
flags are called as conditional flags which indicate some conditions that resulted
C
i) Carry(cY) Flag:
This flag is set whenever there is a carry out from the D7 bit. This flag bit is
iln
"CLR C" where "SETB C" stands for set bit carry" and "CLR C" for
"clear carry".
(i) Auxiliary Carry (AC) Flag:
If there is a carry from D3 to D4 during an ADD or SUB operation, this bit is set;
otherwise, it is cleared. This flag is used by the instructions that perform BCD
arithmetic.
<br>
Page 29 of 440
g
This flag is set whenever the result of a signed number operation is too large
in
causing the high-order bit to overflow into the sign bit.
er
In general, the carry flag is used to detect the errors in unsigned arithmetic
e
operations and the overflow flag is only uscd to detect the crrors in signed
in
arithmetic operations.
ng
The PSW3 and PSW4 are designed as RS0 and RSI, respcctivcly as the bank
fE
selection bits. They arc used to selcct the bank registers of 8051. The PSW.5 and
PSW.1 bits are general-purpose status flag bits and can be used by the
O
programmer for any purpose.
g e
1.5.1 Introduction
ol
Definition:
C
The CPUcan access data in various ways, whiclh are called addressing
u
modes.
ad
memory (or) any register names (or) any numerical duta ctc.
m
Code -| Data
ADDRESSING
MODE OPCODE OPERAND
Part - 1
Part- 2 Part-3
Machine Instructions
Page 30 of 440
8051 Microcontroller
1.17
Each assembly language statement is split into an
opcode and an operand. The
opcode is the instruction that is executed by the
CPUand the operand is the data
or memory location used to execute that instruction.
1.5.2 Types of Addressing modes
There are five different ways to execute the instructions.
Therefore, 8051
g
provides a total of five distinct addressing modes as follows:
in
(i) Immediate addressing mode,
er
(ii) Register direct addressing mode,
e
(ii) Direct addressing mode,
in
ng
(iv) Register indirect addressing mode, and
(v) Indexed addressing mode.
fE
The direct, register indirect and indexed addressing modes are used for accessing
O
memories.
(1) Immediate Addressing Mode
g e
This addressing mode can be used to load information into any of the registers
u
including the DPTR register which stands for Data Pointer and it points the
ad
Examples
i) MOV A, # 55H ;load 55H into A[move the data 55 H (that is
m
R4, #
62 ;
(ii) MOV load the decimal value 62 into register R4.
We can also use immediate addressing mode to send data to 8051 ports.
Example: MOV P1, # 55H
(2) Register Addressing Mode
In the register addressing mode, the data to be operated is available inside
the register(s). We use the register name directly as source operand. Therefore
<br>
Page 31 of 440
microprocessor.
Destination register Source register
g
in
Examples
er
MOV A, RO ; copy the contents of R0 into A.
e
in
; copy the contents of A
into R2.
MV R2, A
ng
of R5 to contents
A.
; add the contents of
ADD A, R5
an
location (source data) is given as
g
Memory
ad
iln
Destination register
Address of memory
m
selected memory
location
Examples
A.
MOV A, 25H ; data from 25H location is given to register
an address.
Here # is not used, because it is
MOV 3OH, A move A register data to 30H location.
<br>
Page 32 of 440
8051 Microcontroller
1.19|
(1) SFR Registers and their Addresses
a Definition
A Special Function Register
(or Special Purpose Registers) are the special
registers_ closely tied to some special function or
status ofthe processor, they
might not be directly writable by normal
instructions (like add, move, etc.).
g
Instead, some special registers in some processor
architectures require
in
special instructions to modify
the.
er
This SFRs are located immediately above the 128
bytes of RAM and
e
responsible for the operation of ALU, timer, serial port, parallel ports
in
and
interrupt control.
ng
Some SFRs available in 8051 are:
(d) DPTR
le
(data pointer).
ol
The SFR can be accessed by their names or by their addresses which is much
ad
easier.
iln
Examples:
RegisterA has address EOH, and register B has address FOH.
m
Ta
Page 33 of 440
SFR Addresses:
to These
A special function register can have an address between 8OH FFH.
to 7FH are the addresser
addresses are above 80H, as the addresses from 00
of RAM memory inside the 8051.
The unused locations of 80H to FFH are reserved and must not be used by
g
the 8051programmer.
in
Address
er
Symbol Name
OEOH
e
ACC* Accumulator
in
OFOH
B* B register
ng
PSW* Program status word ODOH
80H
g
PO* Port 0
le
P]* Port 1
90H
ol
Page 34 of 440
8051 Microcontroller
1.21
g
*Bit addressable
in
Table 1l.4 8051 SFR addresses
er
(ii) Stack and Direct Addressing Mode
e
Only direct addressing mode is allowed for pushing or popping the stack.
in
PUSH A is
invalid.
ng
Pushing the accumulator onto the stack must be coded as PUSH 0EOH.
(4)
fE
Register Indirect Addressing Mode:
O
In the register indirect addressing mode, a register is used as a pointer to the
e
data. If the data is inside the CPU, only registers RO and RI are used as a
g
Register
iln
Data from
selected memory
location
Examples:
Here the value inside RO is considered as an address, which holds the data to be
transferred to an accumulator.
<br>
Page 35 of 440
M Advantages
The advantages of register indirect addressing mode which make it a popular
g
addressing mode in computer architecture are,
in
() Dynamic use of data:
er
It makes accessing data dynamic rather than static as in the case of direct
e
addressing mode. Looping is not possible in direct addressing mode.
in
(i) Efficient use of memory,
ng
(üi) Flexibility in addressing, and
(iv) Easy implementation. fE
O
Limitations
The limitations of register indirect addressing mode are,
e
) RO and RI are the only registers that can be used as pointers in register
g
le
() RO and RI are & bits wide and their use is limited to access any information
C
ROM, we need 16-bit pointer. In such case, the DPTR register is used.
ad
or
8051. The destination operand is always the register A. Either the DPTR
Ta
Examples:
"MOVC A, @A+DPTR"
The 16-bit register DPTR and register A are added to form the address of the
data element stored in on-chip ROM. Because the data elements are stored i
<br>
Page 36 of 440
8051 Microcontroller
1.23
the program (code) space ROM of the 8051. The instruction MOVC is
used
instead of MOV and "C" means code.
"MOVC A, @A+PC"
The only difference is, instead of adding DPTR with accumulator,
here data
g
inside program counter (PC) is added with accumulator to obtain
the target
in
address.
e er
1,6 SOLVED EXAMPLES
in
Example-1
ng
Show the status of the CY, AC
and P
flag after the addition
fE of 38H and 2FH in
the following instructions.
O
MOV A,
#38H
e
Solution:
ol
38 00111000
C
+2F 00101111
u
67 01100111
ad
Example-2
Show the status of the CY, ACand Pflag after the addition of 9CH and 64H in
the following instructions.
MOV A, #9CH
;
ADD A, #64H after the addition A = 00H, CY = 1
<br>
Page 37 of 440
1.24|
Embedded Systems and 10T Desig
Solution:
9C 10011100
+ 64 01100100
100 00000000
g
in
carry beyond the D7 bit.
CY=1,there is a
er
a carry from the D3 to the D4 bit.
AC=1, there is
e
even number of ls (it has zero 1s).
P=0, the accumulator has an
in
ng
Example-3
fE
Show the status of the CY, AC and Pflag after the addition of 88H and 93H i
the following instructions.
O
MOV A, #88H
e
=
;after the addition A = 1BH, CY
1
g
ADD A, #93H
le
Solution:
ol
88 10001000
C
+93 10010011
u
ad
11B 00011011
to the D4 bit.
AC =0, there is no carry from the D3
m
Example-4
Write code to send 55H to ports Pl and P2 using
(a) their námes (b) their addresses.
Solution:
(a) MOV A, #55H ;A=55H
MOV Pl, A ;Pl= 55H
<br>
Page 38 of 440
1.25
805I Microcontroller
MOV P2, A ;
P2 = 55H
(b) From Table 1.4, Pl address 8OH; P2 address AOH
MOV A, #5SH ;A=55H
MOV 80H, A ; Pl=5SH
g
in
Example-5
er
Show the code to push R5 and A onto the stack and then pop them back them
e
into R2 and B, where B =A and R2 = RS
in
ng
Solution:
PUSH 05 push R5 onto stack fE
PUSH 0EOH push register A onto stack
O
POP OFOH pop top of stack into B
e
;
le
;now R2=R6
C
u
Example-6
ad
Solution:
;A-0
m
CLR A
Ta
MOV R1,#60H
;
load pointer. Rl=60H
Page 39 of 440
g
in
pointer, clock and interrupt circuits.
er
2. Define microcontroller.
in
the features that are found
e
The microcontroller incorporates all
in
as a true single-chip system that
microprocessor, but they are designed to work
ng
a system on a single-chip which is
is, it can integrate all the devices needed for
optimized for specific applications. fE set of registers,
The basic functional units of a microprocessor will be ALU,
O
functional blocks
timing and control unit. The microcontroller will have these
a programmable timer, RAM and
and in addition it may have I/O ports,
g e
EPROM/EEPROM.
le
[OR]
What are the main features of 8051 microcontroller? [NOVIDEC-2017]
u
ad
[OR]
State any four inbuilt features of 8051 microcontroller. NOVDEC-2018]
iln
Page 40 of 440
g
microprocessor and in addition has
in
a memory, VO interfacing circuit
and peripheral devices such as
er
ADC, DAC, timer etc.
e
2
It has several instructions to move It has one or two instructions to
in
data between memory and CPU. move data between memory -and
ng
CPU.
3. The microprocessors are used for fE
Microcontrollers are used for
designing general purpose digital designing application specific
O
computing system (or computers). dedicated systems
4. It has one or two bit handling It has many bit handling
e
instructions. instructions.
g
Memory and I/0 devices access Less access time for built-in
le
5.
time is more. memory and I/O devices.
ol
5. What is the size of the on-chip program memory and on-chip data memory of
C
[OR]
ad
[OR]
Write the RAM and ROM capacity in 8051 microcontrollers.
m
[NOVDEC-2022)
Ta
Page 41 of 440
(ii) Less hardware that reduces PCB size and increases reliability of the system.
g
(iv) Low system cost.
in
er
7. What is the significance of PSEN and EA pins in 805l microcontroller?
e
NOVIDEC-2010, 19)
in
Pin 29 (PSEN)
ng
PSEN stands for Program Store Enable. It is an active-low output pin which is
used to read an external memory.
fE
O
Pin 31 (EA/Vpp)
e
It is the External Access (EA) enable pin which allows external program
g
Pin 30 (ALE/PROG)
iln
ALE stands for Address Latch Enable. It is an active-high input pin which is
m
used to distinguish between memory chips when multiple memory chips are
Ta
used.
It is also used to de-multiplex the multiplexed address and data
signals available
at port 0.
9. Define embedded system.
An embedded system is a combination
of computer hardware and software
designed for a specific function. It is a computer system
which is a combinatto
of a computer processor, computer memory, and input/output peripheral
that has a dedicated function within'a larger device
mechanical or electronic systen.
<br>
Page 42 of 440
8051 Microcontroller
1.29|
10. State any four applications of microcontrollers.
[NOVDEC-2018,22]
The main applications of microcontrollers are,
g
(iv) Security systems.
in
Fax machines.
er
(v)
(vi) Laser printers.
e
in
I1. How the microcontrollers respond to any interrupt request?
[APRMAY-2018]
ng
Interrupts is a sub-routine call is that is given by the microcontroller when some
other program with high priority is requesting for acquiring the system buses,
fE
then interrupts occur in current running program.
Interrupts provide a method to postpone or delay the current process, to performs
O
a sub-routine task and then restart the standard program.
e
of 8051? [NOVDEC-2019]
le
[ORJ
ol
(ii) Timer 1
overflow interrupt - TF1
(iii) External hardware interrupt - INTO
iln
Registers are used to store information temporarily, while the information could
be a byte of data to be processed, or an address pointing to the data to be fetched.
14. What is Program Counter (P)?
The Program Counter (PC) is a register that points to the address of the ncxt
instruction to be executed. As each instruction is executed, the PC is incremented
to point to the address of the next instruction to be executed.
<br>
Page 43 of 440
g
16. Draw the PSW register.
in
[OR]
er
What is the flag register format of 8051 microcontroller?
NOVDEC- 2010)
e
PSW.1 PSW.0
in
PSW.7 PSW.6 PSW.5 PSW.4 PSW.3 PSW.2
ng
CY AC FO RS1 RSO OV P
fE
+Register bank Select bit 0
O
1
Register bank Select bit
e
18. List tlhe 8051 instructions that always clear the carry flug. (APR/MAY-2019)
m
Carry flag can also be set to or 0 directly by an instruction such as " SETB
1 C
Ta
and « CLR C" where "SETB C" stands for set bit carry" and "CLR C" to
*clear carry".
Page 44 of 440
8051 Microcontroller
1.31|
g
1 1
in
3 Register Bank 3 is selected
er
20. Define addressing node.
The CPUcan access data in various ways, 'which are called addressing
e
modes.
in
Addressing mode is a way to address an operand. Operand means source data
ng
that is the data we are operating upon. It can be adirect address of memory (or)
any register names (or) any numerical data etc.
21. What are
fE
the different ways of operand addressing in 8051.
O
NOVDEC- 2007, 09, 10 & APRMAY-2011, 17]
e
[OR]
g
There are five different ways to execute the instructions. Therefore, 8051
ol
Page 45 of 440
g
in
23. Write the function of register addressing mode.
er
In the register addressing mode, the data to be operated is available inside the
register(s). We use the register name directly as source operand. Therefore the
e
in
operation is performed within the various registers of the microprocessor.
ng
Examples
A
Special Function Register
(or Special Purpose Registers) are
g
immediately above
the 128 bytes of RAM
ad
available in 8051.
m
[OR]
List any four SFRs.
Ta
Page 46 of 440
1.33|
8051Microcontroller
Example:
g
MOV A, @RO ;move contents ofRAMlocation
in
A
;whöse address is held by RO into
er
are the advantages of the register indirect addressing mode in 8051
e
27. What
(NOV/DEC -2016]
in
microcontroller?
a popular
The advantages of register indirect addressing mode which make it
ng
addressing mode in computer architecture are,
fE
() Dynamic use of data:
as case of direct
O
It makes accessing data dynamic rather than static in the
addressing mode. Looping is not possible in direct addressing mode.
g e
28.
are,
The limitations of register indirect addressing mode
ad
(1) RO and R1 are the only registers that can be used as pointers in register
iln
(i) RO and R1 are 8 bits wide and their use is limited to access any information
Ta
or on-chip
in the internal RAM. When accessing externally connected RAM
case, the DPTR register is used.
ROM, we need 16-bit pointer. In such
29` What happens when the 8051 microcontroller instruction
"MOVC A @A+DPTR" is executed?
Page 47 of 440
g
1.8 REVIEW QUESTIONS
in
microcontroller. [APRMAY-2011, 2012]
1. Explain the features of 805l
er
[ÄPR/MAY-2011]
2. Compare microcontrollers and microprocessors.
e
Draw the pin diagram of 80S1 microcontroller and explain the functions of
in
3.
[MA Y/JUNE -2003, l1, 13 NOVDEC-06,11]
ng
each pin.
4. Briefly discuss the ports of 805landits functions in detail. [APRMAY-2018]
5.
fE
Explain the pinouts of 8051 microcontroller. [NOVDEC-2011]
O
6. With a neat sketch of a schematic diagram, explain the functions of various
signals of 8051. [NOVDEC -2010]
e
[NOVDEC- 08, 10, 16, 19, 20 & APRMAY- 0, 08, 11, 16, 17, 18, 21]
u
10. Witha functional block diagram, briefly discuss the architecture of the 8051
ad
Page 48 of 440
g
in
19. Write a short note on SFR (Special Function Registers).
er
[NOVDEC- 2010 & MAYIJUNE- 2007]
e
in
ng
fE
O
g e
le
ol
C
u
ad
iln
m
Ta
<br>
Page 49 of 440
UNIT -I
Chapter
g
in
er
8051 INSTRUCTION SET
e
in
2.1.INSTRUCTION SET OF 8051
ng
2.1.1 Introduction fE
The process of writing a program for the microcontroller mainly consists of
O
giving instructions (commands) in the specific oder in which they should be
executed in the order to carry out a specific task.
e
instruction set. The instruction groups of the 8051 microcontroller instruction set
ol
source and
operation to be performed while the operands identify the
ad
a Types of Instructions:
m
groups as follows:
Page 50 of 440
Like 8085, some instruction has two operands: first operand is the destination,
and second operand is source.
Mnemonics:
In computer assembler (or assembly) language, a mnemonic is an abbreviation
for an operation which specifies the type of operation to be performed and they
g
in
are translated by the. assembler. All mnemonics of the instruction are of one byte
er
size.
e
Example:
in
AND AC, 37 ; means AND the AC register with 37.
ng
A Format: fE
The format of instruction is as follows:
O
MNEMONIC DESTINATION OPERAND, SOURCE OPERAND
g e
Definition:
ad
Page 51 of 440
g
MOV A, @Ri Move indirect RAM to accumulator
in
1 1
MOV A, #data
er
Move immediate data to accumulator 2
e
(i) MOV A, Rn
in
Copy the contents ofregister Rn to A.
ng
Example: MOV A, RI
fE
This instruction will copy the contents of register RIof the selected register bank
O
to an accumulator A.
Copy the contents of direct address given in the instruction toan accumulator A.
le
This instruction will copy the contents from memory location whose address is
C
Copy the contents of memory location whose address is specified in the register
iln
Examples:
Ta
Page 52 of 440
g
H is copied to the accumulator
in
The data 31
er
Fig 2.1
e
(2) Register A is the Source:
in
ng
Mnemonic Description Byte Cycle
MOV Rn, A fE
Move accumulator to register. 1 1
O
MOVdirect, A Move accumulator to direct byte. 2 1
e
() MOV Rn, A
ol
Copy the contents of accumulator to the register Rn of the selected register bank.
C
40.
40
Ta
R7 R6 R5 R4 R3 R2 R1 RO R7 R6 R5 R4 R3 R2 R1 RO
A0 Bank 0 40 Bank 0
Fig 2.2
(ii) MOV direct, A
Copy the data from an accumulator to direct address.
<br>
Page 53 of 440
80H is the address of port 0. This instruction will copy the contents of an
accumulator to the port 0.
(iüi) MOV @ Ri, A
g
Copy data fromaccumulator to the memory location pointed by Ri.
in
er
Example: MOV@ R0, A
e
This instruction will copy the contents of an accumulator to the nmemory location
in
whose address is pointed by the RO register of the selected register bank.
ng
(3) Register Rn is the Destination:
fE
Mnemonic Description Byte Cycle
O
MOV Rn, A Move accumulator to register. 1 1
g e
This instruction will copy the contents from address 30H to the register R3 of the
m
This instruction willcopy immnediate data 20H to the register R7 of the selected
register bank.
<br>
Page 54 of 440
2.6
Embedded Systems and 1OT Design
After execution
Before execution
Data
Data
20 20
R7 R6 R5 R4 R3 R2 R1 RO R7 R6 R5 R4 R3 R2 R1 RO
A0 Bank 0 20 Bank 0
g
in
The data is copied to register R7
e er
Fig 2.3
in
(4) The Destination is a Direct Address:
ng
Mnemonic Description
fE Byte Cycle
MOV direct, A Move accumulator to direct byte 2 1
O
MOV direct, Rn Move register to direct byte 2 2
MOV direct, direct
e
3 2
C
() MOV direct, Rn
Copy the contents of
register Rn to the direct address.
u
ad
Page 55 of 440
g
(iv) MOV dircct, # data
in
er
Copy the immediate data to direct address.
e
Example: MOV 30H, # 10H
in
This instruction will copy immediate data 10H to the memory location whose
ng
address is 301H.
fE
(4)Destination is an Indirect Address held by RO or R1:
O
Mnemonic Description Byte Cycle
e
This instruction will copy the data from memory location whose address is 30H
to the memory location pointed by register RO of selected register bank.
m
Ta
Page 56 of 440
g
Function: Load data pointer.
in
er
Flags: None.
pointer) register with a 16-bit
e
loads the 16-bit DPTR (data
This instruction
in
immediate value.
ng
Operation: MOV
(DPTR)+# datajs -0
fE
DPH # datajs -8
O
DPL # data,-o
g e
Fig 2.4
Flags : None
<br>
Page 57 of 440
g
MOVC A, @A + PC Move code byte relative to PC to
in
1
2
accumulator
er
(1) MOVC A, @A + DPTR
-
e
Operation: (A) ((A) + (DPTR))
in
This instruction moves a byte of data that is located in program (code)
ng
ROM into register A. This allows us to put strings of data, such as look-.
fE
up table elements, in the code space and read them into the CPU.
The address of the desired byte in the code space (on-chip. ROM) is
O
formed by adding the original value of the accumulator to the 16-bit
e
DPTR register.
g
le
Example:
ol
(2) MOVCA, @ A + PC
-
iln
-
m
program (code)
The instruction moves a byte of data that is located in the
area to A. The address of the desired byte of data is formed by adding the
is used
PC register to the original value of the accumulator. Here, the PC
instead DPTR to generate the data address.
of
Example:
Let (PC) = 4000H, and (A)= 50H.Initially the 16 bit address is computed as,
<br>
Page 58 of 440
(PC) = (PC) + 1
= 4000H + 1H =4001H
g
in
accumulator.
er
2.2.3 Instructions to Access External Data Memory
e
in
MOVX dest-byte, source-byte
ng
Function: Move external
Flags: None.
fE
O
This instruction transfers data betwcen cxternal memory and
register A. The
8051has 64 K bytes of data space in addition to the
64 Kbytes of code space.
e
allows us to
le
whose address is
pointed to by DPTR into the accumulator.
iln
This instruction moves a byte from external memory whose S-bit address is
pointed to by the register Ri into the accumulator.
<br>
Page 59 of 440
g
in
2.2.4 Data Transfer with Stack (PUSH
and POP) Instructions
er
Mnemonic Description Byte Cycle
e
in
PUSH direct Push direct byte onto stack 2 2
ng
POP direct Pop direct byte from stack 2 2
(1) PUSH direct
fE
O
Function: Push onto the stack.
Flags: None
e
g
-
le
(SP)) (direct)
ol
This copies the indicated byte of data onto the stack and increments SP by 1. This
C
Flags: None
Ta
Page 60 of 440
g
1
Exchange register with accumulator.
1
in
XCH A, Rn
er
1
XCH A, direct Exchange direct byte with accumulator. 2
e
in
1
Exchange indirect RAM with accumulator.
1
XCH A, @Ri
ng
Exchange low -order nibble indirect RAM 1 1
XCHD A, @Ri fE
with A.
O
(1) XCHA, Byte
e
Function :
Exchange Accumulator (A) with a byte variable.
g
Flags: None.
le
This instruction swaps the contents of register A and the source byte. The sourc
ol
Example:
u
ad
XCH A, R2 now A
=97H and R2 =65H
m
Mnemonic: XCH A, Rn
Exchanges the register with
the accumulator.
Example: XCH A, R3
<br>
Page 61 of 440
g
() Register - Indirect Mode:
in
er
Mnemonic: XCH A, @Rn
e
Exchanges the indirect RAM with the accumulator.
in
ng
Examples: XCH A, @RO XCH A with data pointed to by RO.
(3) XCHD A, @ Ri fE
Mnemonic: XCHD A@Ri
O
Function: Exchange digits
e
Flags: None
g
le
(bits 3 0) with the lower nibble of the RAM location pointed to by Ri (bits 3 –0)
while leaving the upper nibbles (bits 7-4) of each registers remain unchanged.
C
Let RO contain address 37H, accumulator contain address 25H, and the interhal
RAM location 37H contain 27H.
m
After execution of the XCHD instruction, we have A =27 H and RAM location
Ta
37 H has 25H.
Page 62 of 440
g
1
ADD A,direct Add direct byte to accumulator 2
in
Add indirect RAM to 1 1
er
ADD A,@Ri .accumulator
e
in
:
Mnemonic ADD A, <source-byte>
ng
Function : Add
Flags
:
OV, AC, CY fE
This instruction adds the source byte to the accumulator (A), and places the
O
result in A. Since register A is one byte in size, the source operands must also
be one byte.
g e
The ADD instruction is used for both signed and unsigned numbers.
le
(1)Addressing Modes:
ol
The following addressing modes are supported for the ADD instruction:
C
:
Mnemonic ADD A, # data
+ (A) +# data
iln
Function (A)
This instruction will add the immediate
m
Page 63 of 440
g
This instruction adds the direct byte to the accumulator.
in
er
Example ADD A, 30H :
Add A data in RAM location 30H.
e
(iv) Register-indirect Mode
in
:
Mnemonic ADD A, @ Ri where
i=0 or
i=1 only
ng
Function (A) + (A) + (Ri))
fE
This instruction will add the contents of memory location whose address is
pointed by register Ri of the selected register bank with the contents of the
O
accumulator. The result of addition is stored in the accumulator.
e
Examples:
g
le
ADDC A, Rn 1
with carry flag.
m
Mnemonic :
ADDCA, <source-byte>
Function
:
Add with carry flag.
<br>
Page 64 of 440
Operation
:
A+A)
+
<source-byte> + CY
:
Flags OV, AC, CY
This instruction will add the source byte to A, in addition to the CY flag
(A=A+byte + CY).
(a) If CY - lprior to this instruction CY is also added to A.
g
in
(b) If CY = 0prior to the instruction, source is added to destination plus 0
er
which is used in multibyte additions.
e
(1) ADDC A, Rn
in
Operation :A¢(A) + (Rn) + (CY)
ng
This instruction will add the contents
of accumulator with the contents of
register Rn of the selected register bank and carry flag.
fE The result of addition is
stored in accumulator.
O
Example ADDC A, R2
Adds the contents of A, R2 and carry
e
flag.
Example :
ADDCA, 10H
u
- (3)
ADDC A, @ Ri
m
:
Operation A+ (A) + (Ri) + (C)
Ta
Page 65 of 440
g
SUBB A, #data Subtract immediate data from
in
A with borrow. 2
er
SUBB A, Rn Subtract register from A with
1 1
e
borrow.
in
Subtract direct byte from A
SUBB A, direct 2 1
ng
with borow.
SUBB A,@Ri Subtract indirect RAM from A
with borrow fE 1
: OV, AC, CY
g
Flags
le
This instruction subtracts the source byte and the carry lag from the
ol
The steps for subtraction performed by the internal hardware of the CPU are
as follows:
u
This instruction sets the carry flag (C) according to the following:
Ta
Page 66 of 440
g
in
SUBB A, # 23H :45H-23H -0=22H
(1) Addressing Modes
er
The following four addressing modes are supported
e
for the SUBB:
in
(i) Immediate Mode
ng
Mnemonic : SUBB A, #
data
Operation : (A)-(A)- (CY)-#data fE
Subtracts the immediate data
from the accumulator with a borrow.
O
.Example : SUBB A, #25H
;A=A-25H– CY
e
Mnemonics : SUBB A, Rn
ol
Example : sUBB A, R3
;A=A-R3-CY
ad
Mnemonics: SUBB A, @ Rn
Operation : (A) + (A)- (Rn) -CY
Subtracts the indirect RAM from the accumulator
with a borrow.
<br>
Page 67 of 440
8051.Instruction set
2.19
Example : SUBB A,@RO
;A- data at (R0) -CY
2.3.4 INC byte
Mnemonic Description Byte Cycle
INC A Increment Accumulator 1 1
INC Rn
g
Increment Register 1 1
in
INC direct Increment direct byte 2 1
er
INC @Ri Increment indirect RAM 1 1
e
Mnemonic INC <byte>
in
Function :
Increment
ng
:
Flags None
Operation :
<byte=<byte>+1 fE
This instruction adds 1 to the register or memory location specified by the
O
operand. This instruction supports the following addressing modes.
e
:
Mnemonic INCA
ol
Operation <A><A>+ 1
C
Mnemonic :
INC Rn
iln
.(Rn) ¢- (Rn) +
1
Operation
m
Example :
INC RI
(3) Direct Mode
Mnemonic :
INC direct
Operation (direct) 4- (direct) +1
This instruction will increment the contents of memory location whose direct
address is specified in the instruction by 1.
<br>
Page 68 of 440
2.20|
Embedded Systems and IOT Design
:
INC 30H ;Increment byte in RAM location 30H.
Example
g
Increments the indirect RAM by 1.
in
Example INC @ RO Increment byte pointed to by RO.
e er
2.3.5 DEC byte
in
Mnemonic Description Byte Cycle
ng
1 1
DEC Á Decrement Accumulator
DEC Rn' Decrement Register
fE 1. 1
O
1
DEC direct Decrement direct byte 2
1 1
DEC @Ri Decrement indirect RAM
g e
Function Decrement
C
Flags None
u
>
Operation <byte <byte >-1
ad
(1)Accumulator (A)
Ta
Mnemonics DEC A
Page 69 of 440
8051Instruction set
|2.21
Example DEC R1
Decrements contents of RI by 1
g
in
Operation (direct) ¢- (direct)- 1
er
Example DEC 40H ;Decrement byte in RAM location 40H by 1.
e
(4) Register - indirect Mode
in
Mnemonics
ng
DEC@ Ri ;where i = 0 or lonly.
– 1
Operation (Ri)) –(Ri)) fE
This instruction will decrement the content of memory location pointed by the
O
register Ri by 1
e
Example DEC @ RO ;
Decrement byte pointed to by RO.
g
le
Flags None
Ta
1. DPTR
instruction increments the 16- bit registers DPTR (data pointer) by
This version
Register that can be incremented. There is no decrement
is the only 16 bit
of this instruction.
;
DPTR= 16FFH
Example MOV DPTR, #16FFH
; now DPTR = 1700H
INC DPTR
<br>
Page 70 of 440
Before execution
After execution
DPL DPH DPL
DPH
DPTR 17 00
DPTR 16 FF
g
The contents of DPTR are incremented by 1
in
Fig 2.5
e er
2.3.7 MUL AB
in
Mnemonic Description Byte Cycle
ng
MUL AB Multiply A and B 4
Mnemonics MUL AB
fE
O
Function Multiply AxB
Flags Ov, CY
e
-
g
in register B. The
result is placed in A and B where A
has the lower byte and B has
the higher
u
byte.
ad
product.
m
Example:
Ta
MOV A, #5
MOV B, #7
MUL AB ;A=35= 23H, B=00
2.3.8 DIV AB
Mnemonic Description Byte Cycle
DIV AB Divide A by B
<br>
Page 71 of 440
g
in
B (remainder)
er
This instruction divides a byte accumulator
by the byte in register B. It is
e
assumed that both registers A and B contains an
unsigned byte.
in
After the division, the quotient will be in register A and the
ng
remainder in
register B.
Example
fE
O
MOV A, #35
e
MOV B, #10
g
B = 5
;A=3and
le
DIV AB
ol
-
2.3.9 DecimalI Arithmetic: DA A
C
DA A
Mnemonic :
DA .A
iln
Flags CY
Ta
Page 72 of 440
g
Example:
in
MOV A, #47H ;A=0100 0111
er
ADD A, #38H ;A=47H+38H =7FH, invalid BCD
e
in
DA A ;A=1000 0101 = 85H, valid BCD
ng
47H
+ 38H fE
7FH (invalid BCD)
O
+ 6H (after DA A)
e
85H
g
(valid BCD)
le
Page 73 of 440
t InsIuctionset
|2.25|
ANL
A,@Ri AND indirect RAM to
accumulator 1 1
g
Mnemonic ANL <dest-byte>, <sre-byte>
in
er
Function Logical AND for byte variables
e
Flags None affected.
in
This instruction performsa logical AND on
ng
the operands, bit by bit and storing
the result in the destination. Both the source
and destination values. are byte-size
only.
fE
O
A B
AAND B
g e
1
le
1. 0
ol
1
C
Example:
u
39 0011 1001
m
09 0000 1001
Ta
09 0000 1001
for the ANL instruction there are a total of six addressing modes. Out of six, in
Jour of them, the accumulator must be the destination.
(1) Immediate
Mode
Mnemonic :
ANL A, #data
<br>
Page 74 of 440
g
Mnemonic
in
Operation : (A)+(A) a (Rn)
er
Example ANL A, R3
e
in
(3) Direct Mode
ng
Mnemonic : ANL A, direct
Operation (A) +
(A)a (direct)
fE
:
Example ANL A, 30H ;ANDA with data in RAM location 30H.
O
(4) Register-indirect Mode
e
Mnemonic : ANL A, @ Ri
g
le
:
Operation (A) +(A) ^ (Ri)
ol
tp In the next two addressing modes the destinàtion is a direct address (a RAN
u
location or one of the SFR registers) while the source is either A or immediatt
ad
data.
iln
-
Ta
Operation :
(direct) (direct) a (#data)
Example :
ANL 32H, #44H
Assume that RAM location 32H has
the value 67H.
44H 0100 0100
67H 0110 0111
44H. 0100 0101
<br>
Page 75 of 440
g
(A)
in
Example:
er
MOV B, #44H ;B=44H
e
in
MOV A, #67H ;A=67H
ng
ANL 0FOH, A
;A AND B (B is located at RAM FOH)
fE
; after the operation B = 44H
O
2.4.2 ORL dest-byte, source-byte
e
Flags :
None
* This performs a logical OR on the byte operands, bit by bit, and stores the result in
the destination.
A B A OR B
0
<br>
Page 76 of 440
1 1
1 0 1
1 1
g
Example
in
MOV A, #32H ;A=32H
er
MOV R4, #50H ; R4= 50H
e
ORL
in
;
A, R4 (A=72H)
ng
32H 0011 0010
50H 0101 0000 fE
72H 0111 0010
O
For the ORL instruction there are a total of six addressing
modes. Out of six, in
e
:
Mnemonic ORL A, #data
ol
Operation
:,
u
Mnemonic ORL A, Rn
m
Example :
ORL A, R3
Page 77 of 440
R051-Tnstruction set..
2.29
14) Register-indirect Mode
Mnemonic :
ORL A, @Rn
Operation (A) -(A) V (Ri)
Example : ORL A, @RO ; OR A with data
pointed to by RO.
g
A In the next two addressing modes the
destination is a direct address (a RAM
in
location or one o
the. SFR registers) while the source is either A or immediate
er
data.
e
in
(5) ORL direct, #data
ng
Mnemonic :ORL direct, #data
Example :
O
six, in
ORL 32H, #44H ;OR 44H with contents of RAM location 32H
g e
Mnemonic
:
ORL direct,
Ta
Example
44H
MOV B, #44H ;B=
MOV A, #67H ;A=67H
FOH
ORL OFOH, A ;
ORA and B. (Bis at RAM
; After the operation B =67H
<br>
Page 78 of 440
g
XRL A, Rn accumulator
in
Exclusive-OR direct byte to 2
1
er
XRL A, direct accumulator
e
Exclusive-OR indirect RAM 1 1
in
XRL A, @Ri to accumulator
ng
Exclusive-OR immediate 3 2
XRL. direct, #data data to direct byte
XRL direct, A
fE
Exclusive-OR accumulator 2
1
to direct byte
O
Mnemonic : XRL <dest-byte>,.<src-byte>
e
Function
le
:
Flags Noné
ol
C
# This performs a logical exclusive-OR on the byte operands, bit by bit, storing the
ad
A B A XORB
m
0
Ta
1
1
1
0
1 1
Example:
Page 79 of 440
g
the accummlator must be the destination.
in
(1) Immediate Mode
er
Mnemonic : XRL A, #data
e
in
Operation (A) + (A) (#data)
ng
Example : XRL A, #25H
Example : XRL A, R3
le
Mhemonic :
XRL A, direct
u
:
(A) ¢-(A) (direct)
Operation
ad
Page 80 of 440
g
32H, #44H
in
XRL
A, 32H ; move content of RAM
location 32H to A.
er
MOV
e
44H 0100 0100
in
0110 0111
ng
67H
23H 0010 0011
fE
Therefore A will have 23H.
O
(6) XRL direct, A
e
:
Mnemonic XRL direct, A
g
le
Operation :
(direct) (direct) (A)
ol
Example
C
;
(register B is located at RAM location FOH)
m
;
after the operation B =23H
Ta
2.4.4 CLR
Mnemonic perands Description Byte Cycle
Page 81 of 440
g
Operation .: A
0
in
This instruction clears register A and all bits
of the accumulator are set to 0.
er
Before execution
e
After execution
Accumulator Accumulator.
in
77
ng
Accumulator 00
is cleared
Fig 2.6
fE
O
(2) CLR bit
Function: Clear bit
g e
This instruction clears a single bit. The bit can be the carry flag, or any bit
le
=
Example: CLR P1.7 ;CLEAR P1.7 (P1.7 0)
C
2.4.5 CPL
u
ad
CPL A
Complement accumulator 1 1
m
(1) CPLA
Mnemonic : CPLA
Function Complement accumulator
Flags None are affected
Operation : A +
<br>
Page 82 of 440
g
Complement = 1010 1000 48H
in
Before execution After execution
er
Accumulator Accumulator
e
57 48
in
Complemented
ng
Fig 2.7
RRC A
Rotate accumulator right through
Carry.
SWAP A Swap nibbles within the 1
1
accumulator
(1) RLA
Mnemonic : RL A
Page 83 of 440
g
Bit 7 is rotated into the bit 0 position.
in
er
D7 D6 D5 D4 D3 D2 D1 DO
e
in
ng
MSB LSB
:
Fig 2.8 fE
Example
O
MOV A, #69H ;A=01101001
e
; Now
RL A A= 11010010
g
le
(2) RLC A
ol
:
Mnemonic RLCA
C
Function :
Rotate the accumulator left through carry
u
:
Flags CY
ad
Operation :
(Dn+1)¢- (Dn) wheren=0 to 6
iln
(D0) (CY)
m
(CY) +(D7)
This instruction will rotate the eight bits in the accumulator and the carry flag
Ta
together by one bit to the left. Bit 7 will move into carry and original carry will
move to it
0' positions.
D7 DO
MSB LSB
Fig 2.9
<br>
Page 84 of 440
Example:
CLR C ;CY=0
A, #99H ;A=10011001
MOV
; Now A=00110010and CY=1
RLC A
; Now A=01100101 and CY=0
g
RLC A
in
er
(3) RRA
: RR A
e
Mnemonic
in
: Rotate accumulator right
Function
ng
: None
Flags
Operation
fE
:(Dn) -(Dn+1) where n =0 to 6
(D7) + (D0)
O
one position to the
This instruction will rotate the eight bits in the accumulator by
e
D5 D4 D3 D2 D1 DO
ol
D7 D6
C
u
MSB LSB
ad
Fig 2.10
iln
Example:
m
-;
MOV A, #66H A=01100110
Ta
; =
RR A Now A
00110011
RR A ; Now A= 10011001
(4) RRCA
Mnemonic RRC A
Function : Rotate the accumnulator right
through carry
:
Flags CY
<br>
Page 85 of 440
805IInsTUction set
2.37
Operation : (Dn) (Dn+1), where n
=0to 6
(D7) - (C)
. (CY)+ DO
This instruction will rotate
the eight bits in accumulator
g
together by one bit position to and the carry flag
the right. Bit 0 moves into
in
original carry flag contents move the carry flag,
into bit 7.
er
D7 D6 D5 D4 D3
e
D2 D1 DO
in
ng
fE Carry
flag
Fig 2.11
O
the Example:
e
SETB C ;CY =1
g
MOV
le
A, #99H ;A=10011001
ol
(5) SWAP A
u
Mnemonic :
SWAPA
ad
D7 D4 D3 DO
Higher Lower
nibble nibble
Fig 2.12
<br>
Page 86 of 440
g
SWAP A ;A=95H (1001 0101 in binary)
in
er
2.5 BIT- ORIENTED INSTRUCTIONS
This is also called as Boolean or Bit inanipulation instructions. It is similar
e
in
to logic instructions which perform the logic operations. The difference is that
ng
these are performed upon single bits.
1
g
(i)CLR C
ad
Operation: (bit)
-0
Ta
Page 87 of 440
) SETBC
Operation:
(CY)+1
g
in
(iü) SETB bit
er
Operation: (bit) 1
e
Example:
in
SETB P13 ; P1.3 = 1
ng
2.5.3 ANL C, Source - bit fE
Function : Logical AND for bit variables.
O
:
Flag CY
g e
ANL C, bit 2 2
C
In this instruction the carry flag bit is ANDed with a source bit and the result is
ad
() ANL C, bit
Ta
Page 88 of 440
g
a source bit and the result is
In this instruction the carry flag bit is ORed with
in
source bit is 1, CY is set; otherwise,
placed in the carry flag. Therefore, if the
er
the CY flag remains unchanged.
e
in
() ORL C, bit
ng
Operation: (C)+(C)v (bit)
(ii) ORLC, bit fE
Operation: (C) + (C) (bit)
O
e
Flag : CY
C
Page 89 of 440
g
in
There are three types of branching instructions are,
er
() Jump instructions.
e
(i) Call instructions.
in
(i) Return instructions.
ng
2.6.1 CALL Instructions fE
a Definition:
O
The CALL instruction is a control transfer instruction which is used to call a
subroutine. Subroutines are often used to perform tasks that need to be
g e
Flags : None
u
instructions:
iln
Page 90 of 440
ACALL Stands for *absolute call ". It calls subroutines with a target address tht
must be within 2K bytes of the current Program Counter (PC).
It is a 2-byte instruction, in which 5 bits are used for the opcode and the
remaining 11 bits are used for the target subroutine address. A 11-bit addres
limits the range to 2K bytes.
g
in
(2) LCALL 16-bit address
er
:
Mnemonic LCALL addr16
e
LCALL can be used to call subroutines located anywhere within the 64K byte
in
address space of the8051.
ng
When a subroutine is called, the PC register (yhich has the address of the
fE
instructjon afer the ACALI) is pushed onto the stack, and the Stack Pointer (SE)
is incremented by 2.
O
+
(SP) (SP) 2.
g e
Then the program counter is loaded with the new address and control is
le
(1) RET
Mnemonic : RET
Function : Return from
subroutine
: None
Flags
<br>
Page 91 of 440
g
in
(SP) -(SP)- 2.
er
(2) RETI
e
in
Mnemonic :
RETI
ng
Function : Return from interrupt
:
Flags None fE
This is used at the end of an interrupt service routine (interrupt handler). The top
O
two bytes of the stack are popped into the program counter and program
execution continuous at this new address. Then, the program counter (PC) and
g e
(PC) +(PC) -2
ol
(SP) - (SP) - 2
C
u
Page 92 of 440
Long jump 3 2
LJMP addr16
g
in
rel Short jump (relative addr.) 2 2
SJMP
er
Jump indirect relative to the 2
JMP @A+ DPTR
e
DPTR
in
JZ rel Jump if accumulator is zero. 2 2
ng
Jump if accumulator is not
JNZ rel 2 2
zero. fE
JC rel Jump if carry flag is set 2 2
O
JNC rel Jump if carry flag is not set 2 2
eg
3 2
C
A, direct, rel
jump if not equal 3
3 2
CJNE @Ri, #data, rel Compare immediate to ind.
and jump if not equal 3 2
DJNZ Decrement register and
Rn, rel jump
if not zero. 2 2
Decrement direct byte
DJNZ direct, rel and
jump if not zero 3 2
<br>
Page 93 of 440
g
address unconditionally. exccution to the target
The target address for this
in
2K bytes of program memory. instuction must be within
er
(2) UMP 16– bit addr: Unconditional
e
Mnemonic :
in
LJMP addr16
ng
Function Transfers control unconditionally to a new
• LJMP stands address
for "long jump" which is a 3-byte instruction.
fE The first byte is
the opcode and the next o
bytes are the target address.
O
LJMP is uscd to jump to any zddress
location within the 64K byte cude space
of the 80S1.
g e
Mnemonic :
SJMP rel
ol
adiress
SJMP stands for "short junmp" which is a
2- byte instruction. The firstbyte is
u
ad
the opcode and the second byte is the signed number displacement, whict is
added to the PC (program counter) of the instruction following the SJMP to
iln
This address is often referred to as a relative (rel) address since ths target
-
Ta
Flags :None
<br>
Page 94 of 440
g
Function
:
Jump ifA =0
in
er
Flags : None
e
This instruction examines the contents of the accumulator and jumps if it h
in
value 0.
ng
(6) JNC target:Conditional jump
Mnemonic :
JNCrel fE
Function : Jump if no carry (CY = 0)
O
Flags : None
e
address.
ol
Mnemonic :
JC rel
u
Flags None
iln
address.
Ta
Page 95 of 440
S1nstrüction set
2.47
(ti) JNB bit, target: Conditional
-
Mnemonic : JNB
bit, rel
Function Jump if bit not set
(0)
Flags :None
These instructions are used to
g
monitor a given bit and jump to a target
address
in
ifa given or
bit is lhigh low.
er
Inthe JB, when the bit is high it will jump, while for JNB when the bit
is low
it will jump.
e
in
(9)CJNE dest-byte, source-byte,target: Conditional
and Short Jump
ng
Function Compare and jump if not equal
Flags :CY
fE
O
The magnitudes of the source byte and destination byte are compared.
If they
are not equal, it jumps to the target address.
g e
destination.
ol
:
Mnemonic CJNE A, #data, target
u
ad
Example : CJNE A,
#96, NEXT ; Jump if A isnot 96
m
(ii) Direct
Ta
Mode:
Mnemonic -: CJNE A, direct, target
Page 96 of 440
g
not equal.
Compares immediate data to the register and jumps if
in
er
: is not 70
Example: CJNE R5, #70, NEXT Jump ifRS
e
- Indirect Mode:
in
(iv) Register
is held by register ROor R1.
Any RAM location can be the destination which
ng
Mnemonic CJNE. @ Ri, #data, target
fE
CJNE @ Ri, #data, rel
O
Compares immediate data to indirect register and jumps if not equal.
g e
Example:
le
CJNE @RI, #80, NEXT ; Jump if RAM location whose address is held
ol
;
by R1 is not equal to 80
C
:
Function
: None
Flags
iln
In this instruction a byte is decremented, and if the result is not zero it wil
m
jump to the target address. This instruction supports following two addressiny
Ta
Page 97 of 440
g
(11) NOP
in
Mnemonic : NOP
er
Function : No operation
e
Flags :
None
in
This performs no operation and execution continues with the next instruction. It
ng
is
sometimes used for timing delays to waste clock cycles.
fE
This instruction only updates the PC to point the next instruction following
NOP.
O
[OR]
ol
APRMAY-2021]
u
The instructions
groups as follows:
iln
Page 98 of 440
are translated by the assembler. All mnemonics of the instruction are of one byte
size.
3. Write the format of instruction.
The format of instruction is as follows:
g
in
MNEMONIC DESTINATION OPERAND, SOURCE OPERAND
er
4. What is the function of
datatransfer instructions?
e
The data transfer instructions are associated with transfer of data between
in
registers or external program memory or external data memory. These
ng
instructions are used to copy the content of source operand to the destination
operand. fE
5. State any four data transfer instructions and their function.
[NOVDEC- 2018]
O
(i) MOV
e
(ii) MOVC
ol
(i) MOVX
Move data to/from external memory.
u
ad
(iv) PUSH
iln
[NOVDEC-2007]
Mnemonic
Description Byte
MOVCA, @A +DPTR Cycle
Move code byte
relative
DPTR to accumulator to 1
2
<br>
Page 99 of 440
g
ROM into register A. This allows us to put strings
of data, such as look
in
up table elements, in the code space
and read them into the CPU.
er
The address of the desired byte in the code space (on-chip
ROM) is
e
formed by adding the original value of the accumulator to the 16-bit
in
DPTR register.
ng
Example:
[NOVIDEC-2018]
ol
<src - byte>
Mnemonic: MOV <dest- byte>,
u
ad
us to
This data space must be connected externally and this instruction allows
access externally connected memory.
RIinstruction is executed.
8. Write the operation carried out when MOVXA, @
[NOVIDEC -2022]
g
or
The 8-bit address of external memory is held by RO R1.
in
MOVX A,@ Ri ; where
i.=0 or 1
er
memory whose 8-bit address is
This instruction moves a byte from external
e
pointed to by the register Ri into the accumulator.
in
ng
9. What is arithnetic instruction?
as addition,
Arithmetic instructions perform several basic operations such
fE
subtraction, division, multiplication etc. After execution, the result is stored in
the first operand.
O
10. Write the function of logical instructions.
e
two registers like AND, OR, XOR, NOT, Rotate, Clear and Swap. They are
le
: SWAP A
Mnemonic
ad
:
Function Swap nibbles within the accumulator
iln
:
Flags None
Operation
Ta
D7 D4 D3 DO
Higher Lower
nibble nibble
<br>
Example:
g
SWAP A ;A=95H (10010101 in binary)
in
124What is meant by bit oriented instructions?
er
[APRMAY-2017 & NOVDEC-2019]
e
The bit oriented instruction is also
in
called as Boolean or Bit manipulation
instructions. It is similar to logic instructions
ng
which perform the logic operations.
The difference is that these are performed upon
single bits.
13. Define branch instructions.
fE
.Thebranch instructions are used to change the sequence of instruction execution
O
which controls the flow of program logic. There are three types
of branching
e
instructions are,
g
i) Jump instructions.
le
subroutine. Subroutines are often used to perform tasks that need to be performed
iln
Flags :
None
15. Define subroutine. [NOVIDEC- 2018]
Subroutines are often used to perform tasks that need to be performed frequently.
This makes a program more structured in addition to saving the memory space.
16. What is the function of
RET instruction of 8051? [NOVDEC-2010]
Mnemonic : RET
Function : Return from subroutine
<br>
g
program execution continuous at this new
address. The stack pointer (SP) is
in
decremented by 2.
er
(SP) -(SP) -2.
e
in
What is the difference between RET and RETI
instruction in 8051?
ng
[APRIMAY -2008 & 2011]
[OR] fE
Differentiate RET and RETI instructions.
[NOVDEC-2021]
O
(1) RET
e
Mnemonic : RET
g
Flags : None
ol
(SP) - (SP)-2.
m
(2) RETI
Ta
Mnemonic :
RETI
Function :
Return from interrupt
Flags : None
This is used at the end an interrupt
of service routine (interrupt
two bytes of the stack are handler). The top
popped into the program counter
execution continuous at this new and progra
address. Then, the program counter
the stack pointer (SP) is decremented by 2. (PC) and
<br>
8051Instruction set
|2.55
(PC) +(PC)-2
18. Write the functions
(SP) - (SP)-2
of jump instruction.
The jump instruction transfers
the program sequcnce to
the memory adaress
g
given in the operand based on the specified
flag. JUMP instructions are of two
in
types,
er
(i) Unconditional Jump Instructions
e
Transfers the program sequence to the described memory
in
address.
(ii) Conditional Jump Instructions
ng
Transfers the program sequence to the described memory
address only if the
condition is satisfied.
fE
19, Differentiate CALL instruction from JUMP instruction.
O
[NOVDEC-2017]
A CALL instruction is used to call a subroutinc,
e
updates the counter value and makes it point to another location inside
le
the program.
ol
[OR]
u
Give the format and functionof the instruction DJNZ for 80s1.
ad
NOVIDEC-2019)
iln
Function :
Decrement and jump if not zero
Ta
Flags : None
In this instruction a byte is decrementcd, and if the result is not zero it will
jump to the target address. This instruction supports following two
addressing modes (or) formats:
0) Register Mode:
Mnemonic : DJNZ Rn,targct (where n = 0 to 7)
DJNZ Rn, rel
<br>
g
Mnemonic DJNZ direct, target
in
DJNZ direct, rel
er
Decrements direct byte and jumps if not 0.
e
in
2.8 REVIEW QUESTIONS
ng
1. With necessary examples, discuss the instruction set of the 8051.
fENOVDEC- 2008, NOVDEC - 2022]
O
2. Explain the different types of instructions set used in 8051 microcontroller.
e
[NOVDEC - 2017|
g
[NOVIDEC - 2017
ol
5. Differentiate between
NOVDEC-2019)
ad
[APR/MAY - 2019]J
DO
<br>
UNIT-I'
Chapter 3
g
in
er
PROGRAM AND DATA MEMORY
e
in
3.1 PROGRAM AND DATA MEMORY: 8051 MICROCONTROLLER
ng
MEMORY ORGANIZATION: INTERNAL AND EXTERNAL
MEMORIES fE
O
3.1.1 Introduction
The 8051microcontroller memory is separated as program menory (ROM) and
e
data memory (RM) on the same chip (1C), whereas a microprocessor has to be
g
le
Memory
C
Unit
u
Data
ad
Memory
(RAM)
iln
m
Program
Memory
Ta
(ROM)
menmory unit
Fig 3.1 Microcontroller
8051 microcontroller has both internal ROM and internal RAM. If the internal
memory is inadequate, you can add external memory using the suitable circuits.
g
in
ROM.
original 8-bit 8051 microcontroller by Intel has 4KB of internal
er
any internal
Some variants of 8051 like the 8031 and 8032 series doesn't have
e
memory with instructions
ROM and must be interfaced with an external program
in
loaded in it.
ng
Almost all modern 8051 microcontrollers, like 8052 series, have 8KB of interal
fE
program memory (ROM) in the form of flash memory and provides an option of
reprogramming the memory.
O
g e
le
CPU
ol
(ALU, CU)
C
u
Program
ad
Memory
(ROM)
iln
UUU
m
Ta
4 When an External Access (EA =1) pin is HIGH, then the CPU first fetches the
instructions from the 4KB of internal (on-chip)
ROM in the address rang
of 0000H to 0FFFH and if the memory addresses
exceed this linl
then the instructions are fetched from the external
ROM in the address range 0
1000H to FFFFH.
<br>
g
in
OFFFH
Internal
er
Program
Memory
e
(ROM)
4KB
in
0000H
ng
Fig 3.3 Using both internal and external program memory witlh 8051
When all the instructions are fetch only from an external program memory
fE
(external ROM). Then, the EA pin must be connected to GND (EA= 0) and the
O
memory addresses of the external ROM will be from 0000H to FFFFH.
e
FFFFH
g
External
le
EA=0 Program
Memory
ol
(ROM)
64KB
C
nternal
ad
Program
Memory
iln
(ROM)
m
g
are divided into three different groups as follows:
in
(i) Register Banks.
er
(ii) Bit – addressable RAM, and
e
in
(ii) General purpose RAM (or) Registers (or) Scratch Pad RAM.
ng
7F
fE
Scratch Pad RAM
30
O
2F
Bit-Addressable RAM
e
20
g
1F
le
Register Bank 3
co
18
ol
17
C
Register Bank 2
10
el
u
OF
ad
07
Register Bank 0
m
00
Ta
g
3 B
R3 13 R3 1B R3
in
2 R2 A R2 12 R2 1A R2
er
R1 R1 11 R1 19 R1
RO 8 RO
e
10 RO 18 R0
in
Fig 3.6 8051 Register Banks and their RAM addresses
ng
By default, the 8051 microcontroller is
powered up with register bank 0.
Based on the possible combinations of bits RS1 and RSO
fE of PSW, the register
bank is changed accordingly, i.e., if RS1 and RS0 are 0,
then the Bank 0 is
O
selected. Similarly, Bankl, 2&3 are selected as per the values
of RS1and RSO
as shown in Table 3.1.
ge
0 00H – 07H.
ol
C
1 1
08H– 0FH
u
1
10H-17H
ad
1 1 3
18H- 1FH
iln
example, “ SETB PSW.3 " will make PSW.3 =l and select bank register 1.
These register banks are used to process the data when the microcontroller is
programmed.
(B)BitByte Addressable
-
The next 16B of the RAM from location 20H to 2FH are bit addressable
read/write memory. There are totally 128 (16 x 8) bits that can be addressed
<br>
individually using 00H to 7FH or 8 bits may form any byte address from 20H
to 2FH.
Example: 32H is the bit 2 of the internal RAM location 26H
g
or subtraction, then these
If we perform any operation whether addition
in
operations are unable to be performed directly in the memory, and therefore,
er
are performed by using the registers.
e
The RAM arca above bit addressable area from 30H to 7FH is called general
in
purpose RAM which is addressable as byte.
ng
3.1.4 Interfacing External Memory with 8051 Microcontroller
fE
4 External memory interfacing in 80S1 microcontroller involves connecting
O
external memory devices such as RAM and ROM t0 the microcontroller to
provide an additional memory space.
g e
This allows the microcontroller to execute larger and more complex programs,
le
to the microcontroller through a data bus and an address bus. The data bus is used
to transfer the data between the microcontroller and
u
P1 DO
PO
D7
EA
g
in
8051 ROM/EPROM
A0
er
CLK A7
ALE
e
P3
in
A8
PA
ng
PSEN A15
OE
fE
Fig 3.7Accessing external program
O
4 In Fig 3.7, the PSEN signal is used to activate an output enable signal of the
external ROM/EPROM.
g e
le
3.2 STACKS
ol
3.2.1 Introduction
C
a Definition:
u
ad
The stack is a section of internal RAM used by the CPUto store the information
temporarily. This information could be a data or an address. The CPU needs this
iln
f the stack is a section of RAM, then there must be registers inside the CPUto
point to it. The register used to access the stack is called the Stack Pointer (SP)
register.
The stack pointer is a small register used to point the stack. When we push
Something into the stack memory, then the stack pointer gets increased.
i
<br>
OFH
Stack
Bank -1 Space
(stack)
g
08H
in
Stack 07H
Pointer
er
Bank- 0 Stack
e
Memory
in
0OH
ng
Fig 3.8 Stack memory allocation in 8051 microcontroller
fE
The SP in the 8051 is 8-bits wide, and it can take a value of 00H to FFH. When
thé 8051 is initialized, the SP register contains the value 07H, by default, as it is
O
shown in the Fig 3.8. This means that the RAM location 08H is the first location
e
getting the contents from the stack back into a CPUregister is called
POP.
u
6 5
ad
iln
m
5 5 5
Empty Stack
Ta
4
<br>
g
in
3.2.3 Other Instructions
er
The other instructions of the 8051 that affect
the stack and the stack pointer are
e
ACALL, LCALL, RET, and RETI.
in
The CPUalso uses the stack to save the address of an instruction just below the
ng
CALL instruction because thè CPU knows where to resume when it returns
fE from
the called subroutine.
O
* The stack pointer can be initialized to any internal RAM address by the
e
MICROcONTROLLER
C
3.3.1 Introduction
u
inform that a
device needs its service. A single microcontroller can serve several
iln
(i) Interrupts:
Ta
Whenever any device needs its service, then the device notifies the
microcontroller by sending it an interrupt signal.
it
After receiving an interrupt signal, the microcontroller interrupts whatever
is doing and serves the device.
The program which is associated with the interrupt is called the Interrupt
Service Routine (JSR) or Interrupt Handler.
<br>
a Definition:
some
Interrupt is a sub-routine calls which is given to the microcontroller. When
other program with high priority is requesting for acquire the system buses than
an interrupt occur in current running program.
g
Interrupts provide a method to postpone or. delay the current process, thereby
in
performs a sub-routine task and then restart the standard program again.
e er
(ii) Polling
in
The microcontroller continuously monitors the status of a given device.
ng
When the conditions met, it performs the service. After that, it moves on in
order to monitor the next device until everyone is serviced.
fE
Polling can monitor the status of several devices and serve each of them as
O
certain conditions are met.
e
Drawback:
g
le
Advantages
u
i) It can serve many devices but not all at the same time.
Each device can get the attention
iln
g
Interrupt vector address- is the address where the controller jumps
in
&
after the
interrupt to serve the ISR.
e er
ROM location/
in
Interrupt Interrupt Pin Flag Clearing
Vector Address
ng
Reset 0000 H 9 Auto
External hardware
fE
interrupt 0 (INTO)
0003H P3.2(12) Auto
O
Timer O interrupt (TFO) 000BH Auto
e
External hardware
g
Timer 1
interrupt (TF1) 001BH Auto
ol
0023H
(RI and TI) clears it
u
Table 3.2 Interrupt Service Routine (1SR): Interrupt Vector Tabl for the 80S1
ad
interrupt:
saves the address of the
Ta
g
in
popping the top two bytes of the stack into the PC.
er
Then it starts to execute from that address.
e
in
3.3.4 Six Interrupts in the 8051: Vectored Interrupts
ng
as
The six interrupts in the 8051 are follows:
(0) Reset fE
It is the power-up reset which is the highest priority interrupt. When the reset pin
O
isactivated, then the 8051 jumps to address location 0000.
e
(TFO) and 7Timer 1 Interupt (TF1). Memory locations 000BH and 001BH
ol
Whenever timer overflows, timer overflow flags (TFOrTF1) are set. Then the
u
g
responded to by the microcontroller if they are activated. The interrupts must be
in
enabled by software in order for the microcontroller to respond to them.
er
* Interrupt Enable (E) is a register that is responsible for enabling (unmasking)
e
and disabling (masking) the interrupts.
in
D7 6 3 DO
ng
EA ET2 ES ETI EX1 ETO EX0
fE
Fig 3.10 IE(Anterrupt Enable) register
O
EA IE.7 It disables all interrupts.= When EA =0, no interrupt will be
acknowledged and EA 1
énables the interrupt individually
g e
interrupt.
u
interrupt
Enables (EX1 =1)or disables (EX] =0)external interrupt 1.
iln
EXI IE.2
ETO Enables (ETO= 1) or disables (ETO = 0) Timer 0 overflow
m
IE.1
interrupt
Ta
g
in
a Interrupt Priority (|P):
by assigning a higher priority
to
er
We can alter the sequence of interrupt priority
any one of the interrupts by programming a register
called Interrupt Priority
e
in
(IP).
any of the interrupts, we make the corresponding bit
ng
To give a higher priority to
or more interrupt bits in the IP register are set
to
in the IP register high. When two fE
high and these interrupts have a higher priority than others,
they are serviced
according to the sequence of Table 3.3.
O
External Interrupt 1
(INTI)
Timer Interrupt
u
1 (TF1)
ad
D7 6 5 4 3 2 DO
g
PT1
in
IP.3 Timerl interrupt priority bit
1= High priority
er
0=Low priority
e
PX1 IP.2 External interrupt 1 priority bit
in
1=High priority
ng
0= Low priority
PTO IP.1 fE
Timer O interrupt priority bit
1=High priority
O
0=Low priority
e
1= High priority
le
0-Low priority
ol
3.4.1 Introduction
iln
The 8051 has two timers/counters. They can be used either as timers in order to
generate a tme delay or as event counters to count events happening outside the
m
microcontroller.
Ta
Design
Embedded Systems and I0T
3.16
TLO
THO
D6 D5 D4 D3 D2 D1 DO
D13|D12 D11D10 D9 D7
D8
D15 D14
g
(a) Timers 0 Registers
in
er
TL1
TH1
e
in
D1 DO
D15D14D13| D12 D11D10 D9 D8 D7 D6 D5 D4 D3 D2
ng
(b)Timers 1 Registers
Fig 3.12
fE
O
3.4.2 Structure of TMOD (Timer Mode) Register
e
Both the timers 0 and I uses the same register is called as TMOD which is used
to
g
# TMOD is a 8-bit register in which the lower four bits are for Timer0 and the
ol
upper four bits are for Timer 1. In each case, the lower two bits (MI & MO) are
C
used to set the timer mode whereas, the upper two bits are used to specify the
u
operation.
ad
(MSB)
(LSB)
iln
Timer 1
Timer 0
Ta
g
16-bit timer/counter THX and TLX are cascaded;
in
there is no prescaler.
er
1 2 8 bit auto reload:
e
8-bit auto reload timer/counter; THx holds a value
in
which is to be reloaded into TLx each time it
ng
overflows.
1 1 3 Split timer mode
fE
O
Table 3.4
(i) c/T (Clock/Timer)
g e
This bit is used to decide whether the timer is used as a delay generator or an event
le
counter.
ol
The frequency for the timer is always 1/12" the frequency of thecrystal attached
iln
to the 8051.
m
XTAL
Ta
+ 12
oscillator
(iv) GATE
Timers of 8051 gets started and stopped by either a software or hardware control:
(a) GATE =0: Software is used.
- The
start and stop of the timer are controlled by the way of
sofhware using the
TR(timer start) bits TRO and TRI.
- The SETB instruction starts and stopped by the CLR instruction.
<br>
(b) The hardware way of starting and stopping the timer by an external source is
achieved by making GATE=1 in the TMOD register.
g
TCON is for interrupt functions and the upperfour bits are for tiner operations,
in
e er
MSB LSB
in
7 6 4
3 2
ng
TFI TRI TFO TRO IE1 ITI IEO ITO
fE
BIT SYMBOL FUNCTION
O
TCON.7 TF1 Timer loverflow flag
e
Bit 3: 1E1
u
An external interrupt 1
edge flag which is set by the hardware
ad
processed.
Bit 2: IT1
m
g
in
A Fig 3.15 shows Mode 0 which is a 13-bit
timer mode for which 8-bit of THx and
er
5-bit of TLx are
SB used. It is mostly used for interfacing possible with old MCS-48
e
family microcontrollers.
0
in
13-bit timer
0
ng
D12
DO
fE
Load 8-bit in THx Load 5-bit in TLX as prescaler
O
D7 DO D7 DO
8-bit THx register 8-bit TLx register
g e
Higher 3-bits of TLx should be written as zero while using a timer mode 0, or it
ol
will -affect the result. The 13-bit counter can hold the values between 0000 to
1FFFH in TH-TL. Therefore, when the timer reaches its maximum of 1FFFH, it
C
tern
ad
Mode I is a l6-bit timer mode which is used to generate a delay and it uses &-bit
m
THx TLX
D15 D0
After TH and TL are loaded with a 16-bit initial value, the timer must
be
(ii)
started. This is done by SETB TRO" for Timer '0' and " SETB TRI"
for
Timer 1'.
After the timer is stated, it starts to count up until it reaches its limit
of
(iii)
FFFFH. When it rolls over from FFFFH to 0000, it sets TF (timer flag)
bit
g
in
HIGH.
er
Each timer has its own timer flag: TFO for Timer 0, and TF1 for Timer. This
timer flag can be monitored. When this timer flag is raised, then we can stop
e
in
the timer with the instructions “ CLR TRO " or CLR TRI" for timer 0 and
ng
timer 1, respectively.
(iv) After the timer reaches its limit and rolls over, then to repeat the process the
fE
TH and TL must be reloaded with the original value, and TF must be
O
reloaded with 0.
e
XTAL
g
+ 12 TL TEF
oscillator
le
To generate a time delay using the timer's mode 1, the following steps are
ad
taken:
(i) Load the TMOD value register indicating which timer (timer 0 or s
timer 1)
iln
3.21
3.4.6 Mode 2
Programming
Operations (or) Characteristics:
()
The following are the
characteristics and operations
of mode 2:
) a
Itis 8-bit timer which allows only
values of 00 to FFH tobe loaded
into the timer's register TH.
g
ii) After TH is loaded with the 8-bit value,
in
the 8051 gives a copy of it to TL.
Then the timer must be started which
er
is done by the instruction “SETB
for timer 0' and SETB TRO"
TRI" for timer 1.
e
in
(ii) After the timer is started and it starts to count up
by incrementing the TL
ng
register until it reaches its limit of FFH. When it
rolls over from FFH to 00, it
sets TF (timer flag) HIGH.
(iv) When the TL register rolls from FFH to 0 and TF is set to 1, then TL is
g
reloaded automatically with the original value that is hold by the TH register.
le
To repeat the process, we must simply clear TF and without any need by the
ol
in contrast with mode 1 in which the programmer has to reload TH and TL.
u
ad
XTAL TF Overflow
+12
iln
oscillator flag
TR TF goes high
cT=0
m
Value gets automatically loaded into the TLx and TLx starts counting from that
value.
<br>
g
() Load the TMOD value register indicating which timer (timer 0 or timer 1)
in
is to be used, and the timer mode (mode 2) is selected.
er
(ii) Load the TH registers with the initial count value.
e
(ii) Start the timer.
in
(iv) Keep monitoring the timer flag (TF) with the JNB TE, target " instruction to
ng
see whether it is raised. Get out of the loop when TF goes
high.
(v) Clear the TF flag. fE
(vi) Go back to Step 4, since mode 2 is auto-reload.
O
3.5 COUNTER PROGRAMMING
e
# Timers can also be used as counters counting events happening outside the
g
TMOD and TH, TL registers are the same as for the timer.
C
u
the 8051.
4 The counter. counts up as pulses are
fed from pins 14 and 15 and these are
called TO pins
(timer 0 input) and T1 (timer 1 input).
Pin Port Pin Function Description
14 P3.4 TO Timer/counter 0 external
input.
15 P3.5 T1 Timer/counter 1 external input.
<br>
g
Port pins are used for Timers 0 and 1. In case of Timer 0, when C/T = 1, pin
3
in
P3.4 provides the clock pulse and. the counter counts up for -each clock pulse
er
coming from that pin.
e
Similarly, for Timer 1, when C/T = 1
each clock pulse coming in from pin P3.5
in
that makes the counter count up.
ng
(1) Counter 0 in Mode 1:
fE Overflow
flag
O
Timer 0 THO TLO TFO
external
input
e
register:
u
i)
1.
(11) M1:MO bits are set to 01 to select mode
iln
(iv) When GATE = 1; counter will run only if TRO is set tol and the logic signal
on external interrupt pin INTO is high.
Ta
(2) Counter 1
in Mode 1:
Overflow
flag
Timer 1 T1
external
input
TH1
TL1H
pin 3.5 TF1'goes high
TR1 when FFFF0
= 1
ciT
(mode 1)
Fig 3.20 Timer I with External Input
<br>
g
(iv) When GATE = 1, counter will run only if TRI is set tol and the logic signal
in
on external interrupt pin INTI is set to high.
er
(3) Counter O in Mode 2:
e
Overflow
in
flag
ng
Timer 0
external TFO
input TRO
pin 3.4 fE Reload
THO
O
cT=1 TFO goes high
e
when FF0
g
(mode 2)
To operate counter0 in mode
2 we have to perform the following
ol
.
(ii)) M1:M0bits are set to
10 to select mode 2.
ad
Overflow
Timer 1 flag
external TF1
input
g
pin 3.5 TR1
in
Reload
er
TH1
cIT
e
=1 TF1 goes high
in
when
FF0
Fig 3.22 Timer Iwith External Input (mode 2)
ng
3.5.2 TCON Register: Timer/ Counter Control Register fE
4 TCON (timer control) register is a 8-bit register. The upper
four bits are used to
O
store the TF and TR bits of both Timer 0 and Timer 1
and the lower four bits are
used for controlling the interrupt bits.
g e
The TROand TRIflags in TCON register are used to turn on or off the timers.
le
ol
(MSB) (LSB)
TF1 TR1 TFO TRO IE1 IT1
C
IEO ITO
u
ad
Symbol Position
Timer Overflow Flag. Set by hardware on
1
Ta
TF1 TCON.7
tmer/counter overflow. Cleared when interrupt
processed.
TRI TCON.6 Timer-1 Run control bit. Set/cleared by software to
turn timer/counter on/off.
TFO TCON.5 Timer 0 Overflow Flag. Set by hardware on
timer/counter overflow. Cleared when interrupt
processed.
<br>
g
processed.
in
IT1 TCON.2 Interrupt 1 Type control bit. Set/cleared by software
er
to specify falling edge/low level triggered external
e
interrupts.
in
IEO TCON.1 Interrupt 0 Edge Flag. Set by hardware when external
ng
interrupt edge detected. Cleared when interrupt
processed.
ITO TCON.0
fE
Interrupt 0 Type control bit, Set/cleared by software
to specify falling edgelow level triggered external
O
interrupts.
e
"SETB TRI" and "CLR TRI", we could use "SETB TCON.6" and « CLR
ol
Timer 0
u
Timer 1
SETB TRI SETB TCON, 6
CLR TR1 CLR TCON, 6
SETB TF1 SETB. TCON. 7
CLR TF1 CLR TCON. 7
Table 3.5 Equivalent instructions
for the TCON.
<br>
4 If GATE = 1, the start and stop of the timer are done externally through pins P3.2
and P3.3 for timers 0 and 1, respectively. This hardware way allows to start or
stop the timer extermally at any time via a
simple switch.
g
XTAL
Oscillator + 12
in
e er
c/T-1
in
TO IN
Pin 3.2
ng
TRO
Gate
fE
O
INTO Pin
Pin 3.2
e
a Timer0 and Timer 1 are turned ON by the software method using the
SETB
ol
TRO" and “ SETB TRI" instructions and which is beyond the control of the user
C
of that product.
u
XTAL +12
ad
Oscillator Tc/T-0
iln
m
c/T=1
T1 IN
Ta
Pin 3.5
TR1
Gate
INT1 Pin
Pin 3.3
g
5
in
1 2 3 4
e er
in
ng
fE
6 7 8 9
O
Pin Deseription
e
1
Data Carrier Detect (DCD)
g
le
g
The RS232 standard is not TTL Compatible, therefore,
it requires a line driver
in
(voltage converter) such as the MAX232 chip to convert RS232
voltage levels
er
to TTL levels, and vice versa:
e
o The RS232's signals to TTL voltage
levels will be acceptable at the 8051's
in
TxD and RxD pins.
ng
8051 MAX232
TxDO (P3.1)
11 11
fE
14
O
13
RxDO (P3.0) 10 12
DB-9
g e
le
* To allow the data transfer between the PC and 8051 system without any error, we
u
must make sure that the baúd rate of the 8051 system matches the baud rate of the
ad
* The 8051 transfers and receives data serially at many different baud rates. The
m
baud rate in the 8051 is programmable which is donc with the help of Timer 1.
Ta
4 The 8051 divides the crystal frequency by 12 in order to get the machine cycle
frequency. In the case of XTAL =l1.0592 MEHz, the machine cycle fequency is
921.6 kHz (11.0592 MHz /12=921.6 kHz).
* The 8051's serial communication UART circuitry divides the machine cycle
frequency of 921.6 kHz by 32 once more before it is used by Timer I to set the
baud rate. Therefore, 921.6 kHz is divided by 32 gives 28,800 Hz.
<br>
g
in
Fig 3.28 Baud rate in the 8051
er
must be programmed in mode 2, that
When Timer is used to set the baud rate it
1
e
in
with the values shown in Tabl 3.6.
ng
Baud Rate THI(Decimal) THI(Hex)
9600 -3 fE FD
4800 -6 FA
O
2400 -12 F4
e
-24 E8
g
1200
le
a SBUF is a 8-bit register used solely for the purpose of serial communication. For
u
a byte data to be transferred via the TxD line, it must be placed in the SBUF
ad
register. Similarly, SBUF holds the byte of data when it is received by 8051 RxD
iln
line.
m
g
by the software.
in
SM2 SCON.5 Serial port Mode control bit 2 which is used
for
er
multiprocessor communication.
e
REN SCON.4 Receiver Enable control bit. Set/cleared by the
in
software to enableldisable the serial data reception.
ng
TB8 SCON.3 Transmit Bit 8. Not widely used.
RB8 SCON.2
fE
Receive Bit 8: Not widely used.
O
TI SCON.I Transmit Interrupt flag. Set by HW and cleared by
SW.
g e
SW.
ol
) SMO, SM1:
u
bits determine the framing of data by specifying the number of bits per
character, and the start and stop bits.
iln
In the SCON register, when serial mode 1 is chosen, the data framing is 8
m
bits, I stop bit, and l start bit which makes it compatible with the COM port
Ta
of IBM/compatible PCs.
In serial mode 1, it allows the baud rate to be variable and is set by Timer
1
of the 8051.
0 Serial Mode 0.
1 Serial Mode 1,
8-bit data, 1 stop bit, Istart bit.
<br>
1 1 Serial Mode 3.
(i) SM2
enables the multiprocessing
g
SCON register and this bit
SM2 is the DS bit of the
in
capability of 8051.
er
(iii) REN (Receive Enable)
e
as since
is also referred to SCON.4
in
the SCON register which
It is D4 bit of
ng
SCON isa bit-addressable register.
bit is high (REN = 1), it allows the 8051 to receive data on the
() When REN fE
RxD pin of the 8051.
O
=
(ii) When REN bit is low (REN 0), the receiver is disabled.
SETB SCON.4" and
e
These instructions use the bit-addressable features of register SCON. This bit
ol
TB8 is bit D3of SCON which is used for both the serial modes 2 and 3.
ad
RB8 is bit D2 of the SCON register. In serial mode 1, this bits gest a copy the
of
m
(vi) TI (Transmit
Interrupt)
TI is bit Di of the SCON register. When 8051 finishes the transfer
of 8-b
character:
-
I raises TIflag to indicate that it is ready to transfer an
another byte.
TI bit is raised at the beginning
of the stop bit.
(vi) RI(Receive Interrupt)
.
RIis the DO bit of the SCON register.
After 8051 receives
RxD:
data serially
<br>
g
oscillator frequency
in
12
10-bit (start bit + 8-data bits + stop bit).
er
Variable
e
2 11-bit (start bit + 8-data bits + 1
in
programmable 9" data bit + stop bit). Programmable to either 32
ng
1
fE or
a oscillator frequency
3 11-bit (start bit + 8 data bit +| Variable
programmable 9" data bit + stop bit).
O
steps are used to program the 8051 in order to transfer the character
ol
The following
bytes serially:
C
) TMOD register is loaded with the value 20H which indicates the use of
u
(i) The THIis loaded with one of the values to set the baud rate for serial data
iln
transfer.
m
(ii) The SCON register is loaded with the value 50H which indicates serial mode
Ta
g
in
indicates serial
(iiü) Thc SCON register is loaded with the value 50H, which
er
receive
mode 1, where a 8- bit data is framed with start and stop bits and
e
cnablc is turned on.
in
(iv) TRI is set to 1 to start Timer 1.
ng
(v) RI is cleared by " CLR RI" instruction.
(vi) The RI flag bit is monitored with the use
fE of instruction " JNB RI, xx" if an
entire character has been received yet.
O
(vii) When RI is raised, SBUF has the byte and its contents are moved into a safe
e
place.
g
le
D7 DO
g
PCON.2 General purpose user flag bit 0. Set/cleared by program.
in
GFO
er
PD PCON.1 Power down bit. It is set to 1 by program to enter power
down configuration for CHMOS microcontrollers.
e
PCON.0 Idle mode bit. It is set to 1 by program to enter idle
in
IDL
mode configuration for CHMOS microcontrollers.
ng
Fig 3.30 PCON register fE
There is a software way to double the baud rate of the 8051 while the crystal
O
frequency is fixed. This is done with the register called PCON.
The PCON register is a 8-bit register. The bit that is used for the serial
g e
When the 8051 is powered up, D7(SMOD bit) of the PCON register is zero.
ol
We can set it to high by the software and thereby double the baud rate.
C
(2) SMOD
u
57600 Hz
ad
SMOD =1
11,0592 MHz +16 To timer
1 To set
XTAL
Machine cycle freq.
iln
+ 12 the Baud
oscillator 921.6 kHz 28800 Hz
+32 rate
m
SMOD =0
= 12 = 921.6 kHz
Machine cycle frequency 11.0592 MHz/
=
and 921.6 kHz /32 28,800 Hz for
SMOD =0.
<br>
g
Machine cycle frequency
in
Hz for SMOD = 1.
and 921.6 kHz/ 16=57,600
er
uses that
XTAL is divided by 16 and
XTAL = 11.0592 MHz, then 1/12 of
e
rate.
frequency for Timer l to set the baud
in
ng
(Decimal) (Hex) SMOD=0 SMOD=1
THÍ
9,600 19,200
-3 FD fE
-6 FA 4,800 9,600
O
- 12 F4 2,400 4,800
e
and SMOD =1
0
ol
Example-1
u
g
MOV R4, #0F3H
in
PUSH 6
er
1
PUSH
e
PUSH 4
in
ng
Solution
After PUSH 6 fE
After PUSH 1
After PUSH 4
OB OB OB 0B
O
OA OA OA OA F3
e
09 09 12 09 12
g
08 08 25 08 25 08 25
le
Example-3
C
.
Examining the stack, show the contents of the register and SP after execution
u
POP 3 ;
POP Stack into R3
iln
POP 5 ;
POP Stack into R5
POP Stack into R2
m
;
POP 2
Ta
Solution
After POP 3 After POP 5 After POP 2
OB 54 OB 0B OB
OA F9 OA
F9
09 76 09 76 09 76 09
08 6C 08 6C 08 6C 08 60
Start SP 0B SP= 0A SP = 09 SP = 08
<br>
Example-4
Indicate which mode and which timer is selected for each of the following.
(a) MOV TMOD, #01H (b) MOV TMOD, #20H (C) MOV TMOD, #12H
Solution
g
(LSB)
in
(MSB)
CIT M1 MO
er
GATE CIT M1 MO GATE
Timer 1 Timer 0
e
in
TMOD register
ng
Based on M1 and MO bits:
We convert the value from hex to binary. fE
(a) TMOD = 00000001, model of timer 0 is selected
O
(b) TMOD=00100000, mode 2 of timer 1 is selected
timerlare selected.
e
Example-5
ol
Find the timer's clock frequency and its period for various 8051-based
C
(a) 12 MHz
ad
(b) 16 MHz
iln
Solution
Ta
XTAL
+ 12
oscillator
T= 1/921.6 kHz=1.085 us
<br>
Solution
g
The machine cycle frequency of 8051 = 11.0592/12 = 921.6 kHz, and 921.6
in
LHZ/32 = 28,800 Hz is frequency by UART to timer 1 to set baud rate.
er
(a) 28,800/3 = 9600 where-3 = FD (hex) is loaded into TH1
e
(b) 28,800/12 =2400 where-12 = F4 (hex) is loaded into THI
in
(c) 28,800/24 = 1200 where -24 = E8 (hex) is loaded into TH1
ng
Example-7 fE
Ifthe crystal frequency is 22 MHz, what will be the baud rate if: (a) THÍ =-3;
O
(b) THI=-12 with SMOD =0 and SMOD= 1?
e
Solution
g
le
22
Machine Cycle freq. = 12 = 1833 kHz
C
57281 =
(a) With THI =-3, the baud rate is 3
19,093
iln
57281 =
(b) With TH =-12, the baud rate is 12
4773
m
g
are stored in the
In 8051 microcontroller, the code or instructions to be executed
in
Tha
program memory, which is also called as the ROM of the microcontroller.
er
original 8051 microcontroller by Intel has 4KB of internal ROM.
e
Write thefunction of data memory in 8051l microcontroller.
in
3.
The data memory or RAM of the 8051 microcontroller stores temporary data
and
ng
intermediate results that are generated and used during the normal operation of the
fE
microcontroller. Original Intel's 8051 microcontroller had 128B of internal RAM.
Almost all modern variants of 8051 microcontroller have 256B of RAM.
O
4. Define stack. [APRMAY-2018
e
The stack is a section of internal RAM used by the CPU to store the information
g
temporarily. This information could be a data or an address. The CPU needs this
le
point to it. The register used to access the stack is called the Stack Pointer (SP)
ad
register.
iln
6. What is ISR?
The program which is associated with the interrupt is called the Interrupt
m
Servico
Routine (ISR) or Interrupt Handler.
Ta
7. Define interrupt.
Interrupt is a sub-routine calls which is given to the
microcontroller. When so
other program with high priority is
requesting for acquire the system buses
an interrupt occur current
in running program.
Interrupts provide a method to postpone
or delay the current process, thereby
performs a sub-routine task and
then restart the standard program
again.
<br>
g
certain conditions are met.
in
Write the advantages of interrupts in
er
9. the microcontrollers.
The advantages of interrupts in the microcontrollers are,
e
in
() It can serve many devices but not all at the same time.
ng
Each device can get the attention of the microcontroller based on the
assigned priority. fE
For the polling method, it is not possible to assign priority since it checks
O
alldevices in a round-robin fashion.
e
(i) The microcontroller can also ignore (mask) a device request for service,
g
le
The group of memory locations which set separately to hold the addresses of
Interrupt Service Routines (ISRs) is called Interrupt Vector Table.
u
ad
Interrupt vector addrèss is the address where the controller jumps after the
interrupt to serve the Interrupt Service Routine (ISR).
m
g
0023H
in
Receive interrupt R1
er
Transmit interrupt T1 0023H
e
14. Define IE.
in
Interrupt Enable (IE) is a register that is responsible for enabling (unmasking)
ng
and disabling (masking) the interrupts.
fE
154 What is the difference between timer and counter operation in 8051?
NOVDEC-2004 & APRMAY-2005]
O
The 8051 has two timers/counters. They can be used either as timers in order to
e
generate a time delay or as event counters to count events happening outside the
g
microcontroller.
le
Both the timers 0 and 1 uses the same register is called as TMOD (Timer Mode)
C
TMOD is a 8-bit register in which the lower four bits are for Timer 0 and the
ad
upper four bits are for Timer 1. In each case, the lower two bits (M1 & M) are
iln
used to set the timer mode whereas the upper two bits are used to specify the
operation.
m
Mode 1 is a 16-bit timer mode which is used to generate a delay and it uses 8-bit
of THx and 8-bit of TLx toform a total 16-bit register.
18. Why mode-2 in 8051 microcontroller is also called an auto-related mode?
In 8051 microcontroller, mode 2 is a 8-bit auto-reload timer mode. In this mode,
we have to load the THx-8 bit value only. When the Timer gets
started, the THX
value gets automatically loaded into the TLx and TLx starts counting from thal
value.
<br>
There are two ways to increase the baud rate of data transfer in the 8051 are,
g
in
() To use a higher frequency crystal.
er
(ii) To change a bit in the PCON.(power control) register.
e
20. Which register has the SMOD bit, and what is its status when the 805! is
in
NOVVDEC -2021]
ng
powered up?
The PCON (power control) register is a 8-bit register. The bit that is used for the
fE
serial communication is D7, the SMOD (Serial mode) bit.
[APRMAY-2006]
I. Explain the RAM memory space allocation in
8051.
C
[NOVDEC-2017|
m
8OSl microcontroller?
How do youselect a register bank in
Ta
D
NOVDEC-2011 & APRMAY -2010, 1I]
access external memory devices in an 8051
O Explain with block diagram, how to
[NOVIDEC-2017]
based system.
(APRMAY-2016]
9. Explain the vectored interrupts in 8051 microcontroller.
80S1. [NOVIDEC-2007 & 08]
Writeashort notes on interrupt
of
10.
register in 8051 microcontroller.
l1. Briefly write about the IE and IP (NOVIDEC-2011)
g
(TMOD) register of 8051.
in
options available with Timer Mode
12. Illustrate the
[NOVIDEC-2021 & APR/MAY-2023/
e er
witlh neat diagram.
13. Disciuss in detail about TCON register
in
and mode -2 timer operations the control
witlh
I
ng
14. Write about the mode
registers used in 805I.
(NOVDEC -2022)
15.
fE
Explain the different modes of operation of timers in 8051 in detail
with its
[NOVDEC -2004 & APRMAY-2011, 17]
O
associated registers.
16. Draw the block diagram of Intel 8031/805I timer/counter and erplain its
e
[APRMMAY -2004]
g
18. Draw and explain SCON special function register. [NOVDEC -2010]
C
19, Discuss in detail about the serial data transfer in 8051. (NOVDEC-2022|
u
ad
iln
m
Ta
<br>
UNIT - II
Chapter 4
g
in
EMBEDDED COMPUTING
e er
4.1 EMBEDDED SYSTEM DESIGN PROCESS
in
ng
4.1.1 Introduction
A Objectives: fE
The two major objectives of an embedded system design process are
O
() I will give us an introduction to the various steps involved in embedded
system design before we know into them in more detail.
g e
A Methodology:
C
Understanding your design mcthodology helps you to ensure that you didn't skip
reasons:
anything. A design methodology is important for the following three
u
ad
functional tests.
Ta
g
in
4.1.2 Steps
Fig 4.1 summarizes the major. steps involved in
the embedded system design
er
process. ln top-down design, we will begin with the most abstract
description of
e
the system and it concludes with the concrete details.
But in the bottom-up
in
a system. The real design
design, we start from small components to build large
ng
often uses the both techniques.
In this top-down view, we start with the system requirements and specification
that is we create a more detailed description of what we want?
The bottom-up design information to help us refine
the system and its steps are
shown in the Figure 4.1 as dashed-line arrows.
The specification states only how the system
behaves, not how it is built? Tne
details of the system's internals begin to
architecture, which gives the system structure
take shape. when we develop
in terms of large components.
e
<br>
Embedded Computing
4.3
Once we know the
needed components, we can
components, including design our need using
both the software modules those
-Based on those components, and any specialized hardware.
we can finally build a
complete system.
Major Goals:
The major goals
of the embedded system design are,
g
in
(i) Manufacturing cost,
er
(ii) Performance (both
overall speed and deadlines),
and
e
(iii) Power consumption.
in
ng
a Tasks:
The tasks which should be performed at every fE
step in the design process:
(i) We must analyze the design at each step to
determine how we can meet
O
the specifications.
e
as
such cost, speed, and so on.
C
4.1.3 Requirements
u
At the initial stages of the design process, we must know what we are
designing?
ad
requirements, and
(a) We refine the requirements into a specification that contains enough
information to begin the designing of the system architecture.
g
Talking to marketing representatives, and
in
er
users for comment.
Providing prototypes to the
e
as a function of output) or
Requirements may be functional (output
in
not sufficient.
non-functional. Functional description is often
ng
s Nonfunctional Requirements: fE
The typical nonfunctional requirements are,
O
() Performance:
e
usability of the
The speed of the system is major consideration for the
a
g
such
The performance may be a combination of soft performance metrics
ol
(ii) Cost:
The target cost or the purchase price of the system is almost a consideration.
iln
assembly, and
(b) NonRecurring Engineering (NRE) costs include the personnel and
other costs of designing the system.
(ii) Physical size and weight:
The physical aspects ofthe final system depend upon the application.
A handlheld device typically has
tight requirements on both the size
weight that can be considered through the
entire system design.
<br>
Embedded Computing
4.5
(iv) Power Consumption:
Power is an important consideration
in other applications.
in the battery-powered systems as well as
It can be clearly specified in the requirements
terms of a battery life. stage in
g
Validating a set
of requirements is a psychological task because it requires
in
understanding both i.e., what the people want
and how the communicate
er
those needs.
e
One good way is an user interface portion
of a system's requirements is to
in
build a mock-up which may uses canned data to simulate the
functionality in a
ng
restricted demonstration, and it may be executed on a PC or a workstation.
fE
It should give the customera good idea that how the system will be used and
how the user can react to it. Generally, the nonfunctional models of devices
O
can also give customers a better idea of characteristics such as size and
weight.
e
g
o Requirements analysis for a big system can be complex and a time consuming
ol
o
as a checklist and it is considered as the
the project. We can use this form
iln
Purpose
Inputs
Outputs
Functions
Peformance
Manufacturing cost
Power
Physical size and weight
requirements form
Fig 4.2 Sample
<br>
g
(i) Purpose:
in
It is a one or two-line description that what the
system is supposed to d.
er
(ii) Inputs and outputs:
e
an idea about the following detail:
in
The inputs and outputs to the system gives
ng
Types of data,
Data characteristics, and
Types of I/O devices.
fE
O
(iv) Functions:
system does. A good
The function is a more detailed description of what the
e
(v) Performance:
ol
(vi) Power:
consu
We may have only a rough idea of how much power the system can
Typically, the most important decision is whether the machine will be battery
powered or plugged into the wall.
spend
Battery-powered machines must be much more careful about how they
energy.
<br>
Embedded Computing
4.7|
(vii) Physical Size and Weight:
Some indication of the physical size and weight of the system is to
help guide
certain architectural decisions.
4.1.4 Specification
g
4 The specification serves as the contract between the customer and
the architects.
in
It must be carefully written so that it can accurately
reflects the customer's
er
requirements that can be clearly followed during the design.
e
4 Specification is essential in creating the working systems with a minimum of
in
designer effort.
ng
# The specification should be understandable because someone can verify that
fE
whether it meets system requirements and overall expectations of the customer.
O
# Designers can run into several different types of problems caused by unclear
specifications. So, the designers must know what they need to build.
g e
Example:
le
User interface.
Operations that must be performed to satisfy the customer requests.
iln
Search Display
g
GPS Renderer
receiver engine
in
er
User
e
Interface
in
Database
ng
Fig 4.3 Block diagram for the moving map
fE
The above diagram is giving an idea that helps in
implementing the functions
4.3
described in the specification. We can refine the system block diagram in Fig
O
into two block diagrams as shown in Fig 4.4:
e
The hardware block diagram clearly shows that one central CPUsurrounded by
C
memory and I/O devices. We have chosen to use two memories: a frame buffer
u
for the pixels to be displayed and a separate program'data memory for general
ad
The software block diagram closely follows the system block diagram and added
a timer to control when we read the buttons on the user interface and render data
m
First, we can concentrate on the functional elements in the system block diagram
and then consider the nonfunctional constraints when creating the hardware and
software architectures.
<br>
Embedded Computing
4.9
Frame
buffer CPU
Display
GPS receiver
g
Memory.
in
er
Panel /O
Bus
e
in
(a) Hardware
ng
Database fERenderer Pixels
search
O
e
(b) Software
C
or .
The designer must spend time for architecting the system before start coding
iln
g
process.
which is designed to be useful at many levels of abstraction in the design
in
er
Object-oriented design emphasizes two important concepts:
e
() It encourages the design to be described as a number of interacting objects,
in
rather than a
few large monolithic blocks
of
code.
ng
(ii) We can also use UML to model the outside world that interacts with our
system such objects may be a people or other machines. Thinking of the
fE
design in terms of actual objects helps us understand the natural structure of
O
the system.
Object-Oriented (00) specification can be viewed in two complementary ways:
g e
(i) Itprovides a basic set of primitives that can be used to describe systems
C
provide a basic methods that are similar for structuring large systems.
m
Structural description means the basic components of the system. The principal
component of an object-oriented design is the ohject. An object includes a set
of
attributes that define its internal state.
When implemented in a programming language, these attributes usually become
variables or constants held in a data structure.
An object describing a display such as a CRT screen in UML notation is shown
in Fig 4.5. The text in the folded-corner-page icon is a note which does nol
correspond to an object in the system and only serves as a comment.
<br>
Embedded Computing
4.11
Pixels is d1: Display
a 2-D array Object name: class name
pixels: arrayl] of pixels
elements Atributes
menu_items
g
& The attribute is an array
of pixels that holds the contents of the display.
in
object is identified in two ways: It The
has a unique name, and it is a member a
er
class. of
e
# The name is underlined to. show that this is a
description of an object and not
in
class.
ng
(1)Classes as Types
A Definition: fE
A class defines the attributes that an object may have. It also defines the
O
operations that determine how the object interacts with the rest of the world.
e
the same characteristics even their attributes may have different values.
le
have
ol
pixels
ad
elements Attributés
menu_items
Pixels is
iln
a 2-D array
m
mouse_click( )
draw_box() Operations
Ta
g
design. The proper interface must provide
in
well as the ways to update the state.
er
Relationships between Objects and Classes:
e
can exist between objects and
in
There are several types of relationships that
ng
classes:
(i) Association: fE no
It occurs between objects that communicate with
each other but have
O
ownership relationship between them.
e
(i) Aggregation:
g
(iii) Composition:
owner does not allow the access to
C
(iv) Generalization:
It allows us to define one class in terms of another.
iln
UML allows us to define one class in terms of another. Fig 4.7 shows a
Ta
one-bit pixels.
(ii) color map to allo
Color_ map_display uses a graphic device known as a
the user to select from a large number of available colours even wiu
small number of bits per pixel.
<br>
Display
pixels
objects Base class
menu_item s
pixel( )
g
set_pixel()
mouse_click ()
in
draw_box()
8,k
er
Generalization
e
in
BW_display Color_mnap_display
ng
color_map
fE
O
Derived classes
e
The color_ map_display class defines a color map attribute that determines
ol
In this case, Display is the base class for the two derived classes. A derived
class is defined to inclde all the attributes and operations of its base class.
u
ad
s Inheritance: "
iln
another class.
Ta
g
in
class for sound. base
attributes and operations of both its
inherits all the
er
The derived class
speaker.
classes such as display and
e
in
Display
Speaker Base class
ng
fE
O
g e
Multimedia_display
le
Derived class
ol
C
and Associations
ad
(5) Links
capure
A
link describes a relationship between objects and association is the
iln
actual objects in the system, there is a set of messages that keeps track of
Ta
active messages.
we
In this case, the link contains the relation. generalized into classes,
When
define an association between the message set class and the message cla
The association is drawn as a line between the two labeled class with the nate
of the association, namely, contains.
The ball and the number at the message class end indicate that the messag
may include zero or more message objects.
<br>
Embedded Computing
4.15
message msg1: mnessage
msg = msg1
set1: message set
length 1102
message set
msg2: message
Count =2
message
g
msg =msg2
in
length =2114|
er
(a) Links between objects
e
in
message
ng
Contains message set
msg: ADPCM_stream
0.* cOunt: integer
length: integer fE
O
(b)Association between classes
One' way to
specify the behavior of an operation is a state machine. Fig 4.10
ol
shows UML states and the transition between two states are shown by a skeleton
C
arrow.
u
ad
State
iln
a b
Name
m
Ta
() Signal:
It is an asynchronous occurrence which is defined in UML by an object and
it is labeled as a << signal>>.
<br>
(ii)Call Event:
g
This call event follows the model of a procedure call in a programming language.
in
er
(iii)Time-Out Event:
e
A time-out event causes the machine to leave a state after a certain amount
in
of time. The label tm(time-value) on the edge gives the amount of time after
ng
which the transition occurs.
<<signal>>
le
X, y: position
Parameters
u
Signal event
ad
Event
iln
draw_box(10,5,3,2,blue)
d
m
Call event
Ta
tm(time-value)
e. f
Time-out event
Embedded Computing
4.17|
A state machine for an operation
of the display is shown in Fig 4.12. The start
and stop states are special states that
help us to organize the flow of the state
machine.
The states in the state machine represent
different conceptual operations. In
Some cases, we take conditional transitions out
of states based on inputs or
g
the results of some computation done the state.
in
in In other cases, we make an
unconditional transition to the next state.
er
o Splitting a complex operation into several states helps us to document
e
the
required steps, much as subroutines and it can be used to structure
in
the code.
When several objects are involved, it is useful to
ng
show the sequence of
operations over time.
fE
Start state
O
Stop state
le
highlight(objid)
region = drawing/
find_objec(objid)
Object
u
Found object
highlighted
ad
d1: Display
m: Menu
Object m: Mouse
g
in
cal _menu(i)
er
Focus of
control
e
in
Lifeline
ng
Fig 4.13 A sequence diagram in UML
fE a
Each object is extending by its lifeline which is dashed line that shows how
O
long the object is alive. In this case, all the objects remain alive for the entire
sequence, but in other cases objects may be created or destroyed during the
g e
processing.
le
The boxes along the lifelines show the focus of control in the sequence, that
ol
is, when the object i actively processing. In this case, the mouse object is
C
The display object uses call events to invoke the menu object twice: once to
ad
determine which nenu item was selected and again to actually execute the
menu call.
iln
m
4.2.1 Introduction
Let us consider a simple system
that is, a model train controller which 1S
illustrated in Fig 4.14 in order to
learn how to use UML to model
The user sends messages
the systems.
to the train with a control box attached
The control box may to the tracks.
have familiar controls
button, and so on. such as a throttle, emergency S
<br>
Embedded Computing
4.19
Receiver,
motor controller
Power
g
|supply
in
er
Console
e
in
ng
System setup
Message
fE
Header AddressComman d ECC Motor| Receiver
O
Track
g e
le
Console
ol
voltage.
m
4.2.2 Requirements
Name Model train controller
model trains
Control speed of up eight
to
Purpose emergency stop, train number
Throttle, inertia setting,
g
Inputs.
in
Train control signals
Outputs upon inertia settings;
Set engine speed based
er
Functions
respond to emergency stop
at least 10 times per second
e
Can update train speed
in
Performance
Manufacturing cost $50
ng
Power 10 W (plugs into wall)
two hands,
Physical size and weight Console should be comfortable for
fE weight
approximate size of standard keyboard;
less than 2 pounds
O
Fig 4.15 Requirements in chart format
e
reverse.
63 different levels in each direction i.e., forward and
u
inertia
responsiveness of the train to commanded changes in speed. The
control will provide atleast eight different levels.
iln
(v)
The DCC was created to provide a standard that could be built by any
manufacturer. Therefore, we can use mix and match components from multip
vendors.
<br>
Embedded Computing
4.21|
(1) DCC Standards
() Standard S-9.1
This is the DCC electrical standard
that defines how bits are encoded on the rails
g
for transmission.
in
(i) Standard S-9.2
er
This is the DCC communication standard that defines the
packets that carry
e
in
information.
ng
(2) DCC Electrical Standard
The DCC electrical standard deals with voltages and currents on the track.
fE
This standard must be carefully designed because the main function of the
O
track is to carry power to the locomotives.
e
The signa! encoding system should not interfere with power transmission
g
The data signal swings between two voltages around the power supply
C
voltage. In the Fig 4.15, bits are encoded in the time between transitions, not
u
whilea l is
ad
is atleast 100us
only by voltage levels. The bit time of 0'
nominally 58us.
iln
a
o The specification also gives the 'allowable variations in bit times that
m
as allowable
describes other electrical properties of the system, such
transition times for signals.
Time
=100 us
58 us
Fig 4.15 Bit encoding in DCC
<br>
g
in
where,
a sequence of atleast 101 bits.
er
P - Preamble, which is
e
S-
in
is 8 bits
A
- Address data byte that gives the address of the unit which
ng
long.
s- Data byte start bit, which is a 0 bit.
fE
D - Data byte, which is bits long and it may contain an address,
O
instruction, data, or error correction information.
E- Packet end bit, which is a 1
bit.
g e
A baseline packet is the minimüm packet that must be accepted by all DCC
ol
(ii) Error. correction data byte that is used to detect and correct
iln
transmission errors.
m
a Definition:
The conceptual specification helps us to write a detailed specification that needs
tobe given to a system architect.
A train control system turns comnands into packets. A command comes from
the command unit while a packet is transmitted over the rails.
Fig 4.16 shows a generic command class and several specific commands derived
from that base class such as Set-speed, Set-inertia and Estop (emergency
stop).
<br>
Embedded Computing
|4.23
Command
g
Set-speed Set-inertia
in
Estop
value: integer
er
value: unsigned-integer
e
Fig 4.16 Class diagramfor the train controller commcnds
in
(1) Subsystems:
ng
There are tvo najor subsystens and each of these has its own internal
structure:
fE
O
) Command unit, and
(ii) Train-board component (receiver)
g e
receiver -are each represented by the objects; the command unit sends a
C
1..n: command
ad
:Console :receiver
iln
subsystems of
the train controller system
Ta
The console sends all the messages, which are numbered the arrow's
messages as 1..n: Those messages are carried over the track.
O. The console needs to perform the following three functions:
on the command unit,
Read the state of the front panel
Format messages, and
Transmit messages.
O, The train receiver must also perform three major functions:
Interpret the message (taking into account the current speed, inertia
setting, etc.), and
Control the motor.
(2) UML Class Diagram
g
Fig 4.18 illustrates the UML class diagram which shows the console class using
in
three classes and its basic characteristics are,
er
)) The Panel class describes the command unit's front panel, which contains
e
the anialog knobs and hardware to interface to the digital parts of the
in
system.
ng
(ii) The Formatter class includes behaviors that know how to read thepanel
fE
knobs and creates a bit stream for the required message.
(ii) The Transnmitter class interfaces to analog electronics to send the message
O
along the track.
Some special classes that represent the analog componets as,
g e
(i) Knobs * deseribes the actual analog knobs, buttons, and levers on the control
le
panel.
ol
(iü) Sender* describes the analog electronics that send bits along the track.
C
Train set
Documentation
u
only
-
ad
1..t
Console Train
iln
1 1
m
1
1 1 1 1
Transmitter
Ta
1 1 1
1 1 1
Detector Pulser
Knobs* Sender
-Physical object
Train makes use oftthree other classes that define its components:
g
in
(ii) The Motor interface class defines how to generate the analog signals
er
required to control the motor.
e
Two classes to represent analog components:
in
(1) Detector* detects analog signals on the track and converts them into digital
ng
form.
(ii) fE
Pulser* turns digital commands into an analog signals required to control
the motor speed.
O
a Fig 4.19 showS a class diagram for these classes which shows a little more detail
g
le
(iii) Inertia.
ad
Knobs* Pulser*
iln
direction: boolean
inertia-knob: unsigned-integer
emergency-stop: boolean
Ta
set-knobs()
Sender
Detector
control system
ig 4.19 Classes describing analog physical objects in the train
<br>
g
in
system to modify the knob settings.
put out and
The Sender and Detector classes are relatively simple. They simply
er
to control the train
pick up a bit, respectively. The Pulser class actually used
e
in
motor's speed.
ng
Panel Motor-interface
speed: integer
panel-active( ): boolean
fE
train-number( ): integer
O
speed(): integer
inertia( ): integer
estop( ): boolean
e
new-settings( )
g
le
Fig 4.20 Class diagram for the panel and motor interface
Fig 4.20 shows the classes for the panel and motor interfaces. These classes
ol
forms the software interface to their respective physical devices. The Panel
C
The Motor-interface defines an attribute for speed that can be set by other
ad
classes.
The Transmitter and Receiver classes are shown in Fig 4.21.
iln
track.
Ta
Transmitter Receiver
current: command
new: boolean
send-speed(adrs: integer, read-cmd( )
speed: integer)
send-inertia(adrs: integer new-cmd (): boolean
val: integer) rcv-type(msg-type:
send-estop(adrs: integer) command)
rcv-speed(val: integer)
rcv-inertia(val: integer)
Embedded Computing
4.27|
The Transmitter provides a distinct behavior for
each type of message that can
he sent and it internally takes care of formatting the message.
The Receiver clasSS
a
nrovides read-cmnd behavior to read a message
off the tracks.
The Formatter class is shown in Fig 4.22, which holds the current control
settings for all the trains. The send-command method is a utility function that
g
serves as the interface to the transmitter. The operate function performs the basic
in
actions for the object.
eer
Formatter
in
curr ent-train: integer
ng
Curr ent-speed[ntrains]: integer
curr ent-inertia[ntrains]: unsigned-integer
fE
curr ent-estop[ntrains]: boolean
O
send-command( )
panel-active( ): boolean
g e
operate( )
le
is illustrated by the
The role of the formatter during the panel's operation
ad
:Formatter :Transmitter
:Knobs :Pane!
speedlinertia/estop
Change in
control settings Read panel
panel-active
Panel settings
|send-speed,
send-command send-inertia,
g
Read pand
Panel settings send-estop
in
in
er
Change
e
Read pand
number|
Panel settings
in
ng
Change in train number Read pand
train
Panel settings
in
Change
set-knobs
fE
new-settings
Operate
O
new-settings( )
C
)
panel-active( New train number
Idle
u
send-command()
ad
Other
iln
Formatter class is shown in Fig 4.24. This behavior watches the panel for
Ta
activity. If the train number changes, it updates the panel display otherwise, it
causes the required message to be sent.
Fig 4.25 shows a state diagram for the
panel-active behavior.
4 The class diagram of train's. controller class is shown in Fig 4.26. The operate
behavior is called by the receiver when it gets a new
command; operate looks al
the contents of the message and uses the issue-command
behavior to change th
setting of speed, direction, and inertia as necessary.
<br>
Embedded Computing
4.29
Start
T current-trai n = train-knob
panel": read-knob ()
update-scr een
changed = true
F current-train I= train-knob
g
in
T
curr
er
panel": read-speed() ent-speed=throttle
changed=true
e
current-speed throttle
in
ng
panel": read-inertia( curr ent-inerti a=
inertia
fE
knob change d =true
F current-inertia = inertia-knob
O
e
T
panel": read-estop ) current-estop = estop-button -
g
F current-estop estop-button
ol
value
C
Return change d
u
ad
Stop
iln
Controller
Ta
current-train: integer
current-speed[ntrains]: unsigned-integer
current-dir ection[ntrains]: boolean
curr ent-inertia[ntrains]: unsigned-integer
operate( )
issue-command( )
Controller class
Fig 4.26 Class diagram for the
<br>
Wait for
command from
receiver
g
in
read-cmd
issue-command()
e er
in
operate behavior
Fig 4.27 State diagram for the Controller
ng
the reception of a set-speed
The operation of the Controller class during
fE
command is illustrated in Fig 4.28. The Controller's
operate behavior must
message.
execute several behaviors in order to determine the nature of the
O
new-cmd
ad
rcv-typ e
rcv-speed
iln
Set-pulsé
Set-speed
m
Set-pulse
Ta
Set-pulse
Set-pulse
Set-pulse
read-cmd operate
Fig 4.28 Sequence diagram for a set-speed command received by the train
<br>
Embedded Computing
4.31|
4,3 TWO MARKS QUESTIONS AND
ANSWERS
Write the objectives of an
embedded system
design process.
The two major objectives an
of embedded system design process are
) It us an introduction to the
will give
various steps involved in embedded
system design before we know
g
into them in more detail.
in
(i) It will allow us to get an idea about the design methodology
itself.
er
2 Why design methodology is inportant in embedded system design
e
process?
in
design methodology is important for the following
A
three reasons:
ng
() Optimizing performance,
(ii) Automated steps. fE
(iii) Easy understanding.
O
3. Name the five basic steps involved in embedded system design process.
e
() Requirements,
ol
(G) Specification,
C
(ii) Architecture,
u
i) Manufacturing cost,
deadlines), and
(i) Performance (both overall speed and
(ii) Power consumption.
Define requirement in embedded design.
Requirement is a plain language description of what the user wants and
expects
1O get.
It may be developed in several ways:
g
(i) Performance,.
in
(ii) Cost,
er
(ii) Physical size and weight,
e
(iv) Power consumption.
in
7. Define architecture design.
ng
The architecture is a plan for the overall structure of the system that will be used
fE
later to design the components that make up the architecture. The creation of the
architecture is the first phase of what many designers think of as design.
O
8. What is UML?
e
9. Define class.
A class defines the attributes that an object may have. It also defines the
C
operations that determine how the object interacts with the rest of the world.
u
A class defines both the interface for a particular type of object and also for that
ad
object's implementation.
iln
Embedded Computing
g
in regular expression as,
in
PSA(sD)
+E
er
where,
e
in
of atleast 101 bits.
S - Packet start bit which
ng
is a 0 bit.
A - Address data byte that gives
the address of the unit which
fE
long. is 8 bits
O
S Data byte start bit, which is a 0 bit.
D - Data byte, which is 8 bits long
e
-
E Packet end bit, which is a 1 bit.
ol
() An address data byte that gives the intended receiver of the packet.
iln
(ii) Error correction data byte that is used to detect and correct transmission
Ta
errors.
% What is the function of conceptual specification?
2. Discuss in detail about the basic steps involved in embedded system design
process.
3. List and discuss about nonfunctional requirements af embedded system design.
g
Write note on specification in embedded design process with an example.
in
S.
er
6. With an example, discuss about architecture designin embedded system.
e
-7.
Explain about sample requirements form with an example.
in
8. With neat sketches, explain about embedded system design process.
ng
9. Explain about designof model train controller with neat sketches.
fE
O
g e
le
ol
C
u
ad
iln
m
Ta
<br>
UNIT - II
Chapter 5
g
in
ARM INSTRUCTION SETS
e er
5.1 ARM PROCESSOR
in
Introduction
ng
5.1.1
a Definition:
An Advanced
fE
RISC Machine (ARM) processor is one of a family of Central
O
Processing Units (CPUs) based on the Reduced Instruction Set Computer
(RISC) architecture for computer processors.
e
and other consumer electronic devices. This needs a very few instruction sets
le
ol
and transistors.
C
I Advantages:
The advantages of ARM processor are,
u
(i) has less power consunption along with reduced complexity in its circuits.
t
iln
ARM processor can be applied to various designs such as 32-bit devices and
embedded systems and we can even be upgraded according to the user needs.
Ta
ARM instructions are written one per lne, starting after the first column.
Comments begin with a semicolon and continue to the end of the line. A label
gives a name to a memory location, comes at the beginning of the line, starting
in the first column:
architecture.
g
in
The ARM architecture supports two basic types of data:
er
Standard ARM Word is 32 bits long, and
Word may be divided into four &-bit bytes.
e
in
addresses to be 32 bits long and an address refers to a byte, not a
ARM7 allows
ng
space is at location 0, the word 1 is at 4,
word. Th word 0 in the ARM address.
the word 2 is at 8, and so on. As a result, the PC is incremented by 4.
fE in a
The ARM processor can be configured at power-up to address the bytes
O
word in either little-endian or big-endian mode, as shown in ig 5.1. Big endian
stores the Most Significant Bytes (MSBs) first, whereas litle endian stores the
g e
Bit 31 Bit 0
ol
Word 4
C
MSB LSB
ad
Bit 31 Bit 0
m
Word 4
Ta
Byte 0 Byte 1
Byte 2 Byte 3 Word 0
LSB MSB
(B) Big -endian
Fig 5.1Byte organizations within anARM word
g
in
e er
in
ng
fE
O
Rrgintet iCTSS:
g e
le
ol
C
u
ad
iln
m
Ta
<br>
5.4
Embedded Systems and
10T Design
This register is setup automatically
during every arithmetic, logical., or
shifting operation. The top
four bits of the CPSR hold the following useful
information about the results
of that arithmetic/logical operation.
() The negative N).bit is set when the
g
result is negative in two's.
in
complement arithmetic.
er
(ii) The zero (Z) bit is set when every bit of
the result is ero.
e
(ii) The carry (C) bit is set when there is a.carry out of
the operation.
in
(iv) Thë overflow () bit is set when an arithmetic operation results in an
ng
overflow.
These bits can be used to easily check the results
fE of an arithmetic operation.
O
(2) Data Processing Instructions
e
The following instructions are used for data processing in ARM processor:
g
pre-processing
Rn Pre-processing
Rm
Barrel shifter
SI
SE
No Result N
RS
Arithmetic logic unit
RS
Rd
<br>
Sete
Instruction
RM
are 32-bit which are 5.5
All operands coming from registers
or literals and the
are placed in any register.
results
One operand to ALUis routed through
the Barrel shifter. Thus,
modified before it the operand
can be is used which is usefiul for fast multiplication
and
dealing with lists, table and other complex data structure.
g
The basic formof a data instruction is simple as,
in
er
ADD r0, rl, r2
e
This instruction sets register r0 to the sum of the values stored in rl and r2.
in
Instrüctions
) Arithmetic
ng
The arithmetic operations perfom addition and subtraction and with carry
fE
versions inchude the current value of the carry bit in the computation.
ADD Add
O
SUB Subtract
le
Rd= Rn+N
ADD Add two 32-bit values
iln
|ADC Add two 32-bit values and carry Rd= Rn +N+ carry
m
Rd= Rn-N
Ta
Rd - Destination
register
Instructions
Table 5.l Arithmetic
<br>
g
SUB R0, R1, R2
in
SBC R0, R1, R2 @RO =
RI– R2-!C
er
RSB R0, R1, R2 @ RO = R2- RI
e
RSC R0, R1, R2 @ RO =R2- R1 -!C
in
ng
(i) Multiplication Instructions
instructions. Here, Rs is the
The basic,ARM provides two multiplication fE
source register and Rd and Rm cannot be the same register.
O
Multiply and accumulate Rd = (Rm * Rs) + Rn
MLA
Rs
Rd= Rm *
e
MUL Multiply
g
Example:
ol
The bit-wise logical operations perform logical AND, OR, and XOR that is,
exclusive -or (EOR) operations.
iln
IHstruclion Sets.
ARM
5.7
RO, R1, R2 @
BIC RO
=RI AND (~R2)
g
LSL Logical shift left (zero
fill)
in
er
LSR Logical shift right (zero fill)
e
ASL Arithmetic shift left
in
ng
ASR Arithmetic shift right
The slhift modifier is always applied to the second source operand. The LSL
ol
and LSR modifiers perform left and right logical shifts, filling the least
C
Destination
iln
(a) LSL.
m
Ta
...0 Destination CF
(b) LSR
Fig 5.4
ARM has two arithmetic shift operations: ASL and ASR. ASL is an
arithmetic shift left by 0 to 31 places. The vacated bits at the least
MSB
LSB
4
31 27
g
in
e er
ASL #4
in
.Fig 5.5
ng
ASR is an arithmetic shift right by 31 to 0
places. The vacated bits at the
most significant end of the word are fE
filled with zeros if the original value
(the source operand) was positive.
O
The vacated bits are filled with ones
if the original value was negative.
g e
MSB
le
31 27 LSB
4
ol
C
u
ad
iln
31 27 LSB
dloo|d1lanodo:lo|1]olo|11]|poou1o|o|o1]
Ta
Fig 5.6
<br>
g
Destination
in
er
Fig 5.7 ROR
e
in
MSB LSB
ng
Destination CF
bitvalue. They update the CPSR flag bits according to the result, but do not
C
After the bits have been set, the information can then be used to change
ad
g
operand into Rd(destination register), where N is the register or immediate
in
value. This instruction is useful for seting an initial values and transferring
er
the data between registers.
e
MOV Move Move a 32 - bit value into a register.
in
MVNMove negated Move the NOT of the 32 - bit value into register.
ng
Table 5.6 Move instructions
fE
The MVN instruction takes the value.of second operand and performs a
O
bitwise logical NOT operation on that value, and places the result into Rd.
e
Example:
g
MOV r0, rl
le
of
C
LDR Load
ad
STR Store
iln
g
LDR Ra, [Rb]
in
Value at [address] found in Rb is loaded into
register Ra.
er
STR Ra, [Rb]
e
in
Value found in register Ra is stored to [address] found in Rb.
ng
(a) Base-Plus -Offset Addressing
fE
This is related to indirect addressing. Here, the register value is added to
another value to form the address.
O
LDR. r0, [r1, # 16]
e
Loads ro with the value stored at the location rl+16. Here, rl is referred to as
g
le
When the offset is an inmediate, it may have any value upto 4,096 and an
C
another register may also be used as affset. This addressing mode has two
u
other variations:
ad
(ii) Post-addressing.
m
Post-indexing does not perform the offset calculation until after the fetch
has been performed.
<br>
r1
g
rt=t+ 16
in
r0
e er
in
Fig 5.9 Auto-indexing
ng
LDR r0, [r1, #16] !
#16 fE
O
ro
g e
le
r1=r1+ 16
ol
C
Fig 5.10Post-indexing
First load r0 with the value stored at the memory location whose address is
u
ad
given by rl, and then add 16 to rl and set rl to the new value.
iln
B# 100
It will add 400 to the current PC value.
<br>
g
in
er
0000 = EQ 0111 = VC
e
0001 = NE 1000 = HI
in
0010 = CS 1001 = LS
ng
0011 = CC 1010 = GE
0100= MI 1011 = LT
0101 = PL 1100 = GT
fE
0110 = VS 1101 = LE
O
EQ Equals zero Z=1
e
NE
288|85|5|9
Not equal to zero
g
Z=0
le
MI Minus N=1
u
VS Overflow V=1
iln
VC Nooverflow V=0
m
g
(1) C Functions:
in
B(<cond>} label
er
Branch:
Branch with Link: BL{<Cond?} sub_routine_label
e
in
31 28 27 25 24 23
ng
Offset
Cond 101
Link bit 0 fE
Branch
1=Branch with link
O
Condition field
BL foo
ol
that
This instruction and link to the code starting at location 'foo'
willperform
C
bank.
iln
;call subroutine.
BL sub
m
To return from subroutine, simply need to restore the PC from the LR.
Ta
;
MOV PC, LR return
a
The standard procedure for allowing nested procedure calls, to build stack,
as illustrated in Fig 5.13.This C code shows a series of functions that cau
other functions: f1() calls f2(), which in turn calls f3( ).
At the right side, we can see the state of the procedure call stack uring i
active
execution of f3( ).The stack contains one activation record for each
procedure.
<br>
void f1(int a) {
f2(a);
g
in
f3
void f2(int r)
er
{
f3(r,5);
e
f2 Growth
in
void f3(int x, int y) {
ng
9= x+ y; f1
main () {
fE
Function call stack
f1 (xyz);
O
e
C
code
g
s Procedure Linkage:
C
Most procedures need to pass parameters into the procedure and return values
u
out of the procedure as well as remember their return address. We can also
ad
make use of the procedure call stack to pass the parameters. The conventions
used to pass values into and out ofprocedures are known as procedure linkage.
iln
The stack elements are frames. A Stack Pointer (SP) defines the end of the
current frame, while a Frame Pointer (FP) defines the end of the last frame.
When a new procedure is called, the SP and FP are modified to push another
frame onto the stack.
(2) ARM Procedure Call Standard (APCS)
The APCS is a good illustration of a ypical procedure linkage mechanism:
<br>
g
rll :Frame pointer.
in
:
r13 Stack pointer.
er
to check for
r10 : Holds the limiting address on stack size, which is used
e
stack overflows.
in
uses in the protocol.
Other registers have additional
ng
5.1.4 Advanced ARM Features
features for a variety of
Several models of ARM processors provides advancedfE
applications:
O
(i) Digital Signal Processing (DSP)
of ARM that provides improved DSP. Multiply Accumulate
e
Several extensions
g
(ii)
is
Multimedia operations are supported by SIMD operations. A single register
C
treated as several smaller data elements, such as bytes. The same operation
is
u
NEON is the ARMv8 version of SIMD. The NEON unit has 32 registers and
each 64 bits wide. Some operations also allow a pair of registers that is to be
m
Data in a single register are treated as a vector of elements and each smaler
than the original registe, with the same operation being performed in parallel
on each vector element.
Trust Zone extensions provide security features. A separate monitor mode alloW
the processor to enter a secure world to perform operations which is not permitted
in the normal mode.
A
<br>
(vi) Cortex
g
Cortex-A5 provides Jazelle execution of Java, floating-point processing,
in
and NEON multimedia instructions.
er
Cortex-A8 is a dual-issue in-order superscalar processor.
e
Cortex-A9 can be used in a multiprocessor with four processing elements.
in
Cortex-A15 is a Multicore Processor Core(MP) with up to four CPUs.
ng
Cortex-R family is designed for real-time embedded computing.
fE
Cortex-M family is designed for microcontroller-based systems that
requires low cost and low-energy operation.
O
5.2 PRELIMINARIES
g e
Address
ad
CPU
Data
iln
Memory
m
store
values used internally.
The CPUhas several internal registers that
in memory of an
Program Counter (PC) is a register which holds the address
memory, decodes the
instruction. The CPU fetches the instruction from
instruction, and executes it.
g
only we can change what the CPU does.
If you change the instructions, then
in
er
(2) Harvard Architectures:
Address
e
in
Data memory
CPU
Data
ng
Address
fE PC
Program memory
Instructions
O
Fig 5.15A Hardvard architecture
Harvard architecture is shown in Fig 5.15 which has separate memories for
g e
memory.
data and program. The PC points the program memory, not data
le
performance for digital signal processing. Data sets that arrive contimuously
and periodically are called streaning ata. Two memories with separate
u
complex tasks and they also generally used a number of different instruction
Ta
g
o The characteristics of instructions are as follows:
in
Fixed versus variable length,
er
Addressing modes,
e
- Numbers
in
of operands, and
ng
-Types
of operations supported.
(5) Worá Length fE
We can characterize architectures by their word length: 4-bit, 8-bit, 16-bit,
O
32-bit, and so on. In some cases, the length ofa data word, an instruction, and
e
instructions and addresses may be longer than the basic data word.
ol
C
MSB LSB
ad
Byte 3 Byte 0
Ta
Byte 2 Byte 1
Byte 1 Byte 2
5.20
Embedded Systems and IOT Design
g
in
o A
single-issue processor executes one instruction at a time. Although it may
er
have several instructions at different stages of execution, only one instruction
e
can be at any particular stage of execution. In multiple-issue processor,
in
multiple instructions are executed at a time.
ng
A superscalar processor can execute more than one instruction during a
fE
clock cycle by simultaneously dispatching multiple instructions to different
execution units on the processor. Therefore, it allows more throughputs.
O
Limitations:
e
a VLIW:
ad
of
instructions can be legally executed together. VLIW processors are often used
Ta
g
in
A microcontroller is one form of a single-chip computer that includes a
processor, memory,and I/0 devices. The term microcontroller is usually used
er
to refer to a computer system chip with a relatively small CPU that includes
e
some read-only memory for program storage.
in
A System-on-Chip (So) generally refers to a larger processor that includes
ng
on-chip RAM that is usually supplemented by an off-chip memory.
ADR r4, d
iln
;
SUB r0, r0, rl another comment
Ta
4 Fig 5.16 shows a part of ARM assembly code which reflects the basic features
of assembly languages:
One instruction appears per line.
- Labels: Give names to memory locations and start in the first column.
- Instructions must start in the second column.
Comments run from some designated comment character to the end the line.
of
<br>
g
31 28 27 26 25 24 21 20 19
in
Format determined
Cond 00 OPCode Rn Rd by Ibit (Operand 2)
e er
in
Immediate
Condition operand -Destination register
ng
field
Operation
code
fE First Operand register.
(Source Register Operand)
O
Set condition codes
0= Do not alter condition codes
e
11-8 7-0
C
(a) Immediate
I=0 format:
iln
# shift Sh
Ta
Rm
(b) Register
11 -8 7 4
6-5 3 -0
Rs 0 Sh Rm
g
one operand using barrel shifter.
in
er
Examples:
e
Operand Addressing
in
Mode Example Description
ng
-
Register only ADD R3, R2, R1 R3 4- R2 + R1
methods:
ol
But cach of these methods add to the complexity of the hardware very much.
m
Very Long Instructions Word (LIW) processors has programs to control the
parallel execution of the instructions. These processors rely on the compiler to
identify the sets of instructions that can be executed in parallel.
The programs decide the parallel flow of the instructions and to resolve conflicts.
This increases the compiler complexity but decreases the hardware complexity
by a lot.
<br>
The main goal of VLIWis to remove the complicated instruction scheduling and
parallel dispatch that appears in most modern microprocessors. A VLIW
processor needs to be quicker and less costly than a comparable RISC chip.
* Fig 5.18 shows the VLIW architecture, the multiple functional units share a
common multi-ported register file for fetching the operands and storing the
g
results.
in
Parallel random access by the functional units to the register file is facilitated by
er
the read/vwrite crossbar. Execution of the operations in the functional units is
e
carried out concurrently with the load/ store operation of data between a RAM
in
and the register file
ng
Multiported Register Fil
fE
O
e
Program
Read /Write Corss Bar
g
le
Control
ol
C
Instruction Cache
m
(1) Packets
set of instructions is bundled together into a VLIW packet, which a set oj
A
is
instructions that may be executed together.
The execution of the next packet will not start until all the instructions the
in
current packet have finished exxecuting. The compiler
identifies packets by
analyzing the program to determine the sets of instructions that can alwayS
execute together.
<br>
i2)
Inter-instruction Dependencies
oA data dependency is a relationship between the data operated on by
instructions. For example in Fig 5.19, the first instruction writes into ro while
the second instruction (r2) reads from it.
ro
g
r1
in
er
add ro, r1, r2 r3
e
add r3, r0, r4
in
r2
Instructions
ng
fE r4
O
Data dependencies
As a result, the first instruction must finish before the second instruction can
g
le
performs its addition. This data dependency graph shows the order in which
ol
r1 r1 r4 2 r5
u
r3 r4
Instructions 2
m
g
Improves performance by Dependency checking
in
executing multiple between instructions is
instructions per
er
clock cycle. required.
Superscalar
Reduces hardware -
Out of- order execution
e
complexity. leads to more complexity.
in
Enhances instruction
ng
throughput.
1. Define ARMprocessor.
ad
g
ARM load-store architecture
is a
in which the data operands must
in
first be loaded
intothe CPU and then stored back to main memory save
to the results.
er
Define CPSR.
e
The basic
in
register in the programming model is the Current
Program Status
ng
Register (CPSR) Which is used by the ARM core to
monitor and control the
internal functions, This register is setup automatically
during every arithmetic,
fE
logical, or shifting operation.
O
6 List the aritlhmetic instructions in ARMprocessor.
e
ADD Add
g
SUB Subtract
ol
SBC
1. Define ROR.
are rotated off to the right end are
m
is also
vacated bit positions on the left and the last bit rotated
Ta
Destination
8, What
is RRX?
it rotates right by 1 bit and is
it
In Rotate
right extended with C(RRX) instruction,
extended goes to the MSB of the register.
to
carry, the carry output
then
<br>
MSB LSB
Destination CF
g
The compare instructions are used to compare or test a register with a 32-bit
in
value. They update the CPSR flag bits according to the result, but do not affect
er
other registers.
e
in
After the bits have becn set, the information can then be used to change program
ng
flow by using conditional execution.
10. List the compare instructions. fE
CMP Compare Flags set as a result of Rn -N
O
CMN Negated compare Flags set as a result of Rn + N
e
TST
le
The B (bränch) instruction is the basic mechanism in ARM for changing the flow
u
of control. The address that is the destination of the branch is often called the
ad
branch target.
iln
The branch specifies the offset from the current PC value to the branch target.
m
The offset is in words, but the ARM is byte addressable. So the offset 1s
Ta
B# 100
It willadd 400to the current PC value.
12. Write the function of branch link instruction.
The Branch Link (BL) instruction implements a subroutine
call by writns
(PC+4) into the Link Register (LR) of the current bank.
BL sub ;call subroutine.
To return from subroutine, simply need to restore the PC from the LR.
<br>
g
and out of procedures are known as procedure linkage.
in
14. What is frame?
er
The compiler passes parameters and return variables
in a block of memory
e
known as a frame which is also used to allocate local variables.
in
15. Diferentiate SP and FP.
ng
The stack elements are frames. A Stack Pointer (SP) defines
the end of the
current frame, while a Frame Pointer (FP) defines the end
fE of the last frame.
When new procedure is called, the SP and FP are modified to push another
O
frame onto the stáck.
16. List the features of ARM processors.
g e
applications:
ol
(v) Jazelle
m
(vi) Cortex
Ta
g
that they
This means they have a smaller number of instructions
in
instruction set.
very fast and
these instructions is designed to be
er
can execute, but each of
e
efficient.
more complex instruction set.
in
CISCprocessors are characterized by a larger and
faster
uses many memory references process complex instructions. RISC has
ng
It
processing, while CISC has slower processing.
20. Differentiate between big endian and little endian.
fE
A big-endian system stores the Most Significant Byte (MSB) of a word at the
O
smallest memory address and the Least Significant Byte(LSB) at the largest. A
e
Bit 0
le
Bit 31
Word 4
ol
Byte 3 Byte 2
LSB
u
MSB
(a) Little- endian
ad
Bit 31 Bit 0
iln
Word 4
m
Byte 0 Byte 1
i Byte 2 Byte 3 Word 0
Ta
LSB MSB
(b) Big - endian
g
in
superscalar processor can execute more than one
A
er
cycle by simultaneously dispatching multiple
instructions to different execution
units on the processor. Therefore,
e
it allows more throughputs.
in
24. Write the limitations of
'superscalarprocessor.
ng
The limitations of the superscalar process are
(i) It uses too much energy, fE
(ii) Difficulty of scheduling instruction becomes complex,
O
(i) It is too expensive for widespread use in embedded systems.
e
The set of registers available for use by the programs is called the programming
m
g
in
- Instructions must start in the second column.
comment character to the end of the line.
er
Comments run from some designated
format of ARM dataprocessing instruction.
e
0. Draw the
in
21 20 19 16.15. 12 11
31 28 27 26 25 24
ng
Format determined
Cond 00 OPCode S Rn Rd by Ibit (Operand 2)
fE
Immediate
O
Condition operand Destination register
field
g e
a
A set of instructions is bundled together into a VLIW packet, which is set of
iln
g
Reduces hardware -
Out of- order execution
in
complexity.
leads to more complexity.
er
Enhances instruction
throughput.
e
in
34. Write tlhe advantages of VLIWprocessor.
The advantages
ng
of VLIW processor are,
) Reduces hardware complexity.
fE
(ii) Reduces power consumption.
O
(iii) Simplifies decoding and instruction issues.
(iv) Increases potential clock rate.
g e
le
4. Write note on
iln
() Auto-indexing addressing.
m
UNIT-II
Chapter 6
g
in
CPUs
eer
6.1 PROGRAMMING INPUT AND OUTPUT
in
ng
6.1.1 Input and Output Devices
fE
O
Status
register
e
CPU Device
g
mechanism
le
Data
ol
register
C
u
Some registers may be read-only, such as a status register that indicates when
the device is done, while others may be readable or writable.
g
in
(I/O)devices:
er
)Memory-mapped I/0, and
e
(ii) I/Omapped I/O.
in
a Memory-Mapped i/0:
ng
In memory-mapped I/O, inputloutput devices are mapped to the memory
fE
address space of the microprocessor. This means that the I/O devices are
treated like memory locations and can be accessed using the same read and
O
write instructions as memory.
e
In other words, the same bus and control signals used for memory access are
g
a /O Mapped i/0:
C
address space which is different from the memory address space. The
ad
signals.
m
Ta
PUs 6.3
.1.4 Interrupts
The interrupt mechanism allows devices to signal the CPU and to force execution
of a particular piece of code.
When an interrupt occurs, the Program Counter's value is changed to point to an
g
interrupt handler routine which is also commonly known as a device driver that
in
takes care of the device: writing the next data, reading the data that have just
er
become ready, and so on.
e
in
ng
Interrupt request Status
register
fE
CPU Interrupt acknowledge Device
PC
O
mechanism
register
g
le
Device :,
ol
C
Fig 6.2 shows the interface between the CPU and VO device includes several
ad
VO device asserts the interrapt reguest signal when it wants service from
the CPU, and
m
CPU asserts the interrupt acknowledge signal when it is ready tohandle the
Ta
VO evice's request.
* The I/O device's logic decides when to interrupt. The program that runs when
no interrupt is being handled is often called the foreground program.
* The CPU implements interrupt by checking the interrupt request line at the
beginning of execution of every instruction. If an interrupt request has been
asserted, the CPU does not fetch the instruction pointed to by the PC.
<br>
g
is typically a
in
The subroutine call mechanism in modern microprocessors
return address on a stack.
er
stack, so the interrupt mechanism puts the
e
(1)Priorities and Vectors
in
some
o Most of the systems have more than one I/Odevice, so that there must be
ng
mechanism for allowing multiple devices to interrupt.
o There are two ways to handle multiple devices which provides more flexible for
fE
the associated hardware and software:
O
(i) Interrupt priorities allows the CPU to recognize some interrupts as more
important than others, and
g e
(ii) Interrupt vectors allow the interrupting device to specify its handler.
le
...
Ta
L1 L2 Ln
CPU
CPUs
6.5
o If devices. 1,2, and n all requested the interrupts simultaneously. The first
request would be acknowledged because it is
connected to the highest-priority
interrupt line.
A Masking:
g
The priority mechanism must ensure that a lower-priority
interrupt does not
in
occur when a higher-priority interrupt is
being handled, then the decision process
er
is known as masking.
e
When an interrupt is acknowledged, then the CPU stores the priority level of
in
that interrupt in an internal register. Ifa subsequent interrupt is received, then
ng
its priority is checked against the priority register.
fE
If the new request has higher priority than the currently pending interrupt then
only it is acknowledged. When the interrupt handler exits, then the priority
O
register must be reset.
g e
(NMI). It is usually reserved for interrupts caused by the power failures which
C
Interrupt vectors provides the ability to define the interrupt handler that
more flexibility.
should service a reguest from a device, which is
Fig 6.4 shows the hardware structure required to suport interrupt vectors. In
addition to the interrupt request and acknowledge lines, an interrupt vector
lines run from the devices to the CPU. After a device's request is
acknowledged, it sends its interrupt vector over those lines to the CPU.
<br>
a memory
The CPUthen uses the vector number as an index in table stored in
as shown in Fig 6.4. The location referenced in the interrupt vector table by
Vector
g
Device Interrupt vector
Vector 0
in
1
table head Handler
Handler 3 Vector 1
er
Interrupt
request Interrupt
ackno wledge Handler 4 Vector 2
e
Vector 3
in
Handler 2
CPU.
ng
Interrupt vector table
Hardware structure fE
Fig 6.4 Interrupt vectors
O
(3) Interrupt Overhead
g e
Once a device requests an interrupt, the following steps are performed by the
le
(i) CPU:
C
The CPU checks the pending interrupts at the beginning of an instruction to find
u
(i) Device:
iln
(iüi) CPU
The CPU looks up the device handler address in the interrupt vector
table
using this vector as an index.
A subroutine-like mechanism is used to save the current value
of the PC and
possibly other internal CPUstate, such as general purpose registers.
<br>
CPUs
6.7
(iv) Software:
The device driver may save additional CPUstate, then it performs the required
onerations on the device which restores any saved state and executes the interrupt
return instruction.
(v) CPU:
g
The interrupt return instruction restores the PC and other automatically saved
in
states in order to return the execution to the code that was interrupted.
er
(4) Interrupts in ARM:
e
in
The ARM processor has two levels of external interrupt:
ng
() Fast Interrupt Requests (F1Qs), and
(i) Interrupt Requests (IRQs). fE
Fast Interrupt Requests (FIas):
O
FIQ is aspecialized type of interupt request, which is a standard technique
e
as
-usedin computer CPUs to deal with events that need to be processed they
g
actions.
ol
operation.
Ta
to an interrupt:
The ARM7 performs the following steps when responding
return.
() Saves appropriate value of the PC to be 'used to
the
(SPSR),
- (ii) Copies the CPSR into an Saved Program Status Register
(iii) Forces bits in the CPSR to note the interrupt, and
vector.
(iv) Forces the PCto the appropriate interrupt
<br>
g
moment.
in
er
Mode Privileged Purpose
e
User No
|Normal operating mode for most programs
in
(tasks).
ng
|Fast Interrupt
Yes Used to handle a high-priority (fast) interrupt.
Request (FIQ) fE
|Interrupt Request Used to handle a low-priority (normal)
O
Yes
(IRQ) interrupt.
e
a
m
Definition:
Ta
CPUs
6.9
The operating system
of a computer usually operates in this mode.
mode helps in preventíng Supervisor
applications from corupting
the data of the operating
system.
Features:
Some of the important features
g
of supervisor mode are as follows:
in
() It handles different types of commands but mostly deals with privileged
er
instructions.
e
(i) The operating system selects supervisor mode
in
for the low level tasks that
require complete access to the system hardware.
ng
(ii) It cancreate the memory address spaces as well as updating them.
fE
(iv) Various interrupts can be enabled or disabled using the supervisor mode.
O
It also contributes to the loading of the processor status.
supervisor mode can access the various data structures available inside
e
(v) The
g
SWI CODE_1
C
* In supervisor mode, the bottom five bits of the CPSR are all set to 1 to indicate
u
that the CPU is in supervisor mode. The old vaue of the CPSR just before the
ad
SWI is stored in a register is called the Saved Program Status Register (SPSR).
iln
supervisor mode, it restores the PC from register rl4 and the CPSR from
Ta
SPSR SVC.
6.3 EXCEPTIONS
6.3.1 Introduction
A Definition:
exception is an internally detectèd error. This mechanism provides a
way for
An
Processor exceptions occur when this normal flow of execution gets diverted, to
allow the processor to handle the events generated by an internal or external
SOurces.
Examples of Events:
Resetting ARM core.
g
in
Failure of fetching instructions.
er
- legal memory accesses.
Externally generated interrupts.
e
an undefined instruction.
An attempt by the processor to execute
in
ng
6.3.2 Exceptions and Modes
Each exception causes the ARM core fE
toenter a specific mode:
O
Exception Mode Purpose
e
SW emulation of HW
iln
Table 6.2
Ta
CPUS
6.11
6.4 TRAPS
Definition:
g
the mode.
in
The entry into supervisor mode must be controlled to maintain security.
If an
er
interface between user and supervisor mode is improperly designed, a user
e
program may be able to sneak code into the supervisor mode
in
that could be
executed to perform the harmful operations.
ng
The ARM provides the SWI interrupt for software interrupts. This instruction
fE
causes the.CPU to enter supervisor mode. An opcode is embedded in the
instruction that can be read by the handler.
O
e
6.5.1 Introduction
ol
C
Local
iln
g
which transforms the input data to
output data.
in
operation on the data (process) is
DFG is a visual model in which the
er
arrows. An
using a block (circle) and data flow is represented using
represented
e
process (circle) represents input data and an outward arroy
arrow
in
inward to the
output data in DFG notation.
from the process (circle) represents
ng
input, to an output.
In a DFG model, a data path is the data flow path from
Embedded applications which are compütationally
fE intensive and data driven are
X=a+b;
C
y= X -C;
u
a b
ad
iln
X
Ta
CPUS
6.13|
6.5.3 Control /Data Flow Graphs (CDFG)
Definition:
The fundamental model
for programs is the ControVData Flow Graplh
(CDFG). II constructs the model
for both data operations (arithmetic and
g
other computations) and control
in
operations (conditionals).
A CDFG uses a datá flow graph as an
er
element and adding constructs to
describe the control. The basic
e
CDFG, have two types nodes:
of
in
(i) Decision nodes, and
ng
(ii) Data flow nodes.
# A
data flow node encapsulates a complete data fE
flow graph to represent a basic
block anda decision node is used to
describe all types of control in a sequential
O
program.
e
Fig 6.7 illustrates a bit of code with control constructs and the CDFG
g
le
if (condl)
u
else
basic block 2 ()
iln
{
switch (testl)
case cl: basic block 4 (); break;
Ta
Design
Embedded Systems and 10T
6.14|
C code
T
basic_block_1()
cond1
F
g
in
er
basic_block_3()
e
in
test1
ng
C1 c3
c2
CDFG
g
le
o
Looping statements in execute the sequence of statements
C many times until
C
o The purpose of the C loop is to repeat the same code for a number of times.
m
The control conditions must be well defined and specified otherwise the loop
Ta
CPUs
|6.15
Building a CDFG for a while loop is straightforward
with an example is given
in Fig 6.10.
while(a < b) {
a = proc1(a,b);
b= proc2(a,b);
g
in
C code
er
a <b
e
in
T
ng
a=
proc1(a,b);
b= proc2(a,b); fE
O
CDFG
6.6.1 Introduction
C
Written in C ..011010110...
Language
Ta
Page 23 of 440
1l
Compiling Assembling
Preprocessing
g
in
Executable file Object Code
er
Linking
e
in
Fig 6.12 Steps involved in compilation process
ng
(1) Program Generation Work Flow:
High-level
Compiler
fE
Assembly Object
language Assembler code
code
O
code
g e
le
Linker
ol
Execution
C
Loader Executable
binary
u
ad
language.
The assembler's job is to translate symbolic assembly language statements
into a bit-level representations of instructions known as object code.
The final steps in determining the addresses of instructions and data are
performed by the linker, which produces an executable binary file. The
program that brings the program into memory for execution is called a
loader.
<br>
CPUs 6.17
(1) Absolute And Relative Addresses
o
There are two types of addressing:
(i) Absolute addresses, and
(ii) Relative addresses.
g
& Absolute Addresses:
in
er
The simplest form of the assembler assumes that the starting address of the
assembly language program has been specified by the programmer. The
e
in
addresses in such a program are known as absolute addresses.
ng
In absolute addressing. you can specify the actual address of a memory
location which is called as absolute address. It is constant and is not
fE
modified in any way by the microprocessor.
O
a Relative Addresses:
e
from another address which is called as the base address that is start of the
le
file.
ol
The absolute address specifies the plysical storage location of the record.
C
The relative address specifies the number of bytes from the start of the file.
u
For example, in Fig 6.14, a relative address might be B+4, B being the base
ad
addresses.
then responsible for translating the relative addresses into the
m
Ta
1 3 5
Absolute
Base
Address
Address
(B) (3)
Relative Address
B+4
addressing
Fig 6.14 Absolute and relative
<br>
6.6.2 Assemblers
When translating an assembly code into object code, the assembler must
translate opcodes and format the bits in each instruction, and then translate the
labels into addresses.
g
in
* Labels make the assembly process more complex, but they are the most
er
inportant abstraction provided by the assembler. Label processing requires two
e
passes through the assembly source code:
in
() The first pass scans the code to determine the address of
each label.
ng
(i) The second pass assembles the instructions using
the label values computed
in the first pass. fE
(1) Symbol Table
O
add ro,r1,r2
e
yy sub r5,r6,7
Ox10
ol
Assembly code
Symbol table
C
location in memory is
Location Counter (PLC). At kept in a Program
Ta
CPUS
6.19|
ORG 100 label1 100
PLC = 100 label1 ADR r4,c 100
LDR rO.(r4]
g
in
Fig 6.16
During the second pass, when a label name is found, the label is looked up in
er
the symbol table arnd its value substitutcd into the appropriate place in the
e
in
instruction.
ng
(2) Object Code Formats
The assembler produces an object file that deseribes the instructions, data and
fE
any addressing information in the binary format. A commonly used object file
O
format, originally developed for Unix is Common Object File Format (COFF).
e
6.6.3 Linking
g
le
2 Linker:
linker is a sofhware tool that plays a crucial role in the compilation process of
ol
an executable file.
with other necessary libraries and molules to create
u
your
The linker takes care of resolving references between different parts of
ad
or
program. When you write code, you often divide it into multiple source files
iln
smoothly.
assembler and modifies the
The linker operates on the object files created by the
necessary links between the files.
assembled code to make the
same file. Other labels will be
Some labels will be both defined and used in the
as illustrated in Fig 6.I7.
defined in a single file but used clsewhere
<br>
ADRa
B labct3
B label2 X
y s 1
g
var1 % 1 3 10
in
er
Extornal Entry
e
Extemal Entry roferuncos points
in
references points
var1 label2
ng
label1
label2 labol3
var1
fE
O
Filo 1
Filo 2
e
symbol identifiers.
iln
CPUS 6.21
assembler extra bits into the object file to
write
identify the instructions and
felds that refer to labels.
Dynamically Linked Libraries
(2)
Static linkers merge all the necessary object code and libraries into a single
executable file, resulting in a self-contained program.
g
in
o
Dynamic linkers allow the program to be loaded into memory at runtime and
er
link to shared libraries which enabling more flexibility and an efficient
e
memory usage.
in
ng
A Dynamic Link Library (DLL):
A
Dynamic Link Library (DLI) is defined as a file type containing code,
fE
data, and resources that can be shared among multiple programs to
O
accomplish the specific tasks.
e
are placed in
o The linker allows us to control where object code modules
ad
(i) Interrupt vectors and other information for I/O devices must be placed in
m
a specific locations.
Ta
(3) Relocatability:
A program is relocatable if it can be executed when loaded into diferent parts of
g
memory. It requires some sort of support from hardware that provides address
in
calculation.
er
6.7 COMPILATION TECHNIQUES
e
in
6.7.1 The Compilation Process
ng
a Definition:
The compilation is a process
fE
of converting the source code into object code. It is
done with the help of the compiler and an assembler. The compiler checks the
O
source code for the syntactical or structural errors, and if the source code is
error-free, then it generates. an assembly code. This assembly code is then
g e
The compilation process is outlind in Fig 6.18. Compilation begins with high
C
level language code such as Cor C++ and generally produces assembly code.
u
High-level
ad
language code
iln
Machine-independent optimizations
Instruction-level optimizations
and code generation
Assembly code
CPU: 6.23|
Some compilers may then perform higher-level optimizations that can be viewed
as modifying the high-level language program input without reference to an
g
instructions.
in
er
6.7.2 Basic Compilation Methods
e
in
(1)Procedures
ng
Procedures are known as
functions in C that requires a specialized code. We
generate the code to handle the procedure call and returm. At each call of the
fE
procedure, we set up the procedure parameters and then makes the call.
O
as a frame. The frames
The information for a call to a procedure is known
are stored on a stack to keep track of the order in which the procedures have
g e
been called.
le
o
processors. are used to pass the first four parameters
linkage for ARM r0- r3
Ta
g
in
a[0]
er
a[1]
e
in
of a one-dimensional array in memory
ng
Fig 6.19 Layout
For our convenience, we can use the pointer aptr for the reading of a[i] as,
fE
*(aptr + i)
O
If the a[ } array
with the size of Mx
N,
then the two-dimensional array
e
a
le
i, j]
as
ol
a contiguous block of
structure can be accessed using
memory. Fields in this
u
*(aptr + 4)
m
Ta
a[0,0]
a0,1]
a[1,0]
a[1,1]
arrays
tn Mausnm Inut for two-dinnensional
<br>
CPUs
|6.25|
6.7.3 Compiler Optimizations
The basic compilation techniques can generate
inefficient code. Then compilers
a
1se wide range of algorithms to
optimize the code vwhich it generates.
g
Loop optimization is the process of increasing an
execution speed and
in
reducing the overlheads associated with loops. It plays an
important role in
er
improving cache performance and making effective use
of parallel
e
processing capabilities.
in
Most execution time of a scientific program
is spent on loops.
ng
(0 Loop Unrolling:
fE
Loop unrolling is a loop transformation technique that helps to optimize the
execution time of a program. It increases the program 's speed by eliminating
O
loop control instruction and loop test instructions.
g e
Loop fusion is combining tvo or more loops in a single loop which reduces the
ol
loop overhead and also reduces the time taken to compile the many loops i.e.,
C
Before optimization:
ad
a = i + 5;
b= i + 10;
Ta
After optimization:
for (int i=0; i<5; i++)
a = + 5:
i
b= i + 10;
g
efficient in multi-core
This optimization is most
in
processor.
task into multiple tasks for cach
er
(d) Loop Tiling
e
inner loop
up a loop intoa set of nested loops and each
in
Loop tiling breaks
the data.
performing the operations a subset of
on
ng
up into tiles of
Here, each loop is broken
An cxample is shown in Fig 6.22.
two loops. For example, the inner 'i"
fE
size two that is, each loop is split into
loop iterates within the tile and the
outer i' loop iterates across the tiles.
O
c0.1]|(0.2} (0,N-1]
e
[1,0) (1,2]
Access
pattern
(2,N - 1]
ol
Before After
A Dead Code:
Dead code is the code that can be never executed. It can be generated by he
programmers, either inadvertently or purposefully and also by the compilers.
Dead code can be identified by reachability analysis that is, finding the
other statements or instructions from which it can be reached. Dead code
elimination analyzes the code for reachability and removes it.
<br>
PUs 6.27|
|Register Allocation
Register allocation is an important method in the final phase of the compiler.
Registers are faster to access than cache memory and registers are available in
small size up tofew hundred kB .Thus, it is necessary to use a minimum number
ofregisters for variable allocation.
g
in
Scheduling:
er
Instruction Scheduling:
e
Insiruction scheduling is a process of mapping a series of instructions into
in
execution ofresources. It decides when and where an instruction is executed.
ng
We can keep track of CPU resources during instruction scheduling by using
fE
a reservation table which illustrated in Fig 6.23. Rows in the table represent
instruction execution time slots and columns represent resources that must
O
be scheduled.
e
t X
le
t+ X X
ol
X
C
t+2
t+3 X
u
ad
After scheduling the instruction, we update the table to note all resources
used by that instruction. Various algorithms can be used for the scheduling
depends on the types of resources and instructions involved,
Software Pipelining:
A soflware pipelining is a compile-time scheduling technique for reordering
instructions across several loop iterations that is, overlaps subsequent loop
iterations to reduce the pipeline operations.
<br>
g
technique for generating the
in
that can be used in adjacent code. One useful
in Fig 6.24.
code is template matching which is illustrated
e er
Multiply
in
cost = 1
ng
fE Add
cost = 1
O
Code
g e
le
Multiply-add
cost = 1
ol
C
Instruction templates
u
ad
The DAG is used to represent the structure basic blocks, to visualize the
of
m
flow of
values between basic blocks, and to provide an optimization techniques
Ta
CPUS 6.29
In this case, we have shown that each instruction takes the same amount of
time, and thus all have a cost of 1.
g
6.8.1 Introduction
in
* Embedded systems helps to perform functions in real time, we often need to
er
know how fast a program runs. The techniques we use to analyze program
e
execution time are also helpful in analyzing properties such as power
in
consumption.
ng
PipelineA
fE
O
eg
le
ol
Cache
Total execution time
C
Consider the Fig 6.25, the CPU pipeline and cache act as windows into
our
*
program. To understand the total execution time of our program, we must look at
iln
an execution paths, which in general are far longer than the pipeline and cache
m
windows.
Ta
a
The pipeline and cache influence execution time, but execution time is global
property of the program. It is _very difficult to calculae the execution time of
programs because of the following reasons:
(1) The execution time of a program often varies with the input data values
program.
because those values select different execution paths in the
g
ways:
in
We can measure program performance in several
er
which
() Some microprocessor manufacturers supply simulators for their CPUs
can runs on a workstation or PC that takes as input datas, and simulates the
e
in
execution of that program. Some of these functional simulations also
ng
measure the execution time of the program.
(ii) A timer connected to the microprocessor bus can be used to measure the
fE
performance of executing sections of acode.
O
(ii) A logic analyzer that can be connected to the microprocessor bus is used to
measure the start and stop times of a code segment.
g e
clearly define
the typical inputs.
u
CPUs
6.31
nath, which takes into account
the data dependencies, pipeline behavior,
and
caching.
(1) Instruction Timing
o Once we know the
execution path of the program, we
have to measure the
execution time of the instrüctions that are
g
executed along that path.
in
o The simplest estimate is
to assume that every instruction takes the same
er
number of clock cycles, which means we need only to count
the instructions
and multiply by the execution time of one instruction to obtain the
e
program's
in
total execution time.
ng
Drawbacks:
fE
The simplest estimation method is an easiest one but this technique has
following
difficulties:
O
(i) All instructions do not take the same amount of execution times.
g e
4 Caching Effects:
C
Cache memory, which is also a type of random access memory which does not
u
ad
need to be refreshed. It is built directly ino the CPU to give the processor the
fastest possible access to memnory locatios and provides nanosecond speed
iln
Definition:
The record of the execution path of a program is known as aprogam trace (or)
a trace. It can be valuable for other purposes, such as analyzing the cache
behavior oftheprogram.
g
in
(2) Measurement lssues
o One of the challenging problems in measuring program perforrmance is to find
er
out the useful set of inputs to give the program.
e
in
First, we have to determine the actual input values. By using a simple
ng
program, we may be able to analyze the algorithm to determine the inputs that
cause the worst-case execution time.
fE
A Software Scaffolding:
O
Software scaffolding means creating a temporary structure
for your project
e
that you can use as the foundation to develop the real and more'complex
g
project. It gives you a quick and simplified (but temporary) structure for
le
your project.
ol
It also used to feed data into the program and get data out.
C
(3) Profiling
u
CPUS
6.33
Simulation Based Performance
(5) Measurement
A CPUsimulator is a program
that takes an input as memory
image for a CPU
and performs the operations on
that memory image that the actual
nerform, leaving the results CPU would
in the modified memory image.
Cycle-Accurate Simulator:
g
in
For the performance analysis of program
level, the most important type,0
er
CPU simulator is a cycle-accurate simulato,
which performs a sufficiently
e
detailed simulation
of the processor's internals that it can determine the
in
exact number of clock cycles
required for execution.
ng
This simulator is built with a detailed knowledge
fE of how the processor
works, so that it can take into account all the possible behaviors
of the
O
microarchitecture that may affect an execution time.
e
A Instruction-level Simulator:
g
le
.
ad
Data registers hold values that are treated as data by the device, such as the data
read or written by a disk.
m
g
In /O mapped VO, input/output devices are mapped to a separate I/O address
in
er
space which is different from the memory address space. The microprocessor
uses special instructions to access the I/O devices using specific IO address
e
in
signals, which are separate from the memory address signals.
ng
5. Give the comparison between memory-mapped I/O and I/O napped /O
Features Memory Mapped I/O
fE I/O Mapped I/O
I/O devices are accessed like any They cannot be accessed like
O
Addressing
other memory location. any other memory location.
g e
Address Size They are assigned with 16-bit |They are assigned with 8-bit
le
Instructions The instruction used are LDA The instruction used are IN and
C
Instruction set Uses the same instructions for Special instructions are used for
accessing both memory and I/O accessing I/O devices
iln
devices
m
CPUs 6.35
1.
foreground program.
Define
The program that runs when no interrupt is being handled is often called the
foreground program.
8.
What do you mean by nasking?
g
The priority mechanism must ensure that a lower-priority interrupt
does not
in
occur when a higher-priority interrupt is being handled, process
then the decision
er
is known as masking.
e
9. What is NMI?
in
The highest-priority interrupt is normally called as Non-Maskable Interrupt
ng
(NMI). It is usually reserved for interrupts caused by the power failures which
cannot be turned off. fE
Name the interrupts available in ARM processor.
-
10.
O
standard technique used in computer CPUs to deal with events that need
to be
ad
processed as they occur, such as receiving data from a network card, or keyboard
iln
or mouse actions.
m
g
in
(vi) Undefined mode, and
er
(vi) System mode.
e
14. What is meant by supervisor mode?
in
Supervisor mode is an automatic selected mode when a computer is powered on
ng
that is, a processor enters supervisor mode on reset.
fE
When a program is in user mode, wants to execute a privileged task,
for example
allocating more memory, it needs to make a system call. So that,
O
the operating
system performs instructions to do the privileged task, which
is achieved, by the
e
(i) It handles different types of commands but mostly deals with privileged.
u
instructions.
ad
(i) The operating system selects supervisor mode for the low level tasks that
require complete access to the system hardware.
iln
(iii) It can create the memory address spaces as well as updating them.
m
(iv) Various interrupts can be enabled or disabled using the supervisor mode. It
Ta
CPUS
6.37|
17. What is meant by trap?
an is an instruction that explicitly generates an
exception condition
lea known as a software interrupt. which is
The most common use a trap
mode. of to enter
is the
18. Write the function of DFG.
g
The Data Flow
in
Graph (DFG) model translates
the data processing requirements
into a graph. This
er
model emphasizes on the data
which transforms and operations on the data
the input data to output data.
e
in
19. What do you mean by CDFG?
ng
The fundamental model programs
for is the Control/Data Flow Graph
constructs the model (CDFG). It
and control operations (conditionals).
fE
for both data operations (arithmetic and
other computations)
O
A CDFG uses a data flow
graph as an element and adding constructs to describe
the control. The basic CDFG,
e
process?
The compilation process in C is converting an understandable
u
() Preprocessing,
Ta
(i) Compiling,
(i) Assembling, and
(iv) Linking.
22, W
Write
the function of compiler.
A
compiler
software that converts the source code (or) high-level language
is
a
into the
instruction-level program in the form of human-readable assembly
language.
<br>
g
24. What is the need of loader?
in
The program that brings the program into memory for execution is called a
er
loader.
e
25. Define absolute addressing.
in
The simplest formn of the assembler assumes that the starting address
ng
of the
assembly .language program has been specified by the programmer. The
fE
addresses in such a program are known as absolute addresses.
In absolute addressing, you can specify
O
the actual address of a memory location
which is called as absolute address.
e
CPUS
6.39
20 What the terms reentrant and recursive represent in program?
program is reentrant it can. be interrupted
A
if by another call to the function
without changing the results of either call.
g
may give a different answer.
in
31. Which one is called as reloacatable program?
er
A program is relocatable ifit can be executed when loaded into different parts
of
e
memory. It requires some sort of support from hardware that provides address
in
calculation.
ng
32. What is compilation process?
fE
The compilation is a process of converting the source code into object code. It is
done with the help of the compiler and an assembler. The compiler checks the
O
source code for the syntactical or structural errors, and if the source code is error
e
free, then it generates an assembly code. Then this assembly code is converted
g
g
Register allocation is an important method in
the final phase of the compiler.
in
Registers are faster to access than cache memory and registers are
available in
er
small size up to few hundred kB Thus, it. is necessary to use a
minimum
e
number of registers for variable allocation.
in
38. What is meant by scheduling or instruction
scheduling?
ng
Instruction scheduling is a process of mapping a series
of instructions into
execution of resources. fE
It decides when and where an instruction is executed.
39. Definê software pipelining.
O
A software pipelining is a compile-time scheduling technique
for reordering
e
subsequent loop
le
trace (or) a
trace: It can be valuable for other purposes, such as
analyzing the cache behavior
of the program.
42. What is meant by software scaffolding?.
Sofware scaffolding means creating a temporary structure for your
project that
you can use as the foundation to develop more
the real and complex project. It
gives you a quick and simplified (but temporary) structure for your project.
It is also used to feed data into the program and get data out.
<br>
CPUs
6.41|
43.
WWrite
thefunction of
cycle-accurate simulator.
Eor the performance analysis
of program level, the most important type CPU
eimulator is a cycle-accurate of
simulator, which performs a sufficiently
detailed
eimulation of the processor's internals
that it can determine the exact number
clock cycles required for execution.
of
g
in
6.10 REVIEW QUESTIONS
er
L.
Explain in detail about programming input and output.
e
Write a note on.
in
2.
ng
() Supervisor mode,
(i) Exceptions, and fE
(ii) Traps.
O
3. Discuss in detail about models of prograns.
e
4. Explain with neat sketches about assembly, linking and loading processes.
g
le
UNIT- III
g
Chapter 7
in
er
PROCESSES AND
e
in
ng
OPERATING SYSTEMS
7.1 STRUCTURE OF
A
REAL-TIME SYSTEM
fE
O
7.1.1 Introduction
e
These specific tasks are mainly related with time constraints. The tasks
assigned
C
a time interval.
to real-time systems need to be completed in given
u
a function.
combination computer hardware and software for specific
of
iln
tasks are
The embedded systems which are designed to perform real-time
or Real-time Embedded Systems.
m
g
in
Application SW
er
e
MS
in
Operating System
ng
Device Drivers
fE
O
MH
Memory
Processor WO Devices
Devices
g e
Figure 7.1 shows the different layers of an embedded system. The lower layer is
ol
I/O devices through which communication between the processor and the
iln
The upper layer is the embedded software. This layer changes according to the
Ta
Software
g
Application Software
in
er
Middleware
e
Operating System (GPOS,RTOS)
in
ng
Firmware
fE
O
Hardware
g e
Memory WO devices
Processor
u
ad
Design
Embedded Systems and 10T
7.4
Sensor
Actuator
Sensor
Actuator HComputation Processing
g
Processing
in
er
Environment
e
in
7.3 Structure of Enbedded Real-time System
ng
(0) Sensor: fE
to sense the environment periodically. It is used for conversion
Sensor is used a
or characteristics into electrical signals. This is
O
some physical events
of
environment and gives output to the
hardware device that takes input from
e
in
process is required to obtain data in compatible form for computation
system:
iln
(i) Computation
m
to be
Computation is a process of calculation and operations needed for task
Ta
completed. This is main process that happens inside real-time system. It takes
data input from sensor and gives output to actuator of real-time system.
It is just like sensor processing but does reverse work. It takes input from
system and gives this to an actuator of system. This is basically used to make
output compatible with environment so that the user can easily understand an
obtained output.
<br>
g
of the commonly actuators.
used
in
7.2 TASK ASSIGNMENT AND SCHEDULING
er
7.2.1 Introduction
e
# Real-time systems are systems that carry real-time tasks. These taskS need to be
in
performed immediately with a certain degree of urgency. In particular,
ng
these
tasks are related to control of certain events (or) reacting to them. Real-time
fE
tasks can be classified as hard real-tine tasks and soft real-time tasks.
A,
hard real-time task must be performed at a specified time which could
O
otherwise lead to huge losses. In soft real-time tasks, a specified deadline can
e
be missed. This is because the task can be rescheduled (or) can be completed
g
A Definition:
u
outcome.
Ta
|7.6|
Embedded Systems and 10T Design
(vi) It facilitates effective collaboration and coordination among
team members.
When assigning tasks, we will consider the following factors:
) Individual skills, knowledge, and expertise required for the task.
(ii) Availability and workload of team members.
g
in
(ii) Deadlines and priority of tasks.
er
(iv) Communication and collaboration requirements.
e
(v) Dependencies and relationships between tasks.
in
(vi) Consideration of individual developmént or growth opportunities.
ng
(vi) Balancing workload and avoiding overbutdening or underutilization.
fE
7.2.3 Scheduling
O
4 In real-time systems, the scheduler is considered as the most important
e
Definition:
C
The way that time is allocated between tasks is termed as "scheduling". The
scheduler is the software that determines which task should run next. The logic of
u
ad
the scheduler and the mechanism that determines when it should be run is the
scheduling algorithm.
iln
Time
g
in
Task 2 Task 2
er
Task 1
Task 1
e
in
Time
ng
Fig 7.5 Preenptive scheduling
fE
* In the case of a non-preemptive scheduling, even if the highest priority is
allocated to the task, it needs to wait until the completion of the current task.
O
This task can be either slow (or) lower priority, which can lead to a longer
e
wait.
g
non
A better approach is designed by combining both preemptive and
le
a process is present in
interrupted on a time-based interval and if higher priority
u
Algorithms:
72.4 Classifications of Task Scheduling
iln
a
priority does not change with mode. In
* In stati priority algorithms, the task
m
with time.
priority algorithms, the priority can clhange
4namic
Ta
g
(ii) Dynamic Planning-based approaches:
in
Here, the feasible schedules are identified dynamically (at run time). It carries
a
er
certain fixed time interval and a process is executed if and only if satisfies the
e
time constraint.
in
(iv) Dynamic Best Effort approaches:
ng
These types of approaches consider deadlines instead of feasible schedules.
fE
Therefore, the task is aborted if its deadline is reached. This approach is used
widely in most of the real-time systems.
O
7.2.5 Advantages
e
Scheduling ensures that real-time tasks are executed within their specified
C
on time,
timing constraints. It guarantees that critical tasks are completed
preventing potential system failures or losses.
u
ad
efficient utilization of processor time, memory, and other resources. This hlps
m
g
in
7.3 MULTIPLE TASKS AND MULTIPLE PROCESSES
er
7.3.1 Introduction
e
A Definition:
in
In embedded systems, multitasking or multiple tasking refers to the ability to
ng
effetively carry out several tasks or processes at once. It enables an embedded
fE
system to manage nmultiple tasks concrrently. as opposed to single-tasking
systems, which can only handle one activity at a time. This increases system
O
responsiveness and efficiency.
e
concurrently which helps build more complex systems using several programs
le
Tasks:
ad
(0S).
m
Ta
P1 P2
P3
Fig 7.6 shows a task that consists of three subtasks and the arrows in the task
graph show data dependencies. P3 cannot start before it receives the results of P1
and P2 where both can execute in parallel.
a Process:
A process is a single execution
g
of a program. run the same program two
If we
in
diferent times, then we have two different processes. Each process has its own
er
state that includes both its registers as well as its memory.
e
In some operating systems, the memory management unit is used to keep each
in
process in a separate address space. In other hand, particularly
lightweight
ng
RTOSs, the processes run in the same address spaçe.
fE
Uncompressed Serial line
Compr essor
Serial line Compressed
O
data data
g e
le
ol
C
u
Compressor
ad
g
in
We need to create a clean data structure
that simplifies the control structure
of
er
the code and also ensure that we process
the inputs and outputs at the proper
e
rates.
in
(2) Asynchronous Input
ng
ò Asynchronous data means it is transmitted and received at variable time
fE
intervals. A single bus architecture was used on early computers.
But Modern
systems are more complex and actually contain a hierarchy of different
O
busses.
e
o For example, the control panel of the compression box may include a
g
o Keeping up with the input and output data while checking the button can
C
One solution is to introduce a counter into the main compresion loop so that a
subroutine is used to check the input button which is called once every n times
iln
7.4.1 Introduction
A Definition:
are called the
Dystems that use different sampling rates at aifferent stages
multirate systems. These techniques are used to convert the given sampling rate
lo the desired sampling rate and to provide diferent sampling rates through the
system.
<br>
g
7.4.2 Timing Requirements on Processes
in
er
Deadline
e
in
P1:
ng
Release time Time
A periodic process
fE
Deadline
O
P1
g e
Period
Periodic process initiated at start of period
ol
C
Deadline
u
P1
ad
Release time
Time
iln
Period
Periodic process released by event
m
Ta
g
external data arriving or data computed by another process.
The initiation time is
in
generally measurd from that event, although the system may want
to make the
er
process ready at some interval after the event itself.
e
4 For a periodically executed processes, there are two common possibilities:
in
ng
In simpler systems, the process may become ready at the beginning
of the
period.
fE
The sophisticated systems may set the initiation time at the arrival time of a
O
certain data that time may be after the start of the period.
e
a Deadline
g
le
The deadline for an aperiodic process is, generally measured from the initiation
C
The deadline for a periodic process may in general occur at some time other than
ad
.
the end of the period. Some scheduling policies make the simplifying assumption
iln
The process's rate is the inverse of its period and in a multirate system, each
Process executes at its own distinct rate.
CPU1 Pl Pij+4
g
CPU4 Plj+3 P1j47
in
er
Time
e
Fig 7.9A sequence ofprocesses with a high initiation rate
in
In this case, the initiation interval is equal to one fourth of the period. It is
ng
possible for a process to have an initiation rate less than the period even in a
single-CPUsystems. fE
a
O
Jitter
Jitter ofa task means it is the allowable variation in the completion of the task.
g e
le
P1 P2
P5
ol
C
P3
u
ad
P6
P4
iln
The timing constraints between processes may be constrained when the processes
Ta
a Task Graph
A set of processeswith
data dependencies is known as a task graph.
The communication among processes of different rates
is very common. Fig 7.11
illustrates the communication required among
three elements of an MPEG
g
audiovideo decoder.
in
er
System Video Audio
e
in
ng
Fig 7.11Communication among processes at
fE
4 Data come into- the decoder in the system format, which multiplexes
diferent rates
audio and
O
video data. Then the system decoder process demultiplexes
the audio and video
data and distributes it to the appropriate processes with different rates.
g e
A The simple, direct and basic measure of the efficiency of CPUuse is utilization
ol
(U). It is defined as, "the ratio of the CPU time that is being
C
This ratio ranges between 0 to 1. One means that all ofthe available CPU time is
m
* The operating system always process to be in one of the following three basic
scheduling states:
(i) Waiting,
<br>
Executing
g
in
er
Chosen
Needs Gets data, CPU ready
to run
data
e
in
Preempted
ng
Ready Waiting
Received data
Needs data fE of aprocess
Fig 7.12 Scheduling states
O
Fig 7.12 shows the possible transitions between states available to a process. A
process goes into the waiting state when it needs data that it has not yet received
g e
or when it has finished all its work for the current period.
le
A process goes into the ready state when it receives its required data (or) when it
ol
enters a new period. A process can go into the executing state only when it has
C
all its data and it is ready to run. The scheduler selects the process as the next
process to run.
u
ad
Scheduling Policy:
while (TRUE ) {
pl ();
p2 ();
g
in
But it does not control the rate at which the processes execute. The
loop runs
er
as quickly as possible, starting a new iteration as soon as the previous iteration
has finished. But, all the processes run at the same rate.
e
in
(2) A Timed Loop
ng
A timer is a much more reliable way to control execution of the loop. So, we
can use the timer to generate periodic interrupts. Let us consider the pal( )
fE
function which is a timer's interrupt handler. Then this code will execute each
process once aftera timer interrupt:
O
void pall (){
e
pl ();
g
le
p2 ();
ol
C
a rate:
several timers, we can set each timer to different
iln
void pA (O{
/* processes that run at rate A*/
m
pl ():.
Ta
p3 ();
void pB (){
/* processes that run at rate B*/
p2 ();
p4 ();
p5 ();
<br>
g
upon timing requirements provided by the system designer.
in
to build a
The most reliable way to meet timing requirements accurately is
er
process that
preemptive operating system and to use priorities to control the
e
are used to build a basic real
needs to run at any given time. These two concepts
in
ng
time operating system.
) C
g
execution.
le
(i) Priority-based scheduling as a way for the programmer to control the order
ol
(1) Preemption
u
To get the full advantage of the timer, we must change our notion of a
ad
process:
iln
g
in
Kernel:
er
The kernel is the part of the operating system that determines what process is
e
raning, which is activated periodicallyby the timer.
in
ng
A Time Quantum:
The length of the timer period is known as the time quantum which is ihe smallest
fE
increment in that we can control CPUactivity.
O
o The kernel determines what process will run next and causes that process to
run. On the next timer interrupt, the kernel may pick the same process or
g e
o We can use the timer to control loop iterations, with one loop iteration
ol
The set ofregisters that defines a process is known as its context, and switching
iln
Jrom one process 's register set to another is known as context switching.
The
3) Process Priorities
u We assign each taska numerical priority, then the kernel can simply look at the
Processes and their priorities, and then select the highest-priority process that is
potSAVE_cONTEXTporRESTORE_CONTEXTVTaskSwitchContext task 1
task 2
timer VProemptiveTick
g
in
e er
in
ng
Fig 7.14 Sequence diagram for a FreeRTOS.org context switch
fE
This diagram shows the application tasks, the hardware timer, and
all the
functions in the kernel that are involved in the context
switch:
O
vPreemptiveTick () is called when the timer ticks.
e
context. task
VTaskIncrementTick( ) updates the time
ol
and vTaskSwitchContext
chooses a new task.
C
as an active class.
Ta
processClass1
myAttributes
myOperations( )
Signals
start
resume.
Processes.and
Operating Systems
7.21
7.15 shows an example of a UML active class. It has all the nomal
# Fig
a-
characteristics of class, including a name, attributes, and operations. also
It
provides. a set ofisignals that can be used to communicate with
the process.
g
communication.
in
a: rawMsg
er
ahat: fullMsg
pl: processClass1 W: WrapperClass
e
master: masterClass
in
ng
Fig 7.16 A collaboration diagram witlh active and normal objects
a
We can mix both the active objects and normal objects. Fig 7.16 shows simple
fE
an interface between two
collaboration diagram in which an object is used as
O
processes.
data before the data is sent to the master
e
process.
le
ANSWERS
7.6 TWO MARKS QUESTIONS AND
ol
.
C
real-time tasks.
used for various hard and soft
ad
g
4. Define task assignments.
in
Task assignment is the process of allocating specific tasks or
responsibilities to
er
individuals or teams within an organization. It involves deternmining
who is
e
responsible for completing a task, by providing them
with the necessary
in
information and resources, and setting clear expectations for the desired outcome.
ng
5. List the reasons for task assignment.
fE
Task assignment is important for the following reasons:
(i) It ensures that work is distributed efficiently
O
and effectively among team
members.
e
and expertise.
le
6. What is scheduling?
iln
(or)
Why the sclheduling status considered iin
m
a
process? [APR/MAY-2023]
The way
Ta
g
Preemptive scheduling
in
is the most commoniy used schcduling
aigorithm in real
time systems. Here, the
er
tasks are prioritized and the task with the
among all other
highest priority
tasks gets the CPU time.
e
in
In the case of a non-preemptive scheduling, even the highest
if priority is
ng
allocated to the task, needs to
it wait until the completion of the current
This can task.
task be either slow (or) lower priority, which can
9.
fE lead to a longer wait.
Why preemptive scheduling
is preferred in real time operating systems?
O
[APRMAY-2019)
e
(or)
What is
the concept of multitasking? Whatt does it sigify? [NOVIDEC-2018]
In embedded
systems, multitasking refers to the ability to effectively carry out
Several
tasks or processes at once. It enables an embedded system to manage
<br>
g
concurrently which helps build more complex systems using several programs
in
that run concurrently.
er
13. Define tasks and processes. [NOVIDEC-2016]
e
A task is a unit of execution or unit of work in a software application. Typically,
in
task execution in an embedded processor is managed by the Operating System
ng
(OS).
fE
A process is a single execution of a program. we run the same program two
If
different times, then we have two different processes. Each process has its own
O
state that includes both its registers as wellas its memory.
e
Processes that share the same address space are often called threads.
ol
15. Define multirate systems and give two real-time exanples. [APRIMAY-2023]
C
Systems that use different sampling rates at different stages are called the
u
multirate systems. These techniques are used to convert the given sampling rate
ad
Examples:
m
(or)
g
(U), It is defined as, "the ratio of the CPU time that is being used for useful
in
computations to the total available CPU tme".
er
CPUtime for useful work
e
U= total available CPU time
in
This ratio ranges between 0 to l.
ng
19.
fE
Write the function of scheduling policy.
O
A scheduling policy defines how processes are selected for promotion from the
e
The kernel is the part of the operating system that determines what
process is
ol
g
in
7. Sumnarize the services of operating system in handling nmultiple task and
er
multiple processes. [APRMAY-2018]
Explain how multiple processes are handled by preemptive real time operating
e
8.
in
system. [NOVDEC-2017]
ng
9. Discuss why preenptive scheduling is preferred in real time operating systems.
fE [APRMAY-2019]
10. With neat sketches, explain about nultirate ystems.
O
II. Explain in detail about preemptive real-time operating systems.
g e
le
ol
C
u
ad
iln
m
Ta
<br>
UNIT - III
Chapter 8
g
NETWORKS AND
in
e er
MULTIPROCESSORS
in
ng
8.1 PRIORITY-BASED SCHEDULING
fE
8.1.1 Introduction
O
The operating system's fundamental job is to allocate resources in the computing
e
system among programs that request them. So scheduling the CPU is one
of
g
task of higher priority to run. In the case of two tasks of the same high priority
C
round robin, in which all the processes are kept on a list and scheduled one
m
Pi 1
10
P2 2 20
g
P3 3 30
in
er
Table: 8.1 Process priority table
e
8.1.2 Rate- Monotonic Scheduling (RMS)
in
Rate-Monotonic Scheduling (RMS) was one of the first scheduling policies
ng
developed for real-time systems and it is still very widely used. The
priority is
decided according to the cycle time of the processes that are involved. The
fE
process with a small job duration (shortest
period), has assigned a highest
O
priority.
e
proportional to the
period it will run for.
ol
Utilization:
() CPU
g
The RMS is the optimal static-priority schedule but it
does not allow the
in
Svstem to use 100% of the available CPUcycles.
A set of processes can be
er
scheduled only if they satisfy the following equation:
e
C
in
M
n - 1).
S (21/n
ng
i =1
Where,
n -Number of processes (tasks) in the process set,
fE
O
C- Computation time of the process,
e
-
U
Processor utilization.
le
- 1)
C
U= n(21/n
willnot be
of two tasks under RMS scheduling, the CPUutilization
u
For a set
ad
(2) Example
m
Processes
3 20
P1
5
2
P2
2 10
P3
Solution:
Number of processes, n =3
U= n(21/n - 1)
<br>
(or)
g
2
in
n
2
3
-0o ++o= 0.15 +
0.4+ 0.2
er
i=1
U= 0.75
e
in
It is less than 1-or 100% utilization. The combined utilization of three
ng
processes is less than the threshold of these processes which means the
above set of processes is schedulable and thus satisfies the above equation of
fE
the algorithm.
O
(i) Scheduling time
For calculating the scheduling time of the algorithm we have to take the LCM
e
of the time period of all the processes. In the above example, LCM (20, 5, 10)
g
le
(ii) Priority
C
The priority will be the highest for the process which has the least running
u
time period. Thus, P2 will have the highest priority, and after that P3 and
ad
lastly P1.
iln
P2 > P3 > P1
2
m
2 2 2
P2
Ta
5 10 20
15
2
2
P3
10 20
3
P1
0 20
g
0 1
2 3 4 5 6 7 8
in
10 11 12 13 14 15 16 17 18 19 20
er
Fig 8.2 Total execution time
e
(3) Advantages and Disadvantages
in
E Advantages
ng
The advantages of RMS are,
() It is easy to implement.
fE
O
(ii) If any static priority assignment algorithm can meet the deadlines then rate
monotonic scheduling can also do the same. It is optimal.
g e
B Disadvantages:
ol
(i) RMA is not optimal when the task period and deadline differ.
u
ad
algorithm sed in real-tine .systems. EDF uses priorities for scheduling which
Ta
* The task whose deadline is closest gets tlhe highest priority. The priorities are
assigned and changed in a dynamic fashion. EDF is very eficient as compared to
other scheduling algorithms in real-time systems. It can make the CPU utilization
l0 about 100% while still guaranteeing the deadlines of all the tasks.
<br>
g
in
3 Static priority scheduling. Dynamic priority scheduling.
er
4 Not expensive to use in practice. Expensive to use in practice.
- period process gets
e
5 Shortest Process closest to its deadline has
in
highest priority. highest priority.
ng
Table 8.l Comparison between RMS and EDF
An I/O device has a flag that must be tested and modified by a process.
ol
If
combinations of events from the two tasks operate on the device
in the wrong
C
order, we may create critical timing race or race condition that causes
u
erroneous operation.
ad
A Definition:
iln
attenpts to perform two or more operations at the same time, but because of the
nature of the device or system, the operations must be done in the proper
Ta
Networks and
Multiprocessors 8.7
of processes, so that when one process has entered its critical section, no other
process is allowed to execute in its critical section.
Process
g
Entry Section
in
er
Critical Section
e
Exit Section
in
ng
Fig 8.3 Critical section fE
(3) Semaphores
O
a Definition:
e
Semaphores are just normal variables that are used to coordinate the activities
g
processes.
o The process of using semaphores provides two operations: wait (P) and
u
ad
signal ().
signal
o The wait operation decrements the value of the semaphore, and the
iln
P()
release it.
*/
/*some nonprotectedoperations here
P();/*wait for semaphore */
work here */
/* do protected
V();/*release semaphore */
<br>
g
in
a Priority Inheritance:
er
The basic idea to promote the priority of any
of the priority inheritance is
process when it requests a resource from the operating system. The priorily of
e
the process temporarily becomes higher than that of any other
process that may
in
ng
use the resource.
process abstraction.
In general, a process can send a communication in one of two ways:
ol
() Blocking, and
C
(ii) Nonblocking.
u
After sending in a bocking communication, the process goes into the waiting
ad
There are two modes through which processes can communicate with each other:
m
g
Shared
in
CPU location /O device
er
Nemo
e
in
Write
ng
Read
fE Bus
The I/O device then reads the data from that location.
g
le
4 In the message pussing node, proccsses interact with each other through
C
Process A M
Writes
Data
iln
Process B M
Reads
m
Dala
Ta
Kernel M
other through
In Fig 8.5, two processes A, and B are communicating with each
message passing. Process A sends a message M to the operating system (kernel).
This message is then read by process B.
own message send/receive
Each communication entity (CPUor process) has its
g
unit.
in
(1) Queues
er
queue uses a FIFO
A queue is a common form of message passing. The
e
discipline and holds records that represent the messages.
in
The FreeRTOS.org system provides a set of
queue functions which allows
ng
queues to be created and deleted so that the system may have as many queues
as necessary. fE
Process P1
O
Process P2
g e
le
Message Queue
ol
Kernel
C
8.2.4 Signals
iln
Signal is also called software interrupt and it is not predictable to know its
occurrence; hence it is also called as an asynchronous eyent.
4 Fig 8.7 shows the use of a signal in UML. The sigbehavior () behavior of the
class is responsible for throwing the signal, as indicated by <<send>>, The signal
object is indicated by the <<signalb> stereotype.
<br>
someClass
<signal>>
aSig <<send>>
sigbehavior)
g
p: integer
in
er
Fig 8.7 Use ofa UML signal
8,2.5 Mailboxes
e
in
The mailbox is a simple mechanism for asynchronous communication. It has a
ng
fxed mumber of bits and can be used for small messages. Some architectures
define mailbox registers.
fE
# We can implement a mailbox by using P( ) and V( ) in main memory for the
O
mailbox storage. A very simple version of a mailbox that it holds only one
message at a time.
g e
le
Task2
ol
C
Mailbox
-I
u
Task3
ad
iln
Task4
m
Ta
g
to 'solve these problems include simulation
in
the ways to solve it. The approaches
as scheduling technique.
technique and also scheduling technique such holistic
e er
8.3.2 Network Abstractions: The 0SI Model
in
services while
Networks are complex systems which ideally provide high-level
ng
hiding many of the details of data transmission from the other
components in the
system. fE
Application End-use interface
O
Transport
ol
Connections
C
model for networks known as Open Systemn Interconnection (0S) models. This
OSI layers will help us to understand the details of real networks.
The seven layers of the OSI model is shown in Fig 8.9 which are proposed to
cover a broad spectrum of networks and their uses. Some networks may not need
the services of one or mor layers because the higher layers may be totally
missing or an intermediate layer may not be necessary.
Any data network should fit into the OSI model which includes seven levels of
abstraction known as layers:
<br>
Networksand Multiprocessors
8.13
(0 Physical Layer:
This layer defines the basic
properties of the interface between systems which
includes the physical connections
(plugs and wires), electrical properties,
functions of the electrical and physical components,
basic
and the basic procedures for
exchanging bits.
g
in
(ü) Data link Layer:
er
The primary purpose of this layer is error detection and control across a single
e
link.
in
(ii) Network Layer:
ng
This layer defines the basic end-to-end data transmission service
fE which is
particularly important in the multi-hop networks.
O
(iv) Transport Layer
This layer defines connection-oriented services which ensures that data are
g e
delivered in the proper order and without errors across multiple links. This layer
le
to
This layer defines data exchange formats and provides transformation utilities
m
an application programs.
Ta
(vil) Application
Layer
between the network and
Ihe application layer provides the application interface
end-user programs.
g
applications without a host computer.
in
Microcontroller
e er
in
CAN controller
ng
fE
CAN Transceiver
O
e
SDL
g
SCL
ol
0
dominant
g
in
e er
in
ng
Node Node
fE a
Fig 8.11 Plysical and electrical organization of
CAN bus
O
When all nodes are transmitting ls, the bus is said to be in the recessive state;
when a node transmits a), the bus is in the dominant state. Data are sent on
eg
CAN is a synchronous bus because all transmitters must send at the same
ol
The format of a CAN data frame is shown in Fig 8.12. A data frame starts
ad
with a 1 and ends with a string of seven zeroes. The first field in the packet
contains the packet's destination address which is known as' the arbitration
iln
field.
m
Transmission
The destination identifier is 11 bits long. The trailing Remote
Ta
The acknowledge field is used to check whether the frame was correctly
received.
12 6 0 to 64 16 2
Start
g
Arbitration field
Acknowledge End of
in
field frame
er
Value=1 Value =0
e
in
transmissiorj
ng
ldentifier
Remote request
bit
Data
length
fE ACK ACK
slot delimiter
code
O
e
11 1 1
g
4
1 1
le
(3) Arbitration
C
Arbitration on Message
Priority (CSMA/AMP).
ad
a Remote Frames:
A remote frame is used to request data from another
node.
(4).Architecture
o
Fig 8.13 shows the basic architecture
of a typical CAN controller which
implements the physical and data link layers; because CAN is a bus. it does
not need network layer services to estäblish end-to-end connections.
<br>
|8.17
Status/control
Protocol registers
CAN controller Host +Host
bus interface
Message
g
objects
in
er
Receive
e
buffer
in
Fig 8.13 Architecture of a CAN
ng
COntroller
The protocol control block is
responsible for determining
fE
messages, whena message when to send
must be resent due to arbitration
a message should be received. losses, and when
O
e
car is controlled
by a network of processors that each has its own
responsibility
C
Engine
m
Ta
Transmission
ABS
g
Aircraft electronics are known as
in
avionics. The most fundamental
between avionics and automotive difference
er
electronics is certification.
Anything that is
permanently attached to the aircraft
must be certified. The certification process
e
for production of aircraft is in two
in
phases:
ng
(i) Design is certified in a process
is known as type certification,
(iü)
and
The manufacture of each aircraft fE
is certified during production.
The traditional architecture for an
avionics system has a separate
O
function: artificial horizon, engine unit for each
control, flight surfaces, etc.
These units are
e
maintenance.
ol
M Advantages
m
() Easy to implement,
Ta
G) Serial Clock Line (SCL) indicates when there is a valid data on the data
line.
Master 1
Slave 1
g
SDL
in
er
SCL
e
in
Master 2
ng
Fig 8.15 Structure of an FC bus system
fE
Fig 8.15 shows the structure 'of a typical I'C bus system. Every node in the
O
network is to both SCL and SDL. Some nodes may be able to act as
connectd
may act
bus masters and the bus may have more than one master. Other nodes
g e
a
A bus transaction is comprised of series of 1-byte
transmissions and an
C
Device address RW
Ta
1 bit
7 bits
address transmission
Fig 8.16 Format of anIC
is shown in Fig 8.16. An address
The format of an address transmission
1
bit for data direction:
transmission includes the 7-bit address and
(1) 0 - Writing from the
master to the slave, and
master.
(1) 1-Reading from the slave to the
<br>
A master can write and then read (or) read and then write by sending a start
after the data transmission, followed by another address transmission and then
more data.
o The basic state transition graph for the master's actions in a bus transaction is
shown in Fig 8.17.
g
in
Address
er
Start
Address, 0
e
Idle Start
in
Address,
ng
Start
Stop Get
Data fE Data Send
read data write data
O
Stop
e
the
slave and then sends another to initiate a
read from the slave.
u
Start
ad
s7-bit address 1
m
Data P Stop
Read From slave
Ta
SCL SDL
Application
Interrupt
g
Bytes
Driver
in
Microprocessor
er
device
Bits
e
Memory
in
Control
Data
ng
Microcontroller fE
O
Fig 8.19 An IC interface in a microcontroller
Microcontroller's timer is typically used to control the length of bits on
e
the
g
bus. Interrupts may be used to recognize bits and masters to initiate their own
le
transfers.
ol
8.3.6
C
Ethernet
Ethernet is very widely used as a Local Area Network (LAN) for.general -
u
ad
purpose computing. Because of its ubiquity and the low cost of Ethernet
interfaces, it is used as a network for embedded computing.
iln
m
Ta
A B C
Start
g
in
er
Ethernet Increment
No
e
Yes
in
ng
Transmit
Yes
fE
<Collision? Abort Wait backup
O
No
e
No
g
Done?
le
Yes.
ol
Finish
C
A node that has a message waits for the bus and then starts transmitting. It
ad
Preamble
()
Ethernet packet starts with a 7-bytes Preamble. This is a pattern
of alternative
g
0's and 1's which indicates starting of the frame and allow sender and receiver
in
to establish bit synchronization.
er
() Start of Frame Delimiter (SFD)
e
in
This is a 1-byte field that is always set to 10101011. SFD indicates that
ng
upcoming bits are starting the packet, which is the destination address.
(i) Length fE
Length is a 2-byte field, which indicates the length of the entire Ethernet
O
packet.
e
(iv) Data
g
le
This is the place where actual data is inserted which is also known as
payload.
ol
Definition
u
ad
The internet layer defines an official packet format and protocol called Internet
Protocol (1P) that provides a connectionless, best-effort delivery service of
iln
systems.
* The term Internet generally means the global nework of computers connected by
the Internet Protocol. In general, an Internet packet will travel over several
different networks from source to destination. The rçlationship between IP and
ndividual networks is illustrated in Fig 8.23.
<br>
Application Application
IP
Transport Transport
g
Data link Data link Data link
in
Physical Physical Physical
er
Node A Router Node B
e
in
Fig 8.23 Protocol utilization in Internet communication
ng
IP works at the network layer. When node A wants to send data to node B, the
application's data pass through several layers of the protocol stack to get to the
fE
Internet Protocol.
O
IP creates packets for routing to the destination, which are then sent to the data
link and physical layers. A node that transmits data among different types
e
af
networks is known as a router.
g
le
a
ad
provide any guarantee that data is effectively delivered or that delivery meets
any quality of 'service.
m
Ta
Identification
bytes
Flags Fragment offset
Header Time to live
Protocol
g
24 Header checksum
in
Source address
er
Destination address
e
Options and padding
in
ng
Data
payload Data
fE
O
Fig 8.24 IP packet structure
e
Header Length tells the number of 32-bits (or) 4 byte word in the header
and it is
used to describe its length.
u
ad
This field defines the entire packet size, including header and data, in bytes.
Ta
M
D:Do not fragment
O D| M:More fragments
g
It is a pointer that shows the offset ofa particular fragment data in the original
in
unftagmented (original) IP packet.
er
(h) Time To Live (TT): 8 bits
e
This shows the number of stations a packet can travel before it is discarded.
in
ng
(i) Protocol: & bits
It defines which upper-layer protocol data are encapsulated in the datagram, such
fE
as TCP, UDP, ICMP and IGMP.
O
Välue Protocol
e
1
ICMP
g
2 IGMP
le
6 TCP
ol
17 UDP
C
89 OSPF
u
The options field gives more functionality to the IP datagram. It can carry fields
that control routing, timing, management, and alignment.
(2) IP Services
The Internet also provides higher-level services built on top of P. The
Transnission Control Protocol (TCP) providesa connection-oriented service
that ensures that data arrive in the appropriate order, and it uses
an
g
TCP
in
UDP
er
IP
e
in
Fig 8.26 The Internet service stack
ng
o
Fig 8.26 shows the relationships between IP and higher-level Internet services.
fE
Using IP as the foundation, TCP is used to provide File Transport Protocol.
(FTP) for batch file transfers and Hypertext Transport Protocol (HTTP) for
O
World Wide Web service.
g e
o Simple Mail Transfer Protocol (SMTP) for e-mail, and Telnet for virtual
le
used as the basis for the network management services that is provided by the
C
of higher priority to run. In the case of two tasks of the same high priority each is
given an equal time slice.
Z. What is Rate Monotonie Scheduling? [NOVDEC-2018|
Rate-Monotonic Scheduling (RMS) was one of the first scheduling policies
developed for real-time systems and it is still very widely used. The priority is
decided according to the cycle time of the processes that are involved. The
Process with a small job duration shortest period), has assigned a highest
piority.
<br>
g
which the task has the larget response time.
in
er
5. Write the advantages of RMS.
e
The advantages of RMS are,
in
(i) It iseasy to implement.
ng
() If any static priority assignment algorithm can meet the deadlines then rate
fE
monotonic scheduling can also do the same. It is optimal.
(ii) It consists of a calculated copy of the time periods.
O
6. What is EDF scheduling?
g e
algorithm used in real-time systems. EDF uses priorities for scheduling which
ol
The task whose deadline is closest gets the highest priority. It can make the CPU
u
utilization to about 100% while still guaranteeing the deadlines of all the tasks.
ad
&
Defne critical timing race or race condition.
attempts to perform two or more operations at the same time, but because of the
nature of the device Or system, the operations must be done in the proper
g
sequence and it need to be done correctly.
in
. What is critical sections? (or)
er
What is the need of criticalsections?
e
of code where processes access shared
The critical section refers to the segment
in
resources, such as common variables and files, and perform write operations on
ng
them.
fE
The critical section problem is used to design a protocol followed by a group of
processes, so that when one process has entered its critical section, no other
O
process is allowed to execute in its critical section.
e
Semaphores are just normal variables that is used to coordinate the activities of
ol
(APRMAY-2017& APRMAY-2019)
I. What is Priority Inversion?
a process blocks
Priority inversion is a situation that can occur when low-priority
iln
inheritance.
Common method for dealing with priority inversion is priority
Ta
830|
() Blocking, and
g
to continue execution after
in
interprocess communication.
14. List out the major styles of
e er
(or)
in
Name the two modes used in interprocess communication.
ng
There are two modes through which processes can communicate with each
other:
The shared memory region shares a shared memory between the processes. On
g
the other hand, the message passing lets processes exchange information through
le
messages.
ol
Some architeou
define mailbox registers.
iln
(or)
Ta
What is a distributed
embedded architecture?
In a distributed embedded are
system, several (PEs)
connected by a Processing Elements
network
that allows elements
may
includes DSP, CPU or
them to communicate. Processing
microcontroller. such as
ASICs is also
used Nonprogrammable unit
to implement as
PE.
17. List the
OSI layers fromlowest to highest
The OSI 1ayers level of abstraction.
fromthelowest
to highestlevel of are described as,
() Physical layer. abstraction
<br>
() Session layer.
g
in
(vi) Application layer.
er
J8. What is CAN bus?
e
in
A
Controller Area Network (CAN
bus) is a vehicle bus standard designed
to
ng
allow microcontrollers and
devices to communicate with each
applications without a host computer.
other's
20.
g
devices
within small-scale embedded systems. It is a
well-known bus commonly used to
C
is used.
For CAN bus, Carrier Sense Multiple Access with Arbitration on Message
m
Priority (CSMA/AMP).
Ta
4 Define
Internet Protocol (1P).
The
internet
Protocol
layer defines an official packet format and protocol called Internet
(IP) that provides a connectionless, best-effort delivery service of
datagrams
across the Internet.
23, What
is best-effort delivery?
Best-effort
delivery describes a a
network service in which network does not
provide
any guarantee that data is effectively delivered or
that delivery meets
anyquality
of service.
<br>
[NOVIDEC-2016]
g
3. Elucidate on schèduling policies with suitable examples. APRMAY-2018]
in
4. -
Explain in detail about Earliest Deadline First scheduling. [APRMAY-2017|
er
5. Compare RMS. versus EDE.
e
NOVDEC-2018]
in
6. With neat sketches, explain the interprocess communication mechanism.
ng
[APRMAY-2017, NOVDEC-2017 & APRAMAY-2018
7. fE
Demonstrate about inter process communication mechanisns.
[APRMAY-2019)
O
8. Discuss about the distributed embedded system
e
[NOV/DEC-2018]
m
UNIT -II
Chapter 9
g
MPSOCs AND SHARED MEMORY
in
er
MULTIPROCESSORS
e
in
9.1 MPSoCs AND SHARED MEMORY MULTIPROCESSORS
ng
9.1.1 Introduction fE
& MPSoC:
O
two or more CPU cores. The multiprocessor is a parallel processor with a single
g
le
shared memory.
ol
Shared memory processors are well suited to applications that requires a large
C
Shared
m
Kernel
a Shared Memory:
g
in
Shared memory is a memory that shares between two or more processes. Each
er
process has its own address space; if any process wants to comnmunicate with
e
some information from its own address space to other processes, then it is only
in
possible with IPC (inter-process communication) techniques.
ng
9.1.2 Heterogeneous Shared Memory Multiprocessors
fE
Many high-performance embedded platforms are heterogeneous multiprocessors:
O
Diferent Processing Elements (PEs) can perform diferent functions. The
memory system may be heterogeneously
distributed around the machine, and
e
heterogeneous.
The PEs may be programmable processors with
ol
programmability.
Processors with different instruction sets can
perform different tasks by using
u
9.1.3 Accelerators
m
Accelerator
Memory
Accelerator
g
CPU
in
e er
in
registers
ng
registers
Accelerator
logic
Data fE
Control
O
e
The CPUand the accelerator may also communicate via shared memory and use
le
synchronization mechanisms to ensure that they do not destroy each other's data.
ol
C
An accelerator interacts with the CPU through the programming model interface
which does not execute instructions. Its interface is functionally equivalent to an
u
VO device,
The first task in designing an accelerator is to determine that our system actually
iln
run
needs one, We have to make sure that the function we want to accelerate will
m
Finally, we will have to design the CPU-side interface to the accelerator. The
the data to it
application software will have to talk to the accelerator, providing
and also telling it what to do next?
teld-Programmable Gate Arrays (FPGAS) provide one useful platform for
Custom
a
accelerators. An FPGAhas fabric with both programmable logic gates
implement a specific
and programmable interconnect that can be configured to
function.
<br>
g
in
Flow of control Flow of control Split
e er
in
A1 A1
ng
P3
Accelerator Accelerator
(P4)
fE P4 -- Join
CPU
CPU
O
Execution time
Execution time
e
Accelerator
g
A1 Accelerator
A1
le
ol
CPU P1 P2 P3 P4 CPU P1 P3
P2 P4
C
Time
Time
Single-threaded
u
Multi-threaded
Fig 9.3 Single- threaded vs. mnultithreaded
ad
control of an accelerator
4 Fig 9.3 shows that data dependencies
allow P2 and P3 to run
iln
by the accelerator.
Ta
Memory
Inputs
g
in
Outputs
W=ab- c*d:
CPU X=e*f,
e er
in
Accelerator
ng
Fig 9.4 Components of execution time for am accelerator
fE
Fig 9.4 shows that an execution time for the accelerator depends not only on the
O
time required to execute the accelerator's function but also depends on the time
required to get the data into the accelerator and back out of it.
g e
A simple accelerator will read all its input data, perform the required
le
computation, and then write all its results. Then the total execution time is
ol
expressed as,
C
= lin
Lacoel
t t+ tout
u
where,
ad
in and tout are the times required for reading and writing the
required variables.
m
respectively.
may take in one or more streams of data and
Ta
a[-1]
b[t-1]
Inputs a [t]
g
b []
in
e er
out [i] = a Q*b [0:
in
ng
fE Accelerator
O
Out [t-1]
Outputs
e
Out [t]
g
of an accelerator
(2) System
ol
Speedup
Ina single-threaded system, the evaluation of the accelerator' s speedup to the
C
Page 32 of 440
1l
P2
S
g
in
P3
e er
in
P4!
ng
fE
Fig 9.6 Evaluating systenn speedup in a single-threaded implementatioin
O
Flow of control
g e
P1
le
ol
C
u
2
ad
iln
m
Ta
g
in
9.2 DESIGN EXAMPLE: AUDIO. PLAYER
er
9.2.1 Theory of Operation and Requirements
e
Audio players are often called MP3 players.
in
The earliest portable MP3 players
were based on compact
ng
disk mechanisms and the modern MP3
nmemory
players use either
aflash or disk drives to store music.
fE
An MP3 player performs three basic functions:
(i)) Audio storage,
O
(ii) Audio decompression, and
e
(1)Audio Decompression
ol
Audio compression is a
lossy process that relies on
ad
9.9
(i) Layer 2 (MP2)
It uses a more advanced
masking model.
(üi) Layer 3(MP3)
It performs additional processing to provide a
lower bit rates.
The various layers that supports several
g
different input sampling rates, output
in
bit rates, and modes such as mono, stereo, etc.
e er
Scale factor
in
ng
Mux
Filter
Quantizerlencoder
bank
fE o 0101.
O
Masking
FFT model
e
path
a diagram of a layer I encoder. The main processing
o Fig 9.8 gives block
ol
the
the quantizer/encoder. The filter bank splits
includes the filter bank and
frequency domain
C
rate.
the encoder to reduce the bit
Subbands helps driven by a
separate Fast
m
factors, which is
model selects the scale could be used for masking,
The masking principle
Ta
O
The filter bank
Fourier Iransform(FFT). results.
provides better which can
but Separate FFT for the subbands,
the scale factors output of the
o model chooses multiplexer at the
The masking stream. The
audio
change along with the required data.
all the
encoder passes along
Aux
Subband
Scale data
samples
Bit factors
CRC allocation
Header format
layer-l data frame
MPEG
Fig 9.9
<br>
g
Demux
Inverse
in
quanlize Inverse
0101..
er
filter
L Expand
bank
e
in
Step
ng
size
Audio player
ad
Outputs Speaker
Ta
displ = 0;
g
in
er
Send Files[displ].name
e
to display
in
ng
button
fE
O
down
Play
g e
le
& Fig 9.11 shows a state diagram for file display/selection. This specification
assumes that allfiles are in the root directory and that all files are playable audio.
iln
* Fig 9.12 shows the state diagram for audio playback. The detals of this operation
m
Ms state diagram refers to sending the samples to the audio system because
playback and reading the next data frame must be overlapped to ensure
continuous operation.
%
The details depend on the hardware platform selected mostly DMA
of playback
transfer
is used.
<br>
Start
Open file
g
in
er
Read frame
e
in
ng
Parse frame
fE
O
Decode frame
g e
system
ol
C
F Last
frame?
u
ad
iln
End
m
RISC processor
DSP Audio
interface
CD
CD interface
drive SRAM
g
Memory controller
in
er
ROM
e
in
ng
flash, DRAM, SRAM
Fig 9.13 Architecture of a Cirrus audio processor fE
for CDMP3 player
Fig 9.13 shows the Cirrus chip uses two processors: a
RISC and a DSP. The
O
memory controller can interfaced to
be several different types of memory: flash
e
memory can be used for data or code storage and DRAM can
be used as a buffer
g
of
be used by A/D
converters. General-purpose I/O pins can be used to decode buttons, run displays,
C
The file
system can either implement known standard such as DOS FAT or can
a
implement a new file system. The file system and an user interface can be tested
Independently of the audio decompression system.
&
The audio
output system should be tested separately from the compression
System. Testing of audio decompression requires sample audio files.
<br>
g
9.3 ENGINE CONTROL UNIT (ECU)
in
er
We will design a simple Engine Control Unit (ECU) which controls the operation
of a fuel-injected engine based on the several measurements taken from the
e
in
running engine.
ng
9.3.1 Theory of Operation and Requirements
fE
Injection
O
Fuel pulse width
injection
RPM
Engine
e
Throttle Spark
g
Spark
le
advance
ol
C
g
in
Functions Compute injeçtor pulse width and spark advance angle as a
function of throttle, RPM, intake air volume, intake manifold
er
pressure
e
in
Performance |Injector pulse updated at 2-ms period, spark advance angle
updated at 1-ms period
ng
Manufacturing
cost |Approximately $50
fE
O
Power Powered by engine generator
weight
le
9.3.2 Specification
& The engine controller must deals many processes with different rates. Table 9.3
u
ad
shows the update periods for the different signals. ANE and AT represents the
change in RPM and throttle position, respectively.
iln
Variable Update
m
Signal In/Out
name period(ms)
Ta
Throttle T Input 2
NN
NE Input 2
RPM
Intake air volume VS Input 25
1
Spark advance angle S Output
g
as,
Spark advance angle (S) using initial values of these variables
in
.. (1)
er
1
PW = 22.5 x VS x 10-k, AT
NE
e
.(2)
in
S =k,x A NE- k; VS
ng
The controller then applies corections to these initial values:
()
fE
As the intake air temperature (THA) increases during engine warm-up, then
the controller reduces the injection duration.
O
(i) As ihe throttle opens, the controller temporarily increases the injection
e
frequency.
g
(ii) The controller adjusts duration up or down based upon readings from the
le
(iy) The injection duration is increased as the battery voltage (+B) drops.
C
u
a Fig 9.15 shows the class diagranm for the engine controller. The two major
iln
The control parameters are computed for the spark plugs and injectors. The
control parameters rely on changes in some of the input signals. We will use the
Ta
Page 33 of 440
1l
Throttle
Pulse-width Spark
g
RPM"
in
Advance
Injector*
er
angle
Air
volume*
e
in
ng
Intake-air
temp*
Exhaust
fE
Oxygen*
O
e
Battery
g
voltage*
le
Update previous
ad
values
iln
Save T
m
Ta
Compute AT
position sensing
Fig 9,16 State diagran for throttle
* Fig 9.17 pulse width, and Fig 9.17 (b)
(a) shows the state diagram for injector
shows angle. In each case, the value is
the state diagram for spark advance
followed by a correction.
Computed
intwo stages, first an initial value
<br>
Compute Compute
initial PW initial S
Correct PW Correct S
g
in
er
Fig 9.17 State diagrams
e
in
The pulse-width and advance-angle processes generate the spark and injector
waveforms which must be carefully timed to the engine's current state.
ng
Each spark plug and injector must fire at exactly the right time in the engine
fE
cycle and consider the engine's current speed as well as the control parameters.
The main processor is a PowerPC processor. The enhanced Modular 10
O
Subsystem (eMIOS) provides 28 input and output channels controlled by timers.
e
mode will automatically generate a waveform whose period and duty cycle can
ol
be varied by writing registers in the eMIOS. The details of the waveform timing
C
Variables that are maintained across task execution, such as the change-of-state
m
g
motion
in
estimation accelerator. Digital video
is still a computationally intensive
task, so it
er
is well suited for acceleration.
e
A video accelerator significantly speeds up
the updating of images on a screen
in
which makes CPUfree to take care of other tasks.
Simply, it act as a video card
ng
with integrated processor and memory. It is mainly , used
fE
1) To increase the overall capabilities of video graphics.
O
(ii) To provides critical speed ups for low-latency I/O functions.
e
Variable
Motion
DCT length Buffer
estimator
C
coder
u
ad
iln
DCT-1
Picture
m
store/
predictor
Ta
of MPEG-2conpression algorithm
Fig 9.18 Block diagram
Fig 9.18 shows the block diagram for MPEG-2 video compression algorithm
uses several
which is the basis for US HDTV broadcasting. This compression
g
in
MPEG uses motion to encode one frame in terms of another. Some frames are
er
sent as modified forms of other frames using a technique known as block
e
motion estimation.
in
a Block Motion Estimation:
ng
A
block matching algorithm is a way of locating the matching macroblocks in
fE
a sequence of digitalvideo frames for the purpose motion estimation.
of
During encoding, the frame is divided into macroblocks which is identified
O
from one frame in other frames using correlation.
e
Search
area
u
ad
Previous frame
iln
Current frame
m
Ta
Macroblock
.We divide the current frame into 16X16 macroblocks, For every macroblock in
g
the frame, we want to find the region in the previous frame that closely matches
in
to the macroblock.
er
We measure similarity using the following sum-of- diferences measure:
e
in
| M(iJ) - S(i –o,j -o,)
ng
1
sijsn
where
- Intensity of
fE
themacroblock at pixel i, j,
MiJ)
O
- Intensity of the search region,
S(i,j)
one dimension, and
n - Size of the macroblock in
e
search region.
g
MBSIZE
ol
C
u
ad
iln
XCENTER, YCENTER
m
Ta
SEARCHSIZE
center)
(measured from
Limit of search
MBSIZEI2
0,0 parameters
search
Block motion
Fig 9.20
<br>
g
Name Block motion estimator
in
Purpose Perform block motion estímation within a
er
PC system
e
|Inputs Macroblocks and scarch areas
in
Outputs Motion vectors
ng
Functions Compute motion vectors using full search
algorithms
Performance
fE
As fast as we can get
Manufacturing cost Hundreds of dollars
O
Power Powered byPC power
supply.
e
9.4.3 Specification
C
Motion-vector Macroblock
u
Search-area
ad
X, y pixels[]
pixels[]
iln
m
Fig 9.21 Classes describing basic data types in the video accelerator
Ta
MPSoCs and
Shared Memory Multiprocessors
9.23
PC Motion-estimator
memoryt 1
Compute-mv()
g
Fig 9.22 Bastc classes for the video accelerator
in
The PC makes its memory accessible to the accelerator.
The accelerator provides
er
a behavior
compute-mv() that performs the block motion estimation algorithm.
e
in
:PC :Motion-estimator
ng
compute-mv( ) fE
O
Search memory []
area
g e
le
memory 0
Macroblock
ol
C
motion-vector
u
ad
iln
video accelerator
Fig 9.23 Sequence diagram for the
m
Fig 9.23 shows a sequence diagram that describes the operation of compute-mv().
Ta
When initiating the behavior. the accelerator reads the search area and
macroblock from the PC. Ater computing the motion vector, it returns it to the
PC.
9.4,4Architecture
The accelerator on a card connected to a PC's
will be implemented in an FPGA
PCI slot.
We have to use a external memory to the FPGA but on the accelerator
board to hold
the pixels.
<br>
PEo
PE
g
in
Network
er
control PE2 Comparator
Motion
e
vector
in
ng
Macroblock
Network
fE
PE15
O
Fig 9.24 An architecture for the motion estimation accelerator
e
An architecture for the motion estimation accelerator is shown in Fig 9.24. The
g
le
machine has two memories: one for the macroblock and the another are for the
ol
searcl memories.
C
Memory Miultiprocessors
MPSOCs andd Shared. 9.25
interfacel Takes commands,
Interface: PCI
returns
motion vector
M memory.
PC memory fetch:
g
memory fetch unit single-port memory
in
Estimator engine:
motion estimator
er
S memory.
e
dual-port memory
in
Fig 9.25 0bject iagramn for the video accelerator
ng
9.5 TWO MARKS QUESTIONS AND ANSWERS
1 Expand MPSoC.
fE
O
MultiProcessor System on Chip (MPSoC) means a System-on- Chip (SoC) with
cores. The multiprocessor is a parallel processor with a single
e
shared memory.
le
Shared memory
process has its own address space; if any process wants to communicate with
u
SOme
techniques.
pOSSible with IPC (inter-process communication)
iln
m
which
for embedded I multiprocessors
Accelerator
is a Processing Element (PE)
Ta
In MP3 players,the following three layer standard defines the audio compression:
g
model.
in
(i) Layer 2 (MP2)
er
It uses a more advanced masking model.
e
in
(iii) Layer 3 (MP3)
ng
It performs additional processing to provide lower bit rates.
Data compressor is a process of reducing the amount of data needed for storage
O
or transmission of a given piece of information using encoding techniques.
e
7. Specify the MPEG layer-l data frame format for the audio player application.
g
le
[NOVIDEC-2016]
ol
CRC
Bit Scale Subband Aux
Header
C
(ii) DSP.
Ta
(iv) CD interface.
(vii)ROM.
(vii)lnputs/ Outputs.
<br>
What is the
need for video accelerator?
APR/MAY-2019)
(OR)
g
in
NOVDEC-2017
hdeo accelerator is a motion estimation accelerator. Digital video is still a
er
computationally intensive task, so it is well suited for acceleration.
e
in
A
video accelerator significantly speeds up the updating
of images on a screen
ng
uhich makes CPUfree to take care of other tasks. Simply, it acts as a
video card
with integrated processor and memory. It is mainly used,
sequence of digital video frames for the purpose of motion estimation. During
C
cncoding, the frame is divided into macroblocks which is identified from one
frame in other frames using correlation.
u
ad
PC system
Ta
Inputs
Macroblocks and search areas
Outputs
Motion vectors
Functions
Compute motion vectors using full search
algorithms
Performance
As fast as we can get
Manufacturing
cost Hundreds of dollars
Power
Powered by PC power supply
Physical size
and weight Packaged as PCI card for PC
<br>
g
2.
in
3. of an audio player.
With neat diagrams, explain the design
er
4. Iustrate the working of Engine Control Unit with a iagram.
e
[APRMAY-2017, NOVDEC-201, NOVDEC-2018 & APRMAY-20197
in
5. Write in detail about the embedded concepts in the design of video accelerator.
ng
NOVDEC-2016, NOVDEC-2018 & APRMAY-20191
fE
O
g e
le
ol
C
u
ad
iln
m
Ta
A
<br>
UNIT- IV
Chapter 10
INTERNET OF THINGS (|oTs)
g
in
er
10.1 INTRODUCTION
e
in
4 The Internet of Things (1oT) describes the netvork of pltysical objects which are
ng
considered as "things" that are embedded wih sensors, sofhware, and other
technologies for the purpose of conecting and exchanging data with other
fE
devices and systems over the Internet.
O
Today, we are using more than 10 billion connected IoT devices, experts
predicting that this number will grow up to 22 billion by 2025. Oracle has a
g e
10.1.1 Applications
ol
C
Homo
Appliancos
u
Smart phonos
ad
and
Computers
Woarablo
iln
Eloctronlcs
m
Printers
Ta
loT Industrial
Dovicos Machines
Cars
Hoalth
care
Sonsors
Camera
of loT
Fig 10.1Applications
<br>
g
energy systems, retail,
cities, environment,
in
health as outlined in Fig 10.1.
er
(i) Homes
e
as smart lighting that adapt the
IoT for homes has several applications such
in
lighting to suit the ambient conditions, smartappliances that can be remótely
ng
detectors,
monitored and controlled, intrusion detection systems, snart smoke
etc.
fE
Cities
O
(iü)
For cities, IoT has applications such as smart parking systems that provide the
e
status updates on available slots, smart lighting that helps in saving energy,
g
(ii) Environment
For environment, IoT has applications such as weather
u
Mernetef
2hings
10.3|
Industrial
i) Industrial applications of IoT include
machine diagnosis
and prognosis systems
that helps in predicting faults and determining the cause of
faults and indoor air
quality systems.
g
Eorhealth and lifestyle, loT has applications such as
in
health and fitness
monitoring systens and wearable electronics.
e er
10.1.2 Definition and Characteristics of IoT
in
4 The Internet of Things (oT) has been defined as,
ng
A Definition: fE
A dymamic global network infrastructure with selfconfiguring capabilities based
O
on standard and interoperable communication protocols where physical and
virtual "tlhings" have identities, physical attributes, and virtual personalities and
e
usSe
le
network, often communicate data associated with users and their emvironments.
ol
day or night.
Ta
Self- Configuring
a large number of
self-configuring capability that allow
loT devices may have
certain functionality.
devices to work together to provide
IoT
to configre themselves with the
Ihese devices haye the ability
fetch the latest software upgrades
infrastructure, setup the networking, and
With minimal manual or user intervention.
<br>
Protocols
(i) Interoperable Communication communication protocols and
IoT devices may support a number of interoperable
can communicate with other devices.
g
in
address or a URI.
er
(v) Integrated into Information Network:
e
loT devices are usually integrated into the information network that allows
them
in
to communicate and exchange data with other devices and systems.
ng
10.2 PHYSICAL DESIGN OF IOT fE
10.2.1 Things in IoT
O
The "Things" in loT usually refers to IoT devices which have unique identities
e
IoT devices can exchange data with other connected devices and applications
either directly or indirectly, or collect data from other devices and process the
ol
3.5mm audio
RJ45/Ethernet UART
m
RCA video
Ta
SPI
Memory Interfaces Graphics Storage Interfaces
12C
NANDINOR GPU SD
MMC CAN
DDR1/DDR2/DDR3
SDIO
ere
a
Fig 10.2 shows block diagram
|10.5
of atypical
severalI interfaces for connections IoT device
to other devices: which may
consists
VO interfaces for sensors, of
()
Interfaces for Internet connectivity,
()
(i). Memory andIstorageinterfaces, and
(i) Audio. Video interfaces.
g
in
An IoT device
can collect
various types of
er
data from
sensors, such as temperature, the on-board or
humidity, light intensity attached
e
den he communicated etc. The sensed data can
either to other devices or
in
cloud-based servers/storage.
1 IoT devices are many
ng
in types such as wearable sensors, smart
light automobiles and industrial machines. watches, LED
fE
10.2.2 IoT Protocols
O
() Link Layer
g e
the network's physical layer or medium such as copper wire, coaxial cable or
ol
a radio wave.
C
over
Using link layer protocols, hosts on the sanme lnk exchange data packets
u
to the context
the link layer. Some of the link layer protocols which is relevant
ad
0) 802.3 Ethernet:
m
g
in
802.11n operates in the 2.4/5 GH, bands.
er
802.11ad operates in the 60 GH band.
e
These standards provide data rates fromn I Mb/s to 6.75 Gb/s.
in
(iüi) IEEE 802.16: WiMax
ng
IEEE 802. 16 is a collection of Wireless broadband communication standards
fE
that provide the data rates from 1.5 Mb/s to 1Gb/s.
a
The recent update (802.16m) provides data rates of 100 Mbit/s for mobile
O
a
station and I Gbit/s for fixedstations.
e
Area Netvorks (LR-WPAN) which provides the data rates from 4OKb/s to 250
ol
Kb/s. These standards form the basis of specifications for higher level
C
includes UMTS and CDMA 2000 and the fourth generation (4G) incudes
Ta
LTE.
IoT devices based on these standards can communicate over cellular networks
with the data rates of 9.6 Kbs for 2G upto 100 Mb/s for 4G.
tlhings
ernetef
10.7
The datagrams contains a source
and destination address
routethem fromthe source to the
that are used to
destination across
the multiple networks.
Internet Protocol version 4 (IPv4)
an internet
IPy4 is protocol that is used to
identify the devices on a network
using a hierarchical I addressing scheme.
bit
g
It uses 32- address scheme that allows
total of 2 or 4,294,967,296
in
addresses. If more and more devices got
connected to the Internet then, we
er
can use IPv6.
Internet Protocol version
e
6 (|Pv6)
(ü)
in
It is the newest versions of internet protocol
and successor to IPv4. IPv6 uses
ng
128-bit address schemes that allows total
of22 or 3.4 x 10
addresses.
Ii) 1PV6 oVer Low Power Wireless Personl Area Networks (6 LoWPAN)
fE
This standard supports low power devices which have limited processing
O
capability. It operates in the 2.4 GHz frequency range and provides the data.
transfer rates of 250 Kb/s.
e
6LoWPAN works with the 802.154 link layer protocol and defines
g
networks.
ol
can
independent the underlying network. The message transfer capability
of
ad
as TCP or without
be set up on connections, either using handshake such
iln
() Error control,
Ta
() Segmentation,
(ii) Flow control, and
(iv) Congestion control.
)
Transmission Control Protocol(TCP):
most widely used transport layer protocol that is used by the web
1P is the programs (SMTP application layer
browsers along with HTTP, email
g
capability of TCP
The flow control
in
not too high for the receiver to process. The congestion control
the data is
er
congestion.
capability of TCP helps in avoiding network
e
User Datagram Protocol (UDP)
in
(i)
time-sensitive applications
ng
UDP is a connectionless protocol, it is useful for
that have very small data units to exchange and do
not want the overhead of
connection setup.
fE
O
UDP does not provide guaranteed delivery, ordering of messages and
Application Layer
le
WebSockets
ol
HTTP CoAP
C
Transport Layer
TCP UDP
iln
m
Network Layer
Ta
Link Layer
things
mernet
f |10.9
Application Layer
9
Aplication layer protocol defines how the
applications interface with the
lowerr layer protocols to sendd the data over
the network.
The application data are typically
in files which is encoded
by the application
and
g
layer protocol Iencapsulated in the transport layer
protocol which provides
in
connection or transaction oriented communication over
the network.
er
Application layer protocols enable process-to-process
connection using ports.
e
The ports numbers are used for application addressing.
in
ng
Example: Port 80for HTTP and Port 22 for SSH.
to identify HTTP
HTTP protocol uses Universal Resource Identifiers (URIs)
C
(M2M)
COAP is an application layer protocol for Machine-to-Machine
uses a request-response model
applications. It is a web transfer protocol and
iln
g
to topics. MOTT
The broker forwards the messages to the clients subscribed
in
specifications are available on JBM developer works.
er
Extensible Messaging and Presence Protocol (XMPP)
e
(v)
in
XMPP is a protocol for real-time communication and streaming XML data
between network entities. XMPP supports wide range of applications
ng
including messaging, presence, data syndication, gaming, multi-party chat and
voice /voice calls.
fE
XMPP is a decentralized protocol and uses client-server architecture. It
O
supports both client-to-server and server-to-server communication paths.
e
generate data) create topics to which subscribers (e.g., devices that want to
ad
g
low-level-specifications
inyplementation. of the
in
er
10.3,1 IoT Functional Blocks
e
in
Application
ng
Services fE
Managemenl
Security
O
Communication
g e
le
Device
ol
* An loT system comprises of a number of functional blocks that provide the system
u
ad
) Device:
m
An loT system comprises of the devices that provide sensing, actùation, monitoring
Ta
li) Communication:
This
communication block handles the communication for the loTsystem.
(ii) Services:
(iv) Management:
functions to govern the loT system.
These functional blocks provide various
(v) Security:
secures the loT system and by providing functions such
Security functional block
g
and data
authorization, message and content integrity,
in
as authentication,
er
security.
e
(vi) Application:
users can use to control and monitor
in
IoT applications provide an interface that the
system. Applications also allow users to view the
ng
the various aspects of the IoT
system status and also to view or analyze the processed data.
fE
10.3.2 IoT Communication Models
O
(i) Request- Response:
e
sends
Request-response is a communications model in which the client
g
When the server receives a request, it decides how to respond, fetches the
ol
data, retrieves resource representations, prepares the response, and then sends
C
Client Server
Receives requests
Ta
7htngs
lernetef
|10.13|
publlsh-Subscribe:
communication model that
It is a involves publishers,
brokers and consumers.
Publishers arc the source of data and send the data
to the topics which is
managcd by the broker. Publishers are not aware
of
the consumers.
Consumcrs subscribe to the topics that are managed by the broker. Once
g
Lenker rcccives the data for a topic from
the
in
the publisher, it sends the data to all
the subscribed consumers,
e er
Publishor Broker
in
Consumer-1
Message published
ng
Topic-1
to Topic-1
Sends Subscribers:
messages to Consumer-1,
topics
fE
Consumer-2 Consumer-2
Message published
O
Topic-2
to Topic-2
Subscribers:
Consumer-3
e
Consumer-3
g
le
communication model
ol
(fi) Push-Pull:
which the data producers pushes the
u
Publisher
Queues Consumer-1
Messages pulled
Sends queues
from
messages to Messages pushed Consumer-2
queue to queues
model
communication
Duch-Dull
-ng
<br>
g
server can send
close the connection. Client and
in
connection setup.
er
communication model and the server is aware of all
Exclusive pair is a stateful
e
10.8 shows the client-server
interactions in the
in
the open connections. Fig.
ng
exclusive pair model.
fE
Request to setup Connection
O
Response accepting the request
g e
le
Mernet of
Ihings
|10.15
REST follows the request- response
API
o communication model.
architectural constraints apply to The REST
the components, connectors,
within a distributed hypermedia and data clements,
system.
g
REST GET PUT
in
Aware Authorization
POST DELETE
HTTP Client
er
REST-full Web
REST Payload Service
e
JSON
in
XML
ng
fE Resourcos
O
URI URI
Representations Representations
g e
Resource Resource
le
ol
0) Client-Server:
concerns.
principle behind the client-server constraint is the separation of
iln
The
For example, clients should not be concerned with the storage of data which
is
m
a concern
of the server.
Ta
(ii) Cache-able:
a response to a request he
Catch constraint requires that the data within
or non-cacheable.
implicitly or cxplicitly labeled as cache-able
reuse thos
Ifa response is cache-able, then a client cache is given the right to
g
response data for later.
in
Caching can be partially or completely eliminate
some interactions and the
er
improve efficiency and scalability.
e
in
(iv) Layered System:
ng
The layered system constraint just reflects the constraints the behavior of the
components such that cach component cannot see beyond the immediate layer
fE
with which they are interacting.
O
The system scalability can be improved by allowing intermediaries to respond
e
between a client and a server must be uniform. Resources are identified in the
requests and are themselves separate from the representations
u
of the resources
ad
the information
required to update or delete the resource. Each message includes enough
m
hings
hernet of
|10.17|
REST
Client
Server
g
in
Response (JSON or XML)
er
Request (GET, PUT, UPDATE or DELETE)
e
with payload (JSON or XML).
in
ng
Response (JSON or XML)
fE
O
Fig 10.10 Request-response model used byy REST
e
(2) Web
Socket-Based Communication APls
g
WebSocket Protocol
le
Client
Server
ol
C
lInitial Handshake
ad
Data frame
m
Data frame
Bidirectional Communication
Ta
(over persistent
Data frame WebSocket connection)
Data frame
WVebSocket APIs
Pig 10.11 Exclusive pair model used by
<br>
g
sent over HTTP and the server interprets it as an upgrade request.
in
If the server supports WebSocket protocol, then the server responds to the
er
WebSocket handshake response. After the connection.is setup, the client and
e
the server can send data/messages to each other in full-duplex mode.
in
ng
WebSocket is suitable for loT applications that have low latency or high
througlput requirements. fE
10.4 IoT ENABLING TECHNOLOGIES
O
WSN comprises of distributed devices with the sensor which are used to monitor
le
routers which are responsible for routing the data packets from
end-nodes to the
ad
coordinator.
iln
Ihings
emet of
10.19
WSNs are enabled by wireless communication
protocols such as
Wsecifications are based on 1EEE IEEE 802.154.
802.15.4 which one
is of the most
popular wireless technologies used by WSNs.
g
environmental conditions.
in
The self-organizing capability
er
of WSN makes network that can reconfigure itself
uhen there is a failure
of some nodes or an addition of new nodes to the network.
e
in
10.4.2 Cloud Computing
ng
fE
O
Cloud Computing
g e
le
ol
Servers Storage
C
Internet
iln
Router Switch
m
End User
Ta
g
in
(i) Infrastructure-as-a-Service (laaS):
er
IaaS is a form ofcloud computing that provides virtualized computing
e
resources over the Internet. In the laaS model, the cloud provider manages IT
in
infrastructures such as storage, server and networking resources, and delivers
ng
them to subscriber organizations via virtual machines accessible through the
Internet. fE
laaS can have many benefits for organzations, such as potentially making
workloads faster, easier, more flexible and also more cost.
O
g e
le
ol
Service Provider
u
ad
iln
m
things
aernel of 10.21|
Software-as-a--Service(SaaS)
g
service provider. These services are available
to end-users over the Internet so,
in
Ae end-users.do not need to install any software on
their devices to access
er
these services.
e
in
10.4,3 Big Data Analytics
ng
. Big data is defined as a collection of data set whose volume is so large that it is
fE
diffcult to store, manage, process and analyze the data using traditional
database and data processing tools.
O
() Data cleaning,
le
as monitoring stations.
Sensor data generated by IoT system such weather
ad
)
sensors embedded in industrial and
Machine sensor data collected from
()
iln
bands.
tracking of vehicles.
(iv) Data for location and
generated by IoT system
monitoring systems.
(v) Data generated by retail inventory
1) Characteristics
Theunderlying characteristics of big dataincludes,
) Volume:
considered as big data. The
There volume of data to be
is fixed threshold for
no
difficult to store,
manage and
scale data that is
lerm big data
is used for massive data
processing
architecture.
Process using traditional data bases and
<br>
(ii) Velocity:
Velocity of data refers to how fast the data is generated and how frequently it
varies. Modern IT, industrial and other systems are generating data at
increasingly higher speeds.
g
(ii) Variety:
in
Variety refers to the forns of the data. Big data comes in various forms such as
er
structured or unstructued data including text data, audio, video and sensor data.
e
10.4.4 Communication Protocols
in
Communications protocols form the backbone of loT system which enables
ng
network connectivity and coupling into the applications.
fE
Communications protocols allow devices to exchange data over the network.
These protocols define the data exchange formats, data encoding, addressing
O
schemes for devices and routing of packets from source to destination.
e
This protocol also support sequence control that helps in ordering the packets to
g
determine the lost packets, flow control that helps in controlling the sender data
le
rate with receiver data rate tp avoid the network overwhelmed and retransmission
ol
of lost packets.
C
watches, digital cameras, vending machines etc. These devices form an integral
part of IoT systems.
fThings
10.23
Lighting
Control Smartphone
Controlled alerts
appliances
Energy
management
g
in
Controlled
iigations
e er
in
ng
Temperature
Control Alarm
Motion detection
|Keyless entry fE control
O
1) Smart Lighting
energy by adapting the lighting to the
C
users to
uses loT-enabled sensors, bulbs, or adapters to allow
O Smart lighting
iln
Key Lighting:
Benefits of loT-Enabled Smart
LED bulbs.
Save money byswitching more energy-efficient
to control or
are off when they
aren''t needed
Set schedules lights
to ensure that measure when you re away from
schedules remotely
as a security
,oMng
home or out
oftown. rooms or individual bulbs.
Adjust the color lights
of in diferent
or dimness
<br>
g
in
Smart applianices make the management easier and also provide status
er
information to the user remotely.
e
a What are Smart Appliances?
in
Any appliance can become smart with wireless connectivity and sensors that
ng
allow remote control or autonomous operation through user
input, scheduling,
or Artificial Intelligence and Machine fE
Learning (A/ML).
Sensors combined with wireless connectivity can
provide the end-user with
O
information about the appliance's usage,
temperature, service life,
e
Ø Advantages
le
leaving home.
(3) Intrusion Detection
iln
Things
ernet of
|10.25
by
Alerts raised Smoke detectors can
be in the form of
system. Gas detectors can detect signals to fire alarm
the presence of harmful gases
monoxide (CO) and Liquid such as carbon
i Petroleum Gas
(LPG).
Asmart smoke / gas detector can
o raise alerts in human voice describing
dhe problem where
is, send an SMS or email to user
the or the local fire safety
g
department and provide visual feedback on status.
its
in
er
10.5.3 Snmart Cities
e
Smart Parking
)
in
o
ng
An loT-based smart parking system provides
real-time data on parking space
availability and payments which' is a helpful tool for -businesses
fE and
Consumers.
O
o Smart parking is also known as a connected parking system which is a
centalized management system that allows drivers to use a smartphone app to
g e
M Features:
ol
C
2) Smart Lighting
Ta
g
in
(4) Structural Health Monitoring
er
Structural health monitoring systems uses a network of sensors to monitor the
e
vibrations levels in the structures such as bridges and buildings. The data
in
collected from these sensors is analyzed to assess the health of the structures.
ng
By analyzing the data it is possible to detect cracks and mechanical
fE
breakdowns, locate the damages to a structure and also to calculate the
remaining lifetime of the structure. Using such systems advance warning can,
O
be given in the case of imminent failure of the structure.
e
(5) Surveillance
g
le
comprising
a
of large number of distributed and Internet connected video surveillance
C
cameras.
u
ad
things 10.27
aernet of
Environment
10.5
Weather Monitoring
g
to cloud based applications and storage back-ends.
in
The data collected in the cloud can then be analyzed and visualized by cloud
er
based applications.
e
in
Air & Noise Pollution Monitoring
ng
o Air and sound pollution is a growing issue in these days. It is necessary to
monitor the air quality and keep it under control for a better future and healthy
fE
living for all.
O
us to
o An airquality as well as sound pollution monitoring system that allows
e
monitor and check live air quality as well as sound pollution in particular
g
nodes
loT based forest systems can use a number of monitoring
fire detection node collects
deployed a forest. Each monitoring
at a different locations in
temperature, humidity and
measurements on ambiet conditions including
lightlevels.
<br>
g
can cause extensive damage
River flood
rainfall which cause the
in
flood occurs due to continuous
and human life. River
er
to increase rapidly.
river levels to rise and flow rates
e
flow
can be given by monitoring the water level and
Early warnings of floods
in
ng
rate.
uses a number of sensor nodes that
IoT based river flood monitoring system
fE
can monitor the water level using ultrasonic
sensors and flow rate using the
a sensor nodes is aggregated
flow velocity sensors. Data from number of such
O
in a server or in the cloud.
g e
10.5.6 Energy
le
that collects and analyzes the data captured in near real-time about power
u
to utilities, their suppliers, and their customers on how best to manage the
m
power.
Ta
hings 10.29
ernet of
Renewable Energy Systems
as
Due to thevariability in the output from renewable energy Sources such
solar and wind, when integrating them into the grid can cause grid stability
g
Variable output produces local voltage swings that can impact power quality.
in
can measure
For loT based systems, that are integrates with the transformers
er
the electrical variables and calculate how much
power is fed into the grid.
e
one solution is to simply cut off the
o' To ensure the grid stability,
in
overproduction.
ng
can be used to regulate the
o For wind energy systems, closed-loop controls
voltage at the point
fE
of interconnection which coordinate
wind turbine outputs
(3) Prognostics
e
information is
failures. In systems such as power grids, real-time
machines
sensors called Phasor Measurement
u
specialized electrical
collected -using
ad
Sensing
m
Ta
Prognostics and
Diagnosis
Systems Health
Prognostics Management (PHM)
Management
g
in
10.5.7 Retail
er
(1) Inventory Management
e
Inventory management for retail has become increasingly important in the
in
recent years with the growing competition. While over-stocking of products
ng
can result in additional storage expenses and risk.
fE
loT systems using Radio Frequency Identification (RFID) tags can help in
inventory management and maintaining the inventory levels.
O
RFID tags attached to the products that allow them to be tracked in real-time
e
touching them.
Customers can store the credit card information in their NFC-enabled smart
m
sale terminals.
NFC maybe used in combination with Bluetooth, where NFC
initiates initial
pairing of devices to establish a Bluetooth connection while
the actual data
transfer takes place over the Bluetooth.
Internet ofThings
10.31
Smart-phone applications that communicate
with smart vending machines
llow user preferences to be remembered
and learned with time.
Sensors in a smart vending machine
monitor its operations and send the
to the cloud which can be used data
for predictive maintenance.
g
10.5.8 Logistics
in
er
(1) Route Generation & Scheduling
e
Modern transportation systems are driven by the data collected from multiple
in
Sources which is processed to provide a new services to the stakeholders.
ng
It collects large amount of data from various sources and processing the data
fE
into useful information. The data-driven transportation systems can provide
new services such as advanced route guidance and dynamic vehicle routing.
O
o Route generation and scheduling systems can generate end-to-end routes using
e
g
sub-systems and diagnostic trouble codes which allow rapidly identifying the
in
faults in the vehicle.
e er
10.5.9 Agriculture
in
(1) Smart Irrigation System
ng
Smart irrigation systems can improve crop yiclds while saving water. Smart
fE
irrigation systems use loT devices with soil moisture sensors to determine the
amount of moisture in the soil and relcases the water flow through the
O
irigation pipes only when the moisture levels goes below a predefined
e
threshold.
g
le
for the
growth ofplants.
m
10.5.10 Industry
Ta
ofThings
iernet 10.33|
lndoorAir Quality Monitoring
e
Monitoring indoor air quality in factories
is important for health and safety of
IoT based gas
the workers. monitoring systems can
help in monitoring the
indoor air quality using various gas sensors.
g
Health. Fitness Monitoring
in
&
er
Wearable IoT devices that allow non-invasive and continuous
monitoring of
physiological parameters can help in continuous health and fitness monitoring.
e
in
These wearable devices may be in various forms such as belts and wrist
ng
bands.
The wearable devices form a type of wireless sensor networks called body
fE
area networks in which the measurements from a number of wearable devices
O
are continuously sent to a master node such as a smart-phone which then
sends the data to a server or a cloud-based back-end for further analysis.
g e
ANSWERS
10.6 TWO MARKSOUESTIONS AND
ad
g
self-configuration?
in
4. Why do loTsystens have to be self-adapting and
er
(i) Self-Adapting
the
IoT devices and systems may have the capability to dynamically adapt with
e
in
changing contexts and take actions based on their operating conditions, user's
ng
* context, or sensed environment.
(ii) Self- Configuring fE
IoT devices may have self-configuring capability that allow a large number of
O
devices to work together to provide certain functionality.
List the characteristics of
IoT.
e
5.
g
(ii) Self-configuring.
C
The network layer is responsible for sending of IP datagrams (packets) from the
Ta
ternet of
Things 10.35|
g
layer protocol and encapsulated in the transport layer protocol which provides
in
connection or transaction oriented communication over the network.
er
9. What is HTTP?.
e
in
The Hypertext Transfer Protocol (HTTP) is an application layer protocol that
a
ng
forms the foundation of World Wide Web (WWW). This protocol follows
request-response model where a client sends request to the server using the
HTTP commands.
fE
O
10. What do you mean by logical design of an loT?
the entities
of an loT system refers to abstract representation of
e
an
Logical design
g
implementation.
ol
loT system.
C
of
II. Name the functional blocks
The functional blocks of IoT system are,
u
ad
) Device.
(i) Communication.
iln
(ii) Services.
m
(iv) Management.
Ta
(v) Security.
(vi) Application.
12. What
is request-response model?
model in which the client sends request to
Request-response a communications
is requests.
the Server
and the : server responds to the
l3, Name models used in loT.
the communication
) Request-response model.
Publish-subscribe model.
<br>
g
consumners. not aware of the
in
Consumers subscribe to the
er
topic that are managed by
broker receives the data for a the broker. Once the
topic from the publisher,
e
subscribed consumers. it sends the data to all the
in
ng
15. Define pusl-pull
model.
Push- pull is a communication fE
model in which the data producers
in to the queues and the consumers can pushes the data
pull the data from the queues.
O
16. What do you mean by
REST based API?
Representational State Transfer
e
Big data is defined as a collection of data set whose volume is so large that it is
difficult to store, manage, process and analyze the data using traditional database
and data processing tools.
<br>
1hings
ternet ef 10.37|
Name.the steps
involved in big data analytics.
20
The following steps are involved in big data analytics:
() Data cleaning,
g
in
REVIEW QUESTIONS
er
10.7
e
1.
in
2 Mention the applications of loT.
ng
3 Discuss in detail about the characteristics of IoT.
Describe an example
of
C
model.
10. Describe an example
of
IoT service that uses WebSocket-based communication.
u
neat diagrams.
ad
() Cloud computing.
UNIT -IV
Chapter 11
g
in
MACHINE -TO- MACHINE (M2M)
e er
in
11,1 IoT AND M2M
ng
11.1.1 Introduction
fE
A Definition:
O
A Machine-to-Machine (M2M) connection is 'a connection between two
e
machines without any human interaction that is, it allows two devices to
g
le
communicate autonomously.
M2M devices can autonomously collect and transmit data, facilitating real
ol
industries.
u
and hardware over cellular or wired networks, while loT systems rely on IP
iln
Applications Domain.
<br>
Page 38 of 440
1l
M2M Wired
g
M2M Gateway Network
Devices Service
in
to
Consumer
er
Wireless
e
Network
in
ng
M2M
devices
domain
fE
Fig I1.1 M2M system architecture.
O
(i) Area Networks
e
The various communication protocols that can be used for M2M local area
ol
Gateways:
m
.
M2M Gateway
Ta
Virtual Node
Native Protocol
M2M Node Proxy
Protocol Translation
IP Routing
Virtual Node
Native Protocol
M2M Node Protocol Proxy.
Translation
g
protocols to/from Internet Protocol (IP),
in
er
M2M Core (or) Communication Network
e
The communication network can use either wired or wireless networks
in
use non-IP based communication
P-based) while the M2M area networks
ng
protocols that is, the M2M nodes within one network cannot communicate with
nodes in an external network. fE
(ii) M2M Applications
O
as enterprise applications,
The M2M data is gathered into point solutions such
or remote monitoring applications. M2M has
e
as
various application domains follows:
le
ol
Smart metering,
C
Home automation,
Industrial automation, and
u
ad
Smart grids.
iln
M2M
11,1,3Difference between IoT and
m
M2M
Sr.no IoT
Ta
Direct machine-to-machine
1 Internet-based connectivity. communication.
g
8 to-customer (B2C) types.
in
Machine normally
Many users can access at a time communicates with single
er
over internets. machine at a time.
e
It uses either proprietary or non
in
10 It uses IIP based protocols. IP based protocols.
ng
11.1.4 SDN and NFV for IoT fE
(1) Software-Defined Networking (SDN)
O
a Definition:
e
uses
Software-Defined Networking (SDN) is an approach to networking that
g
le
network.
This model differs from that of traditional networks, which uses dedicated
u
hardware devices (i.e., routers and switches) to control network traffic. SDN
ad
can create and control a virtual network or control atraditional hardware via
iln
software.
m
Fig 11.3 shows the architecture of SDN. The three layers in an SDN
architecture are,
Ta
() Application Layer
This layer contains applications, services running on
the network and decides
how the traffic should move in a network?
(ii) Control Layer
A SDN controller is the software that provides a centralized control over the
entire network. Network administrators use this controller to decide about data
<br>
ochine-1o-dMachine (M2M)
11.5
route based on the information from applications
packet
using the underlying
infrastructuress and handlethe traffic.
APPLICATION LAYER
g
Business Applications
in
(Northbound Interface)
er
CONTROL LAYER
e
SDN
in
(Control plane) Control
Software
ng
Network Services
(southbound Interface)
INFRASTRUCTURE LAYER
fE
Control Data Plane interface
(e.g., OpenFlow)
O
Network Device Network Device Network Device
g e
This layer contain networking devices such as switches, routers and the
ad
northbound
Southbound Application Program Interfaces (API) where the
Ta
architectures are,
Ine limitations of the conventional network
Complex
network devices
to improve link speeds and
protocols being implemented
More
and more
reliability.
<br>
g
manage network
Computing environments require highly scalable and easy to
in
architectures with minimal manual configurations. But in conventional networks
er
all are manual configurations.
e
SDN attempts to create a network architecture that is simpler, inexpensive,
in
.
scalable and easy to manage.
ng
M SDN Benefits: Advantages: Key-elements fE
(i) Direct Programmability:
O
SDN network policy is directly programmable because the control functions are
e
The SDN controller software that maintains a global view of the network, which
appears to applications and SDN network policy as a single and logical switch.
u
ad
With a SDN, administrators can configure the network services and allocate
virtual resources to change the nctwork infrastructure in real time througu
one centralized location.
<br>
Machine-1o-Machine (M2M)
11.7
This allows network administrators to optimize the flow of data through the
network and pioritize applications that require more availability.
g
southbound protocol defines the communication between an SDN controller
in
and the network device/agent such as switch.
er
.
The SDN controller takes the information from the applications and converts
e
them into flow entries, which are fed to the switch via OF. It can also be
in
used for monitoring switch and port statistics in network management.
ng
The term “switch" denotes any network device capable of using OF protocol.
fE
The controller can add, update, and delete flow entries in flow table.
O
SDN Controller
g e
OpenFlow
le
Protocol
ol
Channel
u
ad
Pipeline
iln
Flow Table
Flow Table
m
OpenFlow Switch
Ta
a Definition:
to the use of virtual
The term "Network Functions Virtualization" (NF) refers
are act
machines in place ofphysical network appliances. The virtual machines
load
as a hypervisor to operate networking sofiware and procedures like
g
in
balancing and routing by virtual computers.
er
a Hypervisor:
e
A hypervisor is a software that you can use to run multiple virtual machines
in
on a single physical machine. Every virtual machine has its own operating
ng
system and applications.
fE
The hypervisor allocates the underlying physical computing resources such as
CPUand memory to individual virtual machines as required.
O
M Advantages of NFV: Need of NFV
g e
services from the specialized hardware like routers and firewalls. This
ol
eliminates the need for buying a new hardware and network operations can
C
Virtualization Layer
jlachine-To-Machine (M2M)
11.9
With this, it is possible to
deploy network
components in a matter of hours
onnosed to months as with conventional
as networking. Furthermore, the
virtualized. services can run on less expensive
generic servers.
Fig 11.5 shows the NFV architecture and the key elements are as follows:
g
Virtualized NetworkFunction (VNF): Applications
)
in
VNF is a software implementation of a network function which is capable
of
er
running over the NFV Infrastructure (NFV).
e
Software delivers many forms of network functionality such as virtualized
in
network functions by substituting for the hardware elements for a
ng
conventional network design.
(ö) NEV
fE
Infrastructure (NFVI): Centralized Virtual Network Infrastructure
O
The foundation of an NFV infrastructure can be a hypervisor that abstracts
the resources for computation, storage, and networking that are virtualized.
g e
the
software resources that support the infrastructure virtualization, and
u
2
m
11,2.1 Need
for IoT Systems Management
Ta
0 Automating configuration,
) Improved reliability,
() Multiple
system configurations, and
() Retrieving
and reusing
configurations.
<br>
g
in
and delete configurations network devices.
of
er
Standard Application
netvork devices for the NMS to manage the devices using NETCONF.
e
in
NETCONF uses Extensible Markup Language (XML)-based data encoding for
ng
the configuration data and protocol messages, and uses a simple Remoe
Procedure Call (RPC) mechanism to implement the communication between a
fE
client and a server.
O
A client can be a script or an application running on an NMS. A server is
typically a network device.
g e
.
le
purposs.
M
m
Advantages
Ta
tachine-To-Machine (M2M)
11.11
g
Basic Network Architecture of NETCONF
in
)
er
A
NETCONF system contains atleast one NMS that manages nctwork-wide
e
devices. Fig l1.6 shows the basic nctwork architccture of
NETCONF.
in
NETCONF Server
ng
fE
O
NETCONF Client
e
IP Network
g
le
NMS
ol
C
u
ad
SSH
iln
architecture of NETCONF
Fig I1.6 Basic network
m
g
notification mechanism. This allows the client to learn the status of the
in
managed device.
er
(2) Establishing a NETCONF Session
e
The NETCONF client and server uses the RPC mechanism to communicate
in
with each other. The communication is allowed only after a secure and
ng
connection-oriented session that is established between them.
fE
The client sends an RPC request to the server, and the server returns .a reply
to the client after processing that request.
O
NETCONF Client NETCONF Server
g e
le
ol
Machine-1o-Machine (M2M)
11.13
A
client establishes a Secure Shell (SSH)
connection with a server,
and then establishes a NETCONF session
with the server once the
authentication and authorizations are
complete:
g
Gi) The client sends one or more RPC requests to the server.
in
The following lists some request examples:
er
Modify and commit the configuration.
e
in
Query the configuration data or status.
ng
Perform the maintenance operations on the device.
(iv) The client terminates the NETCONF session. fE
(v) Finally, the SSH connection is terminated.
O
e
YANG Module
iln
Header
revision)
(.,
m
includes
Ta
Import and
Type definitions
operational
Configurational and
declaration
data
notification
Action (RPC) and
declarations
YANG module
Fig 11.8
<br>
g
can be represented as groupings.
types. More complex reusable data structures
in
YANG is gradually becoming a mainstream data description
specification in the
er
all define their
industry. Standards organizations, vendors, carriers, and OTTs
e
in
own YANG models.
The YANG model is integrated on the devices, which function as the servers.
ng
Network administrators can use NETCONF or RESTCONF to centrally manage,
fE
configure, and monitor various YANG-capable network devices, simplifying
network O&M (operations & maintenance) and reducing O&M costs.
O
g e
le
client
RS RESTCONF
client
u
ad
iln
Network
SSH
m
HTTPS
Ta
YANG module can import definitions from other modules. Constraints can be
defined on the data nodes, e.g. allowed values. YANG can model both the
configuration data and state data usingthe'config' statement.
Element Description
g
Module YANG constructs a data model as module. The module
in
name is the sáme as the YANG file name.
er
reference
A module can import data from other modules and
e
data from sub modules,
in
a unique URO.
Namespace of the module, which is globally
ng
Namespace
Namespaces are used during XML encoding of data.
Prefix
fE
Abbreviation of a namespace, which must be unique.
O
YANG belongs.
Organization Name of the organization to which
module developer.
Contact information of the YANG
e
Contact
g
Description
YANG module, providing the
Version information of the
ol
Revision
the module.
version editing history of
C
Container
a sequence of list entries.
ad
used to define
List List node, or a
contains simple data such as an integer
Leaf node,which
iln
Leaf
character string.
m
of lhe YANG
model
Elements
Fig 11.10
Ta
NETCONF-YANG
Managements with
11.2.4 IoT Systems
device management with
approach of IoT
Fig 11.11 shows the generic' as follows:
contains various components
NETCONF-YANG which
W Management System:
NETCONF messages to
send
The managemen system to
Operator uses a
information and notifications from
receives state
configure the IoT device and
he device as NETCONF messages.
<br>
g
Management System
in
e er
NETCONF
in
ng
NETCONF Server
fE
Transaction Rollback
Management
Manager Manager
O
API
e
Authentication,
g
Manager
|Auditing Modules
ol
C
Modules
ad
iln
loT Device
Applications
m
Maaged
Objects (Status, Statistics,Performance,
Alarms,Countors)
Ta
11.17
Transaction Manager:
Rollback<Manager:
g
Rollback manager
is responsible
for generating
all the transactions necessary to
in
a
ollback cúrrent contiguration to its original state.
er
Data Model Manager:
e
Itkeens track of all the YANG data models and
in
the corresponding managed
ng
objects and also keeps track of the aplications which provide data for cach pat
of a data model.
Configuration Validator:
fE
i)
O
a transaction would
It checks whether the resulting configuration after applying
be a valid
e
configuration.
g
data.
This database contains both the configuration and operational
ol
MiljConfiguration API:
C
g
Purpose & Requirements
in
Define Purpose & Requirements of loT system
e er
Process Model Specification
in
Define the use cases
ng
Domain Model Specification
fE
Define Physical Entities, Virtual Entities, Devices, Resources and Services in the loT system
O
Information model specification
Define the structure (e.g.relations, attributes)of all the information in the loT system
g e
le
Service Specifications
Map Process and Information Model to services and define service specifications
ol
C
Application Development
Develop Applications
Achine-To-Machine (M2M)
11.19|
Process Specification
Step2:
The second step is to define the process specification.
In this step, the use
aases of the loT system are
formally based on and derived from the purpose
and requirement specifications.
g
The domain model describes the main concepts, entities and objects in
the
in
domain of loT system to be designed.
er
Domain model defines the attributes of the objects and relationships between
e
the objects, provides an abstract representation of the concepts, independent of
in
any specific technology or platform.
ng
Step 4: Information Model Specification
fE
The information model defines the structure of all the information in
an
represented or stored.
O
IoT system. It does not describe how the information is
Service Specifications
e
Step 5:
system, service types,
g
the Functional
This step describes Groups (FGs).
various Functional
m
grouped into
the loT systems for interacting with instances of
provides functionalities
Each FG either information related to these
Ta
g
in
or by a single freelance developer.
er
Code
Development
e
in
&
Design & Testing
ng
Prototyping Optimization
fE
The process of
O
Planning & APP
Research
Release &
Development Maintenance
g e
11.4.1 Introduction
m
of twomain parts:
(i) Reference architecture, and
(ii) Reference model.
reference model is a model that describes
A
1.21
Architccture Reference
Model(ARM)
g
guidos
in
Unifad steer
loT Reference
er
Requirements
Architecturo
e
extrapolate guidos wth
in
Best Practices
Business Scenarios,
ng
kppication
existing architecturcs& defino Compant
specific
Domain-Spccifc
stakcholders Requzements
Architectures
fE
O
Steps in order to crcate an ARIA Stops to uso ARM
g e
& Definition:
u
& Benefits
Ta
a
A reference architecture serves as standardized blueprint that provides
a
Application'
g
Configuration
Composition
Process Execution
in
Key Exchange &
Fault Service VE & loT Management
er
Orchestration Service Monitoring
Reporting Trusrt &
e
Service VE Reputation
Member Choreography Resolution|VE Services
in
Identity
State loT Service Management
ng
loT Service
Resolution
Authentication
End to End
fE
Communication
Network Hop to Hop
|Communication Communication Communication
O
Device
g e
three views:
(i) FunctionalView
C
achine-1o-Machine (M2M)
11.23|
The software applications ór
services that utilize
the processed loT data
to provide specific functionalities.
g
the (if needed) further to
in
the Internet.
. The
er
Network Functional Components (FC)
is responsible for message
e
routing & forwarding and the necessary translations
of various
in
identifiers and addresses.
ng
(i) loT Service Functional Group
i
fE
The IoT Service FC is a collection of service implementations, which
interface the related and associated resources.
O
(iv) Virtual Entity (VE) Functional Group
g e
modeling a
(a) The process modeling FC provides the right tools for
loT-related services.
iln
services.
the requests coming from loT
The service orchestration FCresolves
concrete loT services that fulGl!
process execution FC or user into the
the requirements.
<br>
g
in
(vi) Security Functional Group
er
The Security FG contains the necessary functions for ensuring the
security and privacy of an loT system.
e
in
The identity. management FC manages the different identities of the
ng
involved Services or Users in an loT system.
fE
The authentication FC verifies the identity of a user and creates an
The key exchange & management is used for setting up the necessary
ol
levels.
iln
Machine-To-Machine (M2M)
11.25|
g
The reporting FC is responsible for producing compressed reports
about
in
the system state based on input from FCs.
er
11.4.3 IoT Reference Model: Domain Model
e
in
loT loT Trust,
ng
Communicational Security and
Model Privacy Model
fE
O
loT Comm.FG} Sec.
Functional
FG
Model
g e
Informationan handled by
le
Functional Components
ol
Concepts as
C
loT Information
foundations of
Model
Functional Groups
u
ad
reference model
Fig l1.16 loT
sub-models. The
describes the domain using a number of
A Teference model
main concepts and the
attributes of the
domain mnodel .captures the basic
domain model also serves as tool for
a
A
g
User.
in
Physical entity.
er
Virtual entity.
e
Augmented entity.
in
Devices.
ng
Resource.
Service. fE
# In the IOT domain model, devices are technical artifacts that behave as interfaces
O
between the digital (Virtual Entity) and physical (Physical Entity) world.
Therefore, devices must have capabilities (like storage, computation &
e
resources available in devices also play a very critical role in the overal
le
operation.
ol
Virtual Entity in the IoT domain model is the "Thing" in the Internet
of
u
of
it is presented using Unified Modeling Language
(UML) diagrams.
iln
Virtual Entity
m
Ta
is association with
Service
exposes
Resource hosts
Device
g
interfaces, and interactions between the components.
in
The functional view is typically derived from the functional model in
er
conjunction with high-level requirements.
e
Application
in
ng
Organisation
loT Business Process
Management fE
Management
O
Virtual Entity Security
Service
e
loT Service
g
le
ol
Communication
C
Device
u
ad
can be done.Communication
helps in understanding how communication works
Ta
model communication.
models try to capture, explain, simplify, and then
(4) Trust, Security & Privacy Model
(i) Privacy
privacy model
User privacy is an utmost importance for LoT system. The IoT-A
depends on the following functional components:
Identity management,
Authentication,
<br>
Authorization, and
Trust & Reputation
(ii) Trust
entity makes
Generally, an entity is said to 'trust' a second entity when the first
g
as the first entitu
the assumption that the second entity will behave exactly
in
er
expects.
e
(ii) Security
in
focuses
The security model for loT consists of communication security that
ng
mostly on the confidentiality and integrity protection of interacting entities.
Note
m
11.5.1 MQTT
a Definition:
4
MQTT is primarily used for machine-to-machine
(M2M) communication or
Internet of Things types of connections.
g
Publish
in
Client
Message
er
Message
Publish
e
Suscriber
Publish Message
in
MQTT
Client
BROKER
ng
Message Publish
Message Suscribér
Publish
fE
O
Client
g e
brokers as below:
C
u
0) MQTT client
ad
acts as a receiver.
if it is receiving messages, it can be
using MQTT over network
a
Ta
communicates
Basically, any device that
called an MTT client
device.
11.30|
Embedded Systems and loT Design
g
(ü) MQTT connection
in
Clients and brokers begin communicating by using an MQTT connection.
er
Clients initiate the connection by sending a CONNECT message to the MQTT
e
broker. The broker confirms that a connection has been established by
in
responding with a CONNACK message. Clients never connect with each
ng
other, they connects only with the broker.
Advantages
fE
O
The advantages of MQTT are,
(6) Lightweight and efficient
g e
MQTT implementation on the loT device requires minimal resources, so that it.
le
can even be used on small microcontrollers. MQTT message headers are also
ol
(ii) Scalable
u
(ii) Secure
MQTT makes it easy for developers to encrypt messages and authenticate
m
(iv) Well-supported
Several languages like Python have extensive support for MQTT Protocol
implementation. Hence, developers can quickly minimal
implement it with a
coding on any type of application.
11.5.2 XMPP
4 XMPP is a short jorm for Extensible Messaging Presence Protocol.
protocol Jor streaming XML elements over a network in order to exchange
<br>
Mchine-To-Michine (M2M)
|11.31
Functions
% Requirements:
The following are the basic requirements of any Instant Messenger which are
g
fulfilled by XMPP:
in
A Send and receive messages with other users.
er
(Gi) Check and share presence status.
e
(i) Manage subscriptions to and from other users.
in
(v) Manage contact list
ng
() Block communications (receive message, sharing presence status, etc) to
specific users.
Decentralized:
fE
O
XMPP is based on client-server architecture, i.e. clients don't communicate
directly, they do it with the help of server as intermediary. It is decentralized
g e
means there is nó centralized XMPP server just like an email, anyone can run
le
A Addresses in XMPP
C
Client Client
stanza
stanza
Client Client
XMPP Component
g
routing capability. Gateways can cxist for purposes of translating between
in
foreign messaging domains and protocols.
e er
11.5.3 MODBUS
in
Modbus or MODBUS is a client/server, data communications protocol in the
ng
application layer of the OSI model. Itwas originally published by Modicon in
fE
1979 for use with its Programmable Logic Controllers (PLCs).
initiate a request and then wait for a response. The initiating device (the master)
g
Computer HMI
u
ad
request
PLC
PLC
Modbus server
Modbus server
ichine-To-Machine
(M2M)
11.33|
Function
Code Function -Specific Data
1
0
253 maxX
g
Fig l1.22 Modbus PDU
in
The packet size is limited to.253 bytes, the
er
# most common
function codes can
ransfer between 240 and 250 bytes of actual data from the slave data model,
e
depending on the code.
in
ng
* Modbus uses the Transmission Control Protocol (TCP), which provides
connection-oriented communication, error detection, and flow control.
fE
Advantages
O
The advantages of Modbus are,
e
a
well as to communicate with each other in reliable, priority
other devices,
m
driven fashion.
Ta
A
T BACNet Network
CAN Network
W
A
Y
g
Node Node
Node
in
Node
er
Fig 11.23 CANbus with BacNet
e
and converts it to BACnet IP
The gateway reads the data from the CAN channel
in
message IDs, and the
format. The messages can be filtered by their CAN
ng
iñcoming bytes of data can be received.
a
fE
The BACnet IP can be set up as client, and data from the
CAN interface can be
O
written to the BACnet server.
BACnet client devices can read data from the gateway which- we received from
g e
Features:
C
Machine-To-Machine (M2M)
11.35
() Communication Networks, and
(i) Applications Domain.
3. List the applications of M2M
g
in
(ii) Home automation,
er
(iii) Industrial automation, and
e
(iv) Smart grids.
in
4. Give the comparisons between IoT and M2M.
ng
Sr.no IoT fE M2M
1 Internet-based connectivity. Direct machine-to-machine
O
communication.
. Wide range of devices and Specific applications and
2
e
industries. industries.
g
3
networks. internet connection.
ol
$. Define SDN.
Software-Defined Networking (SDN) is an approach to networking that uses
software-based controllers or Application Programming Interfaces (APIs) to
communicate with underlying hardware infrastructure and direct traffic on a
network.
O., Name the layer used inSDN.
The three layers used in SDN architecture are,
() Application layer,
<br>
g
northbound API communicates
Application Program Interfaces (APIs) where the
in
between the application and the control
layers and the southbound API
er
communicates between the infrastructure and control layers.
e
of conventional network architectures.
in
8. Give the limitations
ng
The limitations of the conventional network architectures are,
(i) Complex network devices fE
More and more protocols being implemented to improve link speeds and
O
reliability.
(i) Management overhead
e
vendors.
ol
Machine-To-Machine (M2M)
137
(G1) Monitoring operational and statistical data,
g
(vi) Retrieving and reusing configurations.
in
er
12. Define NETCONE.
e
The Network Configuration Protocol (NETCONF) is network management
a
in
protocol allowing a Network Management System (NMS) to deliver, modify, and
ng
delete configurations of network devices.
()
le
cloud-based networks.
C
(ii) NETCONF uses XML encoding to define messages and uses the RPC
u
g
in
16. Define loT reference architecture.
er
An Io'T reference architecture serves as a foundational blueprint that outlines the
e
essential components and interactions within an loT system. It provides a solid
in
starting point for designing and implementing IoT solutions.
ng
17. What is domain model?
fE
A reference model describes the domain using a number of sub-models. The
domain model captures the basic attributes of the main concepts and the
O
relationship between these concepts. A domain model also serves as a tool for
e
g
21. What do you mean by XMPP?
in
XMPP is a short
form for Extensible Messaging
er
protocol for streaming Presence Protocol.
XML elements over a It's
e
messages and presence network in order to exchange
in
information in close to real
mostly used by instant messaging time. This protocol is
ng
applications like WhatsApp.
22. What is Modbus?
Modbus or MODBUS is a client/server
fE
data communications protocol
in the
O
application layer of the OSI model.
Modbus is a request-response protocol
implemented using a master-slave relationship.
g e
()
ad
systemn archtecture.
Mth a neat diagram, explin about M2M
Ta
g
12. Discuss about the
in
architecture.
13. With neat diagram, eyplain about IoT reference
er
reference model with neat diagram.
14. Explain in detail about the loT
e
15. Discuss about the various IoTprotocols.
in
16. Write a note on
ng
() MQTT.
(i) XMPP
fE
O
ge
le
ol
C
u
ad
iln
m
Ta
<br>
UNIT -V
Chapter 12
g
in
loT PHYSICAL DEVICES
e er
in
12.1 BASIC BUILDING BLOCKS OF AN IOT DEVICE
ng
4 An loT system comprises of four basic building blocks as,
() Sensors/ Actuators. fE
(ii) Processors,
O
(ii) Gateways, and
e
(iv) Applications.
g
le
Applications
ol
C
u
Gafeways and
ad
Communication
iln
m
Processors
Ta
Sensors and
Actuators
an IoT device
Fig 12.1 Basic building blocks of
0) Sensors:
Sensing
Sensors are the front end of the loT devices. They really mean "things" in loT.
lIt can
be either on-board of the loT device or attached to the device.
<br>
Actuators: Actuation
g
(ii)
of actuators attached to it„that allow
in
IoT devices can have various types
taking actions upon the physical entities in the
vicinity of the device.
er
an IoT device can turn an appliance
For example, a relay switch connected to
e
in
on/off based on the commands sent to the device.
ng
:
(ii) Processors Analysis & Processing
Processors are the brain of the loT system. The main job of the processor is to
fE
process raw data collected by the sensors and transforms them to some
O
meaningful information and knowledge.
Processórs are easily controlled by the applications and their one more
g e
The main task of gateway is to route the processed data that is, to connect one
u
network to another. Gateways are responsible for bridging sensor nodes with
ad
(v) Applications:
m
of the data
collected. Examples: Smart home apps, Security
system conrol apps and
Industrial control hub apps.
oTPhisical Devices
12.3|
Sensing/Actuation Data Analysis
Processing Communication
Module
Any object you Obtained
npow
g
in
Fig 12.2 IoT device modules
er
12.2 RASPBERRY Pi
e
Raspberry Pi is a series
af low-ost small Single-Board Computers (SBCs) with
in
the physical size
of a credit card developed in the United Kingdom by
ng
the Raspberry Pi Foundation in association
with the Broadcom.
Raspberry Piruns Linz operating system and can perform almost
fE
all tasks that
a normal desktop computer can do.
It also allows interfacing sensors and
O
actuators through the general purpose I/O pins.
e
port Port
display
m
Ta
port ports AV
412:4
g
a
(b) USB ports: These USB ports are used to connect the peripherals like
in
keyboard or mouse. The two black ports are USB2.0 and the two blue ports
er
are USB3.0.
e
in
(e) Ethernet port: This port connects the Raspberry Pi to a wired network.
ng
Raspberry Pi also has Wi-Fi and Bluetoth built in for wireless connections.
fE
(d) HDMI ports: The HDMI port on Raspberry Pi provides both video and
audio output to the external monitors. The raspberry Pi 4 features two micro
O
HDMI ports, allowing it to drive two separate monitors at the same time.
g e
() Camera module port: This port is used to connect the official Raspberry Pi
le
-USB port.
Ta
T PhysicalDevices
|12.5
12.4 LINUX ON RASPBERRY Pi
12.4.1 Introduction
.Linux is a powerful, open-source operating system
oomputers, servers,
based on Unix that is used for
mainframes, móbile devices,
and embedded devices.
Raspberry Pi supports various
g
flavors of Linux including:
in
0) Raspbian: Raspbian
Linux is a Debian Wheezy port optimized
for Raspberry
er
Pi. This is the recommended
Linux for Raspberry Pi.
e
fi) Arch: Arch is an Arch Linux port for AMD devices.
in
(i) Pidora: Pidora Linux is a Fedora Linux port optimized
ng
for Raspberry Pi.
(iv) RaspBMC:
An XBMC media-center distribution for Raspberry Pi.
(v) OpenELEC: fE
A fast and user-friendly XBMC media-center distribution.
(vi) RISC OS: A very
fast and compact operating system.
O
e
12.4.2 Installation
g
# Following are the steps for headless installation (without connecting any
le
https://www.raspberrypi.org/software/
u
ad
(i) After installing Raspberry Pi Imager, open it. The interface of Raspberry Pi
-Imager as shown below:
iln
m
Ta
Raspberry Pi
CHOOSE. SD CARD
CHOOSE OS
SDIALS
<br>
Operating System
g
in
Raspberry Pi 0S (32-b)
Apert of Debian with the Rsepbery Pi Oetktop (Recommended)
er
RAS 2921-91-11
e
in
Raspbomy A OS (oche)
Other Raspberry PA OS based images
ng
Other generel purpose 0S
Gther general purpose Operatng Systerre
(iv) Attach your micro SD card to computer and then click on Choose SD card
ol
erry PiImager y5
u
ad
iln
m
Raspberry Pi
Ta
Devices
oT Physical 12.7|
Now,click on Write button. Raspberry Pi Imager will download the official
()
Raspberry Pi OS online and then write it on to your SD card.
(vi) After the process of writing Raspberry Pi OS is over, open the SD card in
explorer. Create a file named wpa_ supplicant.conf in the SD card root
g
folder and insert the following text which include the password into that file
in
and save it.
er
Command Function Example
e
cd Change directory cd/home/pi
in
Show file contents cat file.txt
ng
cat
Is List files and folders Is/home/pi
locate Search for a file
fE locate file.txt
O
Isusb List USB devices Isusb
directory
g
le
transfer.
Raspberry Pi has serial, SPI and I2C interfaces for data
m
(i) Serial
Ta
Serial interface on Raspberry Pi has receive (Rx) and transmit (Tx) pins
for
TX Rx
Rx Tx Device
RPI
GND GND
interface:
(a) Master. In Slave Out (MISO): Master line for sending data to the peripherals.
g
a
(b) Master Out Slave In (MOSI): Slave line for sending data to master.
in
(c) Serial Clock (SCLK): Clock generated by master to synchronize data
er
transmission.
e
(d) Chip Enable 0(CEO): To enable or disable devices.
in
(e) Chip Enable 1(CE1): To enable ordisable devices.
ng
MOSI
fE
MISO
O
Master SCLK
CE 1
e
CE O
g
le
ol
SCLK
MISO MOSI CE SCLK MISO MOSI
C
Slave 1 Slave 2N
u
ad
hardware modules.
I2C interface allows synchronous data
transfer with just two pins: SDA (data
Ta
SCL
oT Physical Devices
12.9
12.6 PROGRAMMING RASPBERRY PI WITH PYTHON
12.6.1 Controlling LED with Raspberry Pi
.Bo 12.7shows the schematic diagram
of connecting an LED to Raspberry Pi. In
this example, the LED
is connected to GPIO pin 18, but you can connect
the
LED to any other GPIO pin as well.
g
in
er
18 J
e
P
in
W
E
ng
D
Raspberry Pi fE
O
Fig 12.7 Controlling LED with Raspberry Pi
e
on
g
>
ol
Secho 18 /sys/class/gpio/export
C
$cd /sys/class/gpio/gpio18
u
>
echo out direction
iln
#Turn LED on
m
>
Secho 1 value
Ta
GPIO as GPIO
import RPi
Import time
(GPIO.BCM)
GPIO. setmode
g
GPIO.OUT)
in
GPIO. setup (18,
er
While True:
(18, True)
e
GPIO. output
in
time.sleep ( 1 )
ng
GPIO.output (18, False)
time.sleep ( 1) fE
O
12.7 CASE STUDIES
e
nos: 10.23-10.25.
Refer Unit-4, Chapter -10, Page
le
12.7.3 Environment
ad
12.7.4 Agriculture
Refer Unit-4, Chapter -10, Page nos: 10.33
m
Ta
Physical
Devices
oT 12.11|
n modules
List the functional usedin loT device.
AnIoT device can consists off some modules based on their functional.attributes:
Sensing/ actuation ; module,
g
(i)
in
(iv) Application module.
er
3. What is Raspberry Pi?
e
Raspberry Pi isa series of low-cost small Single-Board Computers (SBCs) with
in
the physical size of a credit card developed in the United Kingdom by
ng
the Raspberry PiFoundation in association with the Broadcom.
a
Raspberry Piruns Linux operating system and can perform almost all tasks that
fE
sensors and actuators
normal desktop computer can do. It also allows interfacing
O
through the general purpose I/O pins.
4.- Name the interfaces used inRaspberry Pi.
g e
The following interfaces are used for data transfer in Raspberry Pi:
le
) Serial interface.
ol
(12C) interface.
(i) Inter-Integrated Circuit
u
g
ET3491 EMBEDDED SYSTEMSAND
IOT DESIGN
in
REGULATIONS 2021
er
Time : Three Hours
Maximum: 100
e
Marks
in
Answer ALL questions
ng
PART A - (10 x 2 = 20 marks)
1.
fE
State any fourinbuiltfeatures of 8051 microcontroller.
O
The features of 8051 microcontrollers are as follows:
4KB bytes on-chip program memory (ROM).
e
: SWAPA.
Mnemonic
Swap nibbles within the accumulator.
iln
Function
m
Flags : None
:(D3 –D0) >
(D7-D4)
Ta
Operation
DO
D7 04 03
Lower
Higher nibble
nibble
<br>
g
SWAP.
A
;A=95H (1001
in
3. Define requirement in embedded design.
er
user wants and expects
Requirement is a plain language description of what the
e
tòget. It may be developed in several ways:
in
Talking directly to customers,
ng
Talking to marketing representatives, and
fE
Providing prototypes to the users for comment.
O
4. Defne ARM processor.
An Advanced RISC Machine (ARM) processor is one of family of Central
a
e
Processing Units (CPUs) based on the Reduced Instruction Set Computer (RISC)
g
ARM processors are used in music players, smatphones, wearables, tablets, and
ol
other consumer electronic devices. This needs a very few instruction sets and
C
transistors.
u
5. What is scheduling?
ad
The way that time is allocated between tasks is termed as "scheduling". The
iln
scheduler is the software that determines which task should un next. The logic
of the scheduler and the mechanism that determines when it should be run is the
m
scheduling algorithm.
Ta
6. Define Semaphore.
Semaphores are just riormal variables that are used to coordinate the activities
of multiple processes in a computer system. They are used to enforce mutual
exclusion, avoid race conditions, and implement synchronization between
processes.
7. What is the role of "things" and Internet in IoT?
The Internet of Things (IoT) describes the network of physical objects which a
oolther
considered as "things" that are embedded with sensors, software, and
<br>
technologies for the purpose of connecting and exchanging data with other
devices and systems over the Internet.
g
in
Widerange of devices and Specific applications and
2
er
industries. industries.
e
Uses the Internet and ccllular Uses cither an Intemet or non
in
3
networks. internet conncction.
ng
4 Cloud-based storage analytics. Local data proccssing.
Most scalable.
fE
Less scalable.
O
6 Efficient resource utilization. Optimizcd resource utilization.
e
supports point-to-point
g
It
lt supports cloud bascd
7 communication
le
communication.
ol
as,
An loT system comprises of four basic building blocks
u
() Sensors/ Actuators.
ad
(i) Processors,
iln
(iv) Applications.
Ta
() Serial interface.
(ii) Serial Peripheral Interface (SPI).
(11) Inter-Integrated Circuit (12C)
interface.
<br>
g
(b)Explain the function of DJNZ instruction. (13)
in
Ans: Refer unit-1, chapter -2, page nos: 2.48 -2.49.
er
12. (a) Discuss in detail about the basic steps involved in embedded system design
e
(13)
in
process.
Ans: Refer unit-2, chapter -4, page nos:4.2 -4.18.
ng
[OR]
13. (a)
g
[ORJ
C
(b) Explain in detail about Rate Monotonic Scheduling with an example. (13)
[OR]
Ta
(6) With a neat diagram, explain about M2M system architecture.. (13)
Ans: Refer unit-4, chapter -11, page nos: 11.1– 1l1.3.
15. (a) Explain in detail about the basic building blocks of an IoT device. (13)
Ans: Refer unit-5, chapter -12, page nos: 12.1 – 12.3.
[ORJ
(b) With neat diagram, explain about Raspberry Pi board. (13)
g
in
(15)
er
Ans: Refer unit-2, chapter -6, page nos: 6.15
-6.22.
e
in
ng
fE
O
g e
le
ol
C
u
ad
iln
m
Ta
<br>
g
in
REGULATIONS 2021
er
Time :Three Hours Maximum: 100 Marks
e
in
Answer ALL questions
PART A - (10 x 2 =20 marks)
ng
1. Compare microcontrollers and microprocessors in system design.
Sr.NO Microprocessor
fE Microcontroller
The functional blocks of
O
1. The microcontroller includes the
microprocessor are the ALU, functional blocks of a
e
data between memory and CPU. move data between memory and
u
CPU.
are
ad
instructions. instructions.
Ta
Flags:
None
(DPTR))
Operation: (A) E (A) +
This instruction moves a byte of data
that is located in program (code)
g
ROM into register A. This allows us to put
strings of data, such as look
in
up table elements, in the code space
and read them into the CPU.
er
The addressof the desired byte in the code space (on-chip ROM) is
e
in
formed by adding the original value of the accumulator to
the 16-bit
ng
DPTR register.
Example: fE
Let (DPTR) = 1000H, (A) = 8H
O
A+ DPTR 8H + 1000H, the contents of memory location (1008H) = 22H.
e
() Optimizing performance,
u
RISC (Reduced Instruction Set Computing) and CISC (Complex Instruction Set
Computing) are two different approaches to designing the instruction set of a
Ta
Ses many memory references process complex instructions. RISC has faster
processing, while CISC has slower processing.
<br>
g
and use the CPUuntil it releases it.
in
communication.
Name the two modes used in interprocess
er
6.
other
are two modes through which processes can communicate with each
e
There
in
i) Shared memory, and
ng
(ii) Message passing.
The shared memory region shares a shared
fE
memory between the processes. On
The applications of loT span a wide range of domains which includes homes,
le
health.
C
8. Define SDN.
u
network.
m
with
Raspberry Pi is a
low-cost small Single-Board Computers (SBCs)
series of
the physical size of a credit card developed in the United Kingdom 0y
the Raspberry Pi Foundation in association with the Broadcom.
a
Raspberry Pi runs Linux operating system and can perform almost alltasks that
actuators
normal desktop computer can do. It also allows interfacing sensors and
through the general purpose VO pins.
10. List tihe functional modules used in loT device,
can of f some attributes:
An
loT device consists modules based on their functional
<br>
Part-B
(13x 5 = 65 marks)
g
in
JL.() Explain the diferent addressing mode of 8051.
(13)
er
Ans: Refer unit-1, chapter -1, page nos: 1.15 -1.23.
e
[OR]
in
(D)
Explain the various bitmanipulation instructions in
805l with examples.
ng
fE (13)
Ans: Refer unit-1, chapter -2, page nos: 2.38 -2.40.
O
12. (a). Explain about design
of model train controller with neat sketches. (13)
e
[OR]
(b) With neat sketches, explain in detailabout ARM processor.
ol
(13)
Ans: Refer unit-2, chapter -5, page nos: 5.1 -5.17.
C
(13)
ad
[OR]
(0) Explain in detail about the OSI model layers, with neat sketches (13)
m
1 Systems and
Embedded. loT Dexign
M.Q.10 nwith neat diagrams.
Raspberry Pi
interfaces (13)
15. (a) Write a note on the
-12. page nos:12.7- 12.8
Ans: Refer unit-5, chapter
[OR)
programming of Raspberry Pi
an example, discuss about the
using
With
(6)
(13)
g
Python.
nos: 12.9- 12.I1
in
chapter -12, page
Ans: Refer unit-S,
er
PART C
(1x 15 =15 marks)
e
in
16. (a) Write a note on
ng
() Supervisor mode.
page nos: 6.S - 6.9.
Ans: Refer unit-2, chapter -6. fE
(i) Exceptions.
O
--
Ans: Refer unit-2, chapter 6, page nos: 6.9 6. 10.
e
(ii) Traps.
g
[OR]
(b) Discuss about program level performance analysis.
C
(45)