Embedded System - Microcontroller
Embedded System - Microcontroller
Definitions :
“An Embedded System is a system that has embedded software and computer
hardware, which makes if a system dedicated for an application or specific part
of an application”
Example :
Air conditioner : What does an air conditioner do ?.
The temperature is set as per requirement, say 190C.
There may be variations in external temperature and that will also reflect
in the room air conditioner if fitted.
But however the external temperature varies, the AC machine facilitates
user with cool atmosphere.
Pace maker : Its work to trigger the heart beat if at all heart is getting into
trouble.
Real time and Reactive : Pace makers, ECG, Flight Landing control
Cruise controller : Monitors : Acceleration or deceleration
CPU is connected with both the data There is no separate data and
memory (RAM) & Program memory program memory. It is
(ROM) connected with a memory
(ROM)
Requires more hardware because Requires less hardware
separate address bus and data buses
Requires more space Requires less space
Non-Volatile : This memory that retains its stored value when power is
removed. ROM (Read Only Memory)
ROM (Read Only Memory) :
It does not retain the data stored in it, when the system power is
turned-off.
Ao-Aa-1
Data Memory
Address range
0X0000 to 0XFF FF
• I/P Data
• O/P Data
Harvard Architecture : 8051
Read
Vectors and
Pointers
Write
Program Memory
Do-Da-1
• Boostup Programs
Program Memory • Functions
• Routines
• Tasks
Ao-Aa-1
Data Memory
Address range
0X0000 to 0XFF FF
• I/P Data
• O/P Data
Princeton Architecture :
Harvard Architecture :
FFFFH
Peripherals
(8KB)
8192 Bytes
E000H
DFFFH
SRAM
(24KB)
24496 Bytes
8000H
7FFFH
EPROM
(32KB) Note :
32768 Bytes A15 line if it is low : EPROM
A15 line is High : SRAM
0000H
Memory Map :
Smart Card/
Credit card/ Debit card : 2KB
Java Embeddedcard : 32KB
0x201FFH 0x201FFH
EEPROM EEPROM
512 Bytes 512 Bytes
0x20000H 0x20000H
0x100FFH 0x10FFFH
RAM RAM
(256 BYTES) (4KB)
4048 BYTES)
0x10000H 0x10000H
0x007FFH 0x07FFFH
ROM ROM
(2KB) (32KB)
2048 Bytes 2048 Bytes
0x00000H 0x00000H
Memory Map
Smart Card
Credit/Debit Card
Memory Map
Memory Mapped I/O & I/O Mapped I/O
Memory mapped I/O
Memory Mapped I/O Uses the same instructions for both I/O & memory
operations
I/O Mapped I/O Uses the Separate instructions for read & write operations in
I/O & memory operations
Bus Arbitration:
It is a Process by which current bus master accesses and then leaves
the control of the bus and pass it to the another bus requesting
processor unit.
Memor
y
Another Processor
Processor 2
1 Slave
Main Slave
Bus
Process con
or trolll
Master er Request signal to access Buses (Address
bus/Data bus) Method s: Used to accessing
buses
Polling Priority Method
Bus Grant
Polling lines
Bus Arbiter
Bus Request
Polling IDs : Device 0 : 000 Device1: 001 Device 2: 010 Device 3: 011
and so on
Fixed Priority Method
Bus Grant
Device 1
Bus Request
Bus Grant
Bus Arbiter
or Device 2
Bus Master Bus Request
Bus Grant
Device 3
Bus Request
Design Process
Concepts Used during a Design
1. Abstraction
• Problem component to be abstracted
5. Modular design
• System designing is fast by decomposition of software into
modules that are to be implemented
6. Mapping:
Ex : Image is I/p data to a system
It can have different no of pixels and colours
System does not process each pixel and colour individually
8. Refinements :
Each Component and module design needs to be refined
iteratively till it becomes the most appropriate for implementation by
the software team
The Embedded System Design Process :
Requirements :
Purpose, Inputs, Outputs, Functioning , Design metrics and
Validation requirement for Finally developed system.
Specification:
Customer Expectations from the Product
Designer Needs specifications for
Hardware : Peripheral devices, Processor,& Memory
Data types & Processing specification
Expected System Behaviour
Constraints of Design
Expected Life Cycle
Architecture
System Integration :
Built components are integrated in the system.
The system is made to function and validated.
Debugging tools are used to correct erroneous functioning.
Challenges in Embedded Computing System Design
Assembly Coding
The Final machine implementable software for a product embeds in the one
programmable FLASH ROM as an “Image” in a Frame.
Machine Machine
Machine
Specific Assembler Codes ready
Codes for the
Assembly for locating at
1 Programs at
Language various
various 3
Program Addresses
Addresses
Reallocation
Device
Programmer
From Library Linker ROM’
Needed Bytes for Linked Loader Burner
2
Machine Codes Program
ES ROM Memory
Data Bytes
Assembler : Translates assembly software into the machine codes
Locator : Locates I/O Tasks and Hardware device driver at Fixed Addresses
and then Burn
C language to ROM Image
C Program
Machine Codes in
Function
Object File
Complier
Code Optimizer
From
Linker
Library Bytes for Linked
Needed Programs
Machine
Codes
Step 3 & 4 Same
as Previous
Embedded
System ROM
Memory
Ex :
Bank 2 needs to be select
SETB PSW.3 (Set bit) R0=1
CLR PSW.4 Clear bit R1=0
R1 R0
1 0 Bank 2
2 Bank 3
3 SETB PSW.3 R0=1
4 SETB PSW.4 R1=1
5 Bank0 ,1,2,3: Register R0-R7 (Each bank 8 no
bytes R0 R1, R2,R…R7
Addressing modes
MOVC
Indexed addressing mode :
(Move from Code Memory)
MOVC A, @A+DPTR ; MOVC A,@A+PC
(Base address DPTR + Offset A)
DPTR = 2006 2006 = …
A= 02H 2007=
2008 2008= 89
Immediate addressing
# Symbol represents a Immediate data
MOV A,#45H (45 Immediate data -----A)
Addressing Modes:
This is a method to define Operands
dest operand, Source Operand
Register Addressing
Data can transfer between Register to Register
MOV A, R7
MOV B, R0
Invalid : MOV R0,R4
All banks have same names , It may confuse.
MOVX ( Move the data between external memory to register/ reg-ext mem)
MOVC (Code memory) : Is used for reading from the code memory
MOVC A,@A+DPTR
PUSH : Push the content available in R0 move to Top of Stack
Ex: First STEP: Stack Pointer Increments by ONE (SP+1)
Second Step : Transfer R0 content on Stack memory
Ex : POP AR0
Ex : XCH A,07
A=FF 07=0F
Ex : XCHD A,@R0
Before Execution
After execution
ADD :
Ex : ADD A,07
ADD A,@R0
ADD A,#40H
Ex : ADDC A,R0
If previous Carry Flag =1
A= 08H
+
R0= 01
+
Cy = 01
--------------
=========
SUB
Ex : SUB A,R0
Ex : SUBB A,R0
If Previous Carry flag =1
A= 07H
-
R0=01
-
CY=01
------------
Decrement : DEC A
DEC 40H
Multiplication :
MUL AB
Division :
DIV AB
After division
ANL A,@R0
ANL A,40H
ORL 40H,A
ORL 40H,#07H
XRL A,40H
XRL 40H,A
XRL 40H,#07H
CPL A
RL A
RR A
RRC A
RLC A
Ex : A = 07H
After execution
A=70H
Boolean Instructions :
CLR C
SETB C
SETB PSW.3
ANL C,bit(0) CF=1 AND 01 ; CF=
JC address ; Jump if Carry flag=1
JNC ; Jump if no carry CF=0
JB (Jump if bit =1) JB P1.3, Location ;
JNB P1.0,Location (Jump if No Bit P1.0=0)
JBC (jump if bit is set to 1 and Clears the bit) : JBC P1.0, location
JBC P3.5,memory loc
JBC P3.5,
Ex :The pin 3.5 of an 8051 microcontroller is controlled by a
Push Button. Write a sequence of instructions which turns
Port 1 into a counter. The port 1 value has to be
incremented when the Push button is pressed and
released.
JNZ,CJNE, : Conditional
UNCONDITIONAL :
SHORT JUMP ; SJMP
Program Control transfer within 128 Bytes
Ex : CJNE 40H,#80,200A
CJNE A,#80,200A
DJNZ :
DJNZ 40H,200A
ReturnInterrupt
RETI
NOP No operation
RR A
A = 1000 0010
0100 0001
1010 0000
1000 00 10 CY=1
RRC A
1100 0001 CY=0
0 110 0 0 00 CY=1
RLC A
Ex : A = 07H
After execution
A=70H
Boolean Instructions :
CLR C
SETB C
SETB PSW.3
ANL C,bit(0)
JC
JNC
JB (Jump if bit =1) JB P1.3, Location
JNB P1.0,Location (Jump if No Bit P1.0=0)
JBC (jump if bit is set to 1 and Clears the bit) : JBC P1.0, location
RLC A
Ex : A = 07H
After execution
A=70H
Boolean Instructions :
CLR C
SETB C
SETB PSW.3
ANL C,bit(0)
JC
JNC
JB (Jump if bit =1) JB P1.3, Location
JNB P1.0,Location (Jump if No Bit P1.0=0)
JBC (jump if bit is set to 1 and Clears the bit) : JBC P1.0, location
RLC A
Ex : A = 07H
After execution
A=70H
Boolean Instructions :
CLR C
SETB C
SETB PSW.3
ANL C,bit(0)
JC
JNC
JB (Jump if bit =1) JB P1.3, Location
JNB P1.0,Location (Jump if No Bit P1.0=0)
JBC (jump if bit is set to 1 and Clears the bit) : JBC P1.0, location
RLC A
Ex : A = 07H
After execution
A=70H
Boolean Instructions :
CLR C
SETB C
SETB PSW.3
ANL C,bit(0)
JC
JNC
JB (Jump if bit =1) JB P1.3, Location
JNB P1.0,Location (Jump if No Bit P1.0=0)
JBC (jump if bit is set to 1 and Clears the bit) : JBC P1.0, location