Basics of Electrical Measurement
Basics of Electrical Measurement
Microcontrollers
Unit 1
Formative Assessment
Ashesh B Vignesh
110110013
I.C.E. Department
2010 2014 Batch
Introduction
Definition: A microprocessor is a multipurpose,
programmable, clock driven, register based
electronic device that reads binary instructions
from a storage device called memory, accepts
binary data as input and process data
according to those instructions and provides
results as output
Introduction
Basically, very similar to human brain
called a program
A group of programs is called software
8085 is an 8 bit microprocessor
8086 is a 16 bit microprocessor
figure
Diagram shows that has four components:
memory, input, output and the CPU, which
consists of the ALU
CPU contains various registers to store data, the
ALU to perform arithmetic and logical operations
etc.
It communicates with I/O devices either to accept
or send data
These devices are also known as peripherals
CPU is the primary and central player in
Memory
Memory stores such binary informations as
ROM
ROM is used to store programs that do not need
alterations
Monitor program of a single board
microcomputer is stored in ROM
Programs stored in ROM can be only read, not
altered
RAM
RAM is also known as user memory
I/O Read
Accepts data from input devices
I/O Write
Sends data to output devices
lines:
Address bus, Data bus and Control bus
Address Bus
Address bus is group of 16 lines generally
identified as 0 to 15
Address bits are unidirectional from MPU to
peripheral devices
The MPU uses the address bus to perform the
first step
Each memory location is identified by a binary
number called address
Address bus is used to carry a 16 bit address
Data Bus
Data bus is a group of 8 lines used for data flow
Control Bus
Comprised of various single lines that carry
synchronization signals
Uses such lines to perform step 3
These lines provide a pulse to indicate an MPU
operation
MPU generates specific control signals for every
operation it performs
These signals are used to identify a device type
with which the MPU intends to communicate
8085 Architecture
8085 is an 8 bit general purpose
microprocessor
Capable of addressing 64K of memory
Signals of 8085
There are 6 groups of control and status signals
Address Bus
Data Bus
Control and Status signals
Power supply and frequency signals
Address Bus
8085 has 16 pins used as address bus
Split into two segments: A15 A8 and AD7 AD0
address
AD7 AD0 are used for a dual purpose
purpose
Used as low order address bus and data bus
When executing instruction:
Earlier part of cycle: low order address bus
Later part of cycle used as data bus
Known as multiplexing the bus
latch
Control Signal
Read
A Read control signal (active low)
Indicates selected / or memory device is to be
read
Indicates data available on the data bus
Write
Write control signal (active low)
Indicates the data on data bus are to be written into
Status Signals
/ - Input/Output or Memory
Signal used to differential between I/O and memory
operation
When High, it indicates I/O operation
When Low, it indicates memory operation
Combined with and to generate I/O and
Memory control signals
1 and 0
Similar to
small systems
Ground Reference
1 , 2
A crystal (or RC, LC) network is connected at these
two pins
To operate at 3 MHz, crystal should have a
frequency of 6 MHz
()
Clock output: This signal can be used as the system
Interrupts
To respond to Request, there is a signal
Interrupt signals
transmission
(Serial Input Data)
(Serial Output Data)
Interrupt Control
Serial I/O Control
The ALU
Performs computing functions
Includes:
The accumulator
Temporary register
The arithmetic and logic circuits
Five Flags
arithmetic/logic operation
Result stored in accumulator
Flags are set or reset according to the result of
the operation
ALU Flags
S Sign flag
After an arithmetic or logic operation, if bit 7 of the
ALU Flags
Z Zero Flag
Zero flag is set if ALU operation results in 0
Flag is reset if result is not 0
Flag is modified by results in accumulator as well as
other registers
AC Auxiliary Carry Flag
In arithmetic operation, when carry is generated by
ALU - Flags
P Parity Flag
If result of operation has an even number of 1s, flag
ALU - Flags
The bit positions reserved for these flags in the
8086 microprocessor
Inter iAPX 8086 is a 16 bit microprocessor
8086 Architecture
The 8086 has a 16 bit external data bus
categories
1)
2)
3)
4)
5)
6)
7)
Address bus
Data Bus
Control and status signals
External requests
Response to external requests
Power and clock
Signals for micro processing environment
8086 Architecture
The 7th category, Signals for multiprocessor
environment, is a new
It includes 2 signals
/ (minimum or maximum mode)
Test
maximum
When signal is high (connected to +5 V): Minimum
When signal is low (grounded): Maximum
Minimum mode used for single processor
environment
Maximum mode used for multiprocessor
environment
In Maximum mode, 8 pins assigned different
functions as compared to maximum mode
Bus controller is necessary to generate control signals
processors in a system
When WAIT instruction is being executed,
processor checks this signal
If high, processor interrupts execution of program
If low, it continues execution
- Data Enable
Active low output signal
Generally connected to bidirectional buffer to isolate
flow
/ - Memory and I/O
Indicates whether processor cycle is I/O operation
or memory operation
- Bus High Enable
Active low signal used to enable the high order
Stack
Stack can be described as a set of memory
Stack
As a general practice, the stack is initalized at the
stack information
Size of stack is limited only by
memory address)
By using instruction PUSH
Stack
Data byte can be transferred from stack to
decremented by two
When retrieved, address is incremented by two
Stack
Stack
Subroutine
Group of instructions written separately from main
Subroutine
When subroutine is called, the contents of the
Subroutine
Registers
The operations with the microprocessor performs
are:
Store 8 bit data
Perform arithmetic and logical operations
Test for conditions
Registers
To perform operations, the microprocessor
Registers
Registers
The 6 general purpose registers are: B, C, D, E,
H and L
Each register is 8 bits long
Can be combined to give register pairs
B-C, D-E, H-L
Registers
The accumulator is an 8 bit register that is part of
the ALU
This register is used to store 8 bit data and to
perform arithmetic and logical operations
Used as a register for storing on data when two
are arithmetically operated
The result of the operation is stored also in the
accumulator which is identified as A.
When only one data is to be logically operated, A
is used for storing data and for storing result after
operation
Special Registers
The program counter (PC) is a 16 bit special
Program Counter
The address in PC is incremented for next
operation
Once execution is done, the next address in
placed on address bus, and PC is incremented
again
It basically points next location of memory where
data can be stored
Stack
Stack can be defined as:
A set of memory locations in the R/W memory,
Stack
The beginning of the stack is defined in the
Stack
We call this as the stack growing backwards
PUSH
PUSH is a 1 byte instruction
value F3)
The process of how PUSH works:
First, decrease SP by one
Then copy contents of register B to memory
POP
POP is a 1 byte instruction
slide)
Process of how POP works:
Copy contents of memory location pointed by SP to
register E
Increase the SP by 1
Copy contents of memory location pointed by SP to
register D after increment
Increase SP
Stack
Note: operands B, D and H represent register
increment style.
The information is retrieved from the top of the
stack.
LIFO
LIFO is an acronym
When expanded, it becomes Last In First Out
This is how the stack operations work, where the last
PUSH B
PUSH D
POP D
POP B
8 Bit Addition
Start program by loading the first data into
accumulator
Load the second data into other register
Add the contents of the two registers
Check for carry
Store the value of sum and carry in memory
location
Terminate the program
Program
Loop
LOOP
Memory
4100
4101
4102
4103
4104
4105
4106
4107
4108
4109
410A
410B
410C
410D
410E
410F
4110
4111
4112
4113
4114
4115
Instruction
MVI C, 00H
LDA, 4200H
MOV B,A
LDA, 4201H
ADD B
JNC 410EH
INR C
STA, 4400H
MOV A, C
STA, 4401H
HLT
Op Code
OE
OO
3A
OO
42
47
3A
O1
42
80
O2
0E
41
OC
32
OO
44
79
32
O1
44
76
Comment
Initialise C to 00H
Load the 1st data in A
Move Content of A to B
Load the 2nd data
Add B to A
Jump on no carry
Increment content of S
Store the content of A to 4400H
Move the content of C to A
Store the content of A to 4401H
Terminate the Program
16 Bit addition
Algorithm
Program
Loop
LOOP
Memory
4200
4201
4202
4203
4204
4205
4206
4207
4208
4209
420A
420B
420C
420D
420E
420F
4210
4211
4212
4213
4214
4215
Instructions
MVI C, OO
LHLD 4500
XCHG
LHLD 4502
DAD A
JNC LOOP
INR C
SHLD 4100
MOV A, C
STA 4102
HLT
Opcode
OE
OO
2A
OO
45
EB
2A
O2
45
19
D2
OE
42
OC
22
OO
41
79
32
O2
41
76
Comment
Initialize C a 0
Load address of 1st number to HL pair
Copt 1st number to DE pair
Load address of 2nd number to HL pair
Add HL pair with DE pair
JUMP on no carry to the label LOOP
Increment C by 1
Store HL pair content to 4100
Contents of C copied to A
Store accumulator content to 4102
Program Ends
8 Bit subtraction
Start the program by loading the first data into
accumulator
Load the second data into other register
Subtract the second register data from the
accumulator
Check for positive
Store the result in some memory location
Terminate the program
Program
Loop
LOOP
Memory
4100
4101
4102
4103
4104
4105
4106
4107
4108
4109
410A
410B
410C
410D
410E
410F
4110
4111
4112
4113
4114
4115
Instruction
MVI C, 00H
LDA, 4200H
MOV B,A
LDA, 4201H
SUB B
JP LOOP
DCR C
STA, 4300H
MOV A, C
STA, 4301H
HLT
Op Code
OE
OO
3A
OO
42
47
3A
O1
42
90
F2
0E
41
OD
32
OO
43
79
32
O1
43
76
Comment
Initialise C to 00H
Jump if Positive
Decrement C
Store value in A
Move contents to C
Store value in A
Terminate Program
16 Bit Subtraction
Start the program by loading HL register pair with address of
1st number.
Copy the data to DE register pair.
Load the second number to HL pair.
Copy data in register E to Accumulator.
Copy date in register L to register B.
Subtract data in register B from Accumulator.
Check for carry.
If carry is present take 2s complement of Accumulator.
Store the difference value in the memory location.
Copy data in register D to Accumulator.
Subtract data in register H from Accumulator along with borrow.
Check for carry.
If carry is present take 2s complement of Accumulator.
Store the difference value and borrow in the memory location.
Terminate the program.
Program
Loop
Memory
Instructions
Opcode
4400
LHLD 4600
2A
4401
OO
4402
46
4403
XCHG
EB
4404
LHLD 4602
2A
4405
O2
4406
46
4407
MVI C, 00
4408
OE
OO
Comment
Initialize C as 0
4409
MOV A, E
7B
440A
MOV B, L
45
440B
SUB B
90
440C
JNC LOOP
D2
440D
11
440E
44
440F
CMA
2F
4410
INR A
3C
Program
LOOP
LABEL
4411
STA 4300
32
4412
OO
4413
43
4414
MOV A,D
7A
4415
SBB H
9C
4416
JNC LABEL
D2
4417
1C
4418
4419
441A
441B
INR A
44
OC
2F
3C
441C
STA 4301
32
INR C
CMA
441D
O1
441E
43
441F
MOV A, C
79
4420
STA 4302
32
4421
O2
4422
43
4423
HLT
76
MOV
Copy from source to destination
MOV Rd, Rs
M, Rs
Rd, M
This instruction copies the contents of the source
MVI
Move immediate 8-bit
or
M, data memory
If the operand is a memory location, its location is
specified by the contents of the HL registers
Example: MVI B, 57H or MVI M, 57H
LDA
Load accumulator
LDAX
Load accumulator indirect
LXI
Load register pair immediate
LHLD
Load H and L registers direct
STA
Store accumulator direct
STAX
Store accumulator indirect
SHLD
Store H and L registers direct
PUSH
Push register pair onto stack
POP
Pop off stack to register pair
OUT
Output data from accumulator to a port with 8-bit
address
OUT 8-bit port address
The contents of the accumulator are copied into
IN
Input data to accumulator from a port with 8-bit
address
IN 8-bit port address
The contents of the input port designated in the
and
loaded
into
the
ADD
Add register or memory to accumulator
ADD R
M
The contents of the operand are M added to the
ADC
Add register to accumulator with carry
ADC R
M
The contents of the operand and M the Carry flag are
SUB
Subtract register or memory from accumulator
SUB R
V
The contents of the operand (register or memory
) are subtracted from the contents of the
accumulator
The result is stored in the accumulator
If the operand is a memory location, its location is
specified by the contents of the HL registers
All flags are modified to reflect the result of the
subtraction.
Example: SUB B or SUB M
SBB
Subtract source and borrow from accumulator
SBB
R
M
INR
Increment register or memory by 1
INR
The
R
M
INX
Increment register pair by 1
INX
incremented by 1
The result is stored in the same place
Example: INX H
DCR
Decrement register or memory by 1
DCR R
M
The