Chapter 5

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 38

Microprocessor

MEC523 – Applied Electronics and

INTRODUCTION TO MICROCONTROLLER
MFO
Chapter 5: Micro-controller Systems and Applications
1
At the end of this chapter, the
students should be able to.…
Microprocessor
MEC523 – Applied Electronics and

✓ Write major differences between a microprocessor and a


microcontroller
✓ Explain the applications of microcontrollers
✓ Explain how does a microcontroller differ from a
microprocessor
✓ Explain the different ways of classifying the types of
microcontrollers
✓ Discuss the advantages and disadvantages of Harvard and
Princeton (Von-Neumann) architectures
✓ Differentiate between an embedded and external memory
MFO
microcontroller

2
Microprocessors and Microcontrollers
Microprocessor
MEC523 – Applied Electronics and

Microprocessor
✓ To control some
process
✓ Built from logic ✓ Smaller size – fit onto ✓ Miniaturization – onto one chip
components small cct board ✓ Contains CPU, Memory, I/O,
✓ Large, heavy boxes ✓ Eg: Zilog Z80, Intel 8088, timers and interrupt (Fig. 1.2)
Motorola 6809, etc.
Controller ✓ ~ a CPU (Fig. 1.1)
Microcontroller

Intel 8085 – 8-bit Intel 8051 – 8-bit


MFO ***The CCT board = Intel 8086/8088 – 16-bit Intel 8096 – 16-bit
Command, Control &
Telemetry Board

3
Microprocessors and Microcontrollers

4
MEC523 – Applied Electronics and

MFO
Microprocessor
Microprocessors and Microcontrollers
Microprocessor
MEC523 – Applied Electronics and

Figure 1.2 A block diagram of a microcontroller

MFO

5
Difference of
Microcontroller and Microprocessor
Microprocessor
MEC523 – Applied Electronics and

MFO

6
Difference of
Microcontroller and Microprocessor
Microprocessor
MEC523 – Applied Electronics and

MFO

7
Terminology used for microcontrollers

8
MEC523 – Applied Electronics and

MFO
Microprocessor
Terminology used for microcontrollers
Microprocessor
MEC523 – Applied Electronics and

Machine Cycle
To execute an instruction–the processor
must:
1. Fetch the instruction from memory
2. Decode the instruction
3. Execute the instruction
4. Store the result back in the memory.

CPU (Central Processing Unit) ONE machine cycle = ‘X’ clock cycles (‘X’
depends on the particular
✓Brain of the computer instruction being executed).

✓ Admin all activities in the


system
✓ Perform all data operations PROCESSOR
based on instruction set (set Faster
IS FASTER!
of binary codes) execution of
instructions
➢ Fetching Time to
complete a
MFO
➢ Executing cycle ↓
Clock cycle

9
Terminology used for microcontrollers
Microprocessor
MEC523 – Applied Electronics and

Fetching and Executing an Instruction


✓ Fetching involves the following steps:
➢ Contents of PC are placed on address bus.
➢ READ signal is activated.
➢ Data (instruction opcode) are read from RAM and placed on data bus.
➢ Opcode is latched into the CPU’s internal instruction register.
➢ PC is incremented to prepare for the next fetch from memory.

✓ Execution involves: decoding the opcode and generating control signals to


gate internal registers in and out of the ALU and to signal the ALU to
perform the specified operation

MFO

10
Terminology used for microcontrollers
Microprocessor
MEC523 – Applied Electronics and

Fetching and Executing an Instruction

MFO

11
Terminology used for microcontrollers
Microprocessor
MEC523 – Applied Electronics and

The Buses : Address, Data, and Control

• A BUS is a collection of wires carrying information with a common purpose.

• For each read or write operation, the CPU specifies the location of the data or
instruction by placing an address on the address bus, then activates a signal
on the control bus indicating whether the operation is read or write.

• READ OPERATIONS retrieve a byte of data from memory at the location


specified and place it on the data bus. CPU reads the data and places it in one of
its internal registers.

MFO • WRITE OPERATIONS put data from CPU on the data bus and store it in the
location specified.

12
Terminology used for microcontrollers
Microprocessor
MEC523 – Applied Electronics and

ADDRESS BUS carries the address of a specified location.


For n address lines, 2𝑛 locations can be accessed. E.g., A 16-bit
address bus can access 216 = 65,536 locations or 64K locations
(210 = 1024 = 1K, 26 = 64).

DATA BUS carries information between the CPU and


memory or between the CPU and I/O devices.

CONTROL BUS carries control signals supplied by the CPU


to synchronize the movement of information on the address
and data bus.
MFO

13
Terminology used for microcontrollers
Microprocessor
MEC523 – Applied Electronics and

CONTROL/MONITOR
(INPUT/OUTPUT) DEVICES

✓ CONTROL DEVICES are outputs,


or actuators, that can affect the
world around them when
supplied with a voltage or
current.

✓ MONITORING DEVICES are


inputs, or sensors, that are
stimulated by temperature, Example of control devices
pressure, light, motion, etc. and
convert this to voltage or
current signals to be read by
the computer.
MFO

14
Types of Microcontrollers
Microprocessor
MEC523 – Applied Electronics and

INTERNAL INSTRUCTION
MEMORY ARCHITECTURE
Microcontrollers BUS WIDTH SET
can be classified on
the basis of
internal bus width,
architecture,
memory and
instruction set

FAMILY

MFO

15
Types of Microcontrollers
Microprocessor
MEC523 – Applied Electronics and

THE 8-BIT MICROCONTROLLER

When the ALU performs arithmetic and logical


operations on a byte (8-bits) at an instruction, the
microcontroller is an 8-bit microcontroller. The
internal bus width of 8-bit microcontroller is of 8-
bit. Examples of 8-bit microcontrollers are Intel
8051 family and Motorola MC68HC11 family.

THE 16-BIT MICROCONTROLLER

When the ALU performs arithmetic and logical operations on a


word (16-bits) at an instruction, the microcontroller is an 16-bit
microcontroller. The internal bus width of 16-bit microcontroller
is of 16-bit. Examples of 16-bit microcontrollers are Intel 8096
family and Motorola MC68HC12 and MC68332 families. The
performance and computing capability of 16 bit microcontrollers
MFO are enhanced with greater precision as compared to the 8-bit
microcontrollers.

16
Types of Microcontrollers
Microprocessor
MEC523 – Applied Electronics and

THE 32-BIT MICROCONTROLLER

When the ALU performs arithmetic and logical


operations on a double word (32- bits) at an
instruction, the microcontroller is an 32-bit
microcontroller. The internal bus width of 32-bit
microcontroller is of 32-bit.

Examples of 32-bit microcontrollers are Intel


80960 family and Motorola M683xx and
Intel/Atmel 251 family. The performance and
computing capability of 32 bit microcontrollers
are enhanced with greater precision as
compared to the 16-bit microcontrollers.
MFO

17
Types of Microcontrollers
Microprocessor
MEC523 – Applied Electronics and

EMBEDDED MICROCONTROLLERS
When an embedded system has an microcontroller unit that has all
the functional blocks (including program as well as data memory)
available on a chip is called an embedded microcontroller. For
example, 8051 having Program & Data Memory, I/O Ports, Serial
Communication, Counters and Timers and Interrupt Control logic on
the chip is an embedded microcontroller.

EXTERNAL MEMORY MICROCONTROLLERS


When an embedded system has an microcontroller unit that has not all the
functional blocks available on a chip is called an external memory
microcontroller. In external memory microcontroller, all or part of the memory
units are externally interfaced using an interfacing circuit called the glue circuit.
MFO For example, 8031 has no program memory on the chip is an external memory
microcontroller.

18
Types of Microcontrollers
Microprocessor
MEC523 – Applied Electronics and

CISC (COMPLEX INSTRUCTION SET COMPUTER) ARCHITECTURE


MICROCONTROLLERS
When an microcontroller has an instruction set that supports many
addressing modes for the arithmetic and logical instructions, data
transfer and memory accesses instructions, the microcontroller is
said to be of CISC architecture.

The typical CISC microcontroller has well over 80 instructions, many


of them very powerful and very specialized for specific control
tasks. It is quite common for the instructions to all behave quite
differently. Some might only operate on certain address spaces or
registers, and others might only recognize certain addressing modes.

The advantages of the CISC architecture are that many of the


instructions are macrolike, allowing the programmer to use one
MFO instruction in place of many simpler instructions.

19
Types of Microcontrollers
Microprocessor
MEC523 – Applied Electronics and

RISC (REDUCED INSTRUCTION SET COMPUTER)


ARCHITECTURE MICROCONTROLLERS
The industry trend for microprocessor design is for Reduced
Instruction Set Computers (RISC) designs. When a microcontroller
has an instruction set that supports fewer addressing modes for
the arithmetic and logical instructions, and for data transfer
instructions, the microcontroller is said to be of RISC architecture.

The benefits of RISC design simplicity are a smaller chip, smaller


pin count, and very low power consumption.

MFO

20
Types of Microcontrollers
Microprocessor
MEC523 – Applied Electronics and

Harvard Von-Neumann (Princeton)

✓ Harvard Architecture refers to a ✓ A Von-Neumann Machine, in


memory structure where the contrast to the Harvard Architecture
processor is connected to two provides one data path (bus) for
different memory banks via two both instruction and data
sets of buses ✓ As a result, the CPU can either be
✓ This is to provide the processor with fetching an instruction from
two distinct data paths, one for memory, or read/writing data to it
instruction and one for data ✓ Other than less complexity of
✓ Through this scheme, the CPU can hardware, it allows for using a
read both an instruction and data single, sequential memory.
from the respective memory banks ✓ The Von-Neuman architecture’s
at the same time main advantage is that it simplifies
These ✓ This inherent independence the microcontroller design because
architectures increases the throughput of the only one memory is accessed.
differ in the way machine by enabling it to always
data and pre-fetch the next instruction
programs are ✓ The Harvard Architecture executes
instructions in fewer instruction
stored and cycles than the Von-Neumann
accessed architecture
MFO ✓ The cost of such a system is
complexity in hardware
✓ Commonly used in DSPs
21
Types of Microcontrollers

Harvard
Microprocessor
MEC523 – Applied Electronics and

and
von-Neumann Architecture

MFO

22
23
Design Operation of Memory
MEC523 – Applied Electronics and

MFO
Microprocessor
The Design and Operation of Memory
Microprocessor
MEC523 – Applied Electronics and

✓ Memory in a microprocessor system is where information (data and


instructions) is kept. It can be classified into two main types:
➢ Main memory (RAM and ROM)
➢ Storage memory (Disks , CD ROMs, etc.)

✓ The simple view of RAM is that it is made up of registers that are


made up of flip-flops (or memory elements).
➢ The number of flip-flops in a “memory register” determines the size of the
memory word.
✓ ROM on the other hand uses diodes instead of the flip-flops to
permanently hold the information.

MFO

24
Accessing Information in Memory
Microprocessor
MEC523 – Applied Electronics and

✓ For the microprocessor to access (Read or Write) information in


memory (RAM or ROM), it needs to do the following:
➢ Select the right memory chip (using part of the address bus).
➢ Identify the memory location (using the rest of the address bus).
➢ Access the data (using the data bus).

MFO

25
The Basic Memory Element
Microprocessor
MEC523 – Applied Electronics and

✓ The basic memory element is similar to a D latch.


✓ This latch has an input where the data comes in. It has an enable
input and an output on which data comes out.

Data Input Data Output


D Q

Enable
EN

MFO

26
The Basic Memory Element
Microprocessor
MEC523 – Applied Electronics and

✓ However, this is not safe.


➢ Data is always present on the input and the output is always set to the
contents of the latch.
➢ To avoid this, tri-state buffers are added at the input and output of the
latch.

Data Input Data Output


D Q

WR RD
Enable
EN

MFO

27
The Basic Memory Element
Microprocessor
MEC523 – Applied Electronics and

✓ The WR signal controls the input buffer.


➢ The bar over WR means that this is an active low signal
➢ So, if WR is 0 the input data reaches the latch input
➢ If WR is 1 the input of the latch looks like a wire connected to nothing
✓ The RD signal controls the output in a similar manner

MFO

28
A Memory “Register”
Microprocessor
MEC523 – Applied Electronics and

✓ If we take four of these latches and connect them together, we


will have a 4-bit memory register
I0 I1 I2 I3

WR
D D D D
Q Q Q Q
EN EN EN EN
EN

RD O0 O1 O2 O3

MFO

29
A group of memory registers
D0 D1 D2 D3
Microprocessor
MEC523 – Applied Electronics and

o o o o
WR

D Q D Q D Q D Q

EN EN EN EN

✓ Expanding on this D Q D Q D Q D Q

scheme to add more EN EN EN EN

memory registers we get


the diagram to the right. D Q D Q D Q D Q

EN EN EN EN

D Q D Q D Q D Q

EN EN EN EN

o o o o
RD

MFO
D0 D1 D2 D3

30
A group of Memory Registers
Microprocessor
MEC523 – Applied Electronics and

✓ If we represent each memory location (Register) as a block we get the


following
I I I I
0 1 2 3
W Input Buffers

R
EN Memory Reg. 0

EN
0 Memory Reg. 1

EN
1 Memory Reg. 2

EN
2 Memory Reg. 3

3
Output Buffers
RD

O O O O
MFO
0 1 2 3

31
The Design of a Memory Chip
Microprocessor
MEC523 – Applied Electronics and

✓ Using the RD and WR controls we can determine the direction of


flow either into or out of memory. Then using the appropriate
Enable input we enable an individual memory register.

✓ What we have just designed is a memory with 4 locations and each


location has 4 elements (bits). This memory would be called 4 X 4
[Number of location X number of bits per location].

MFO

32
The Enable Inputs
Microprocessor
MEC523 – Applied Electronics and

✓ How do we produce these enable line?


➢ Since we can never have more than one of these enables active at the
same time, we can have them encoded to reduce the number of lines
coming into the chip.
➢ These encoded lines are the address lines for memory.

MFO

33
The Design of a Memory Chip
Microprocessor
MEC523 – Applied Electronics and

✓ So, the previous diagram would now look like the following:
I I I I
0 1 2 3
W Input Buffers

R
A D Memory Reg. 0

A1 d e Memory Reg. 1
d c
Memory Reg. 2
A0 r o
e d Memory Reg. 3
s e
RD s r Output Buffers

O O O O
MFO
0 1 2 3

34
The Design of a Memory Chip
Microprocessor
MEC523 – Applied Electronics and

✓ Since we have tri-state buffers on both the inputs and outputs of the flip
flops, we can use one set of pins only.
➢ The chip would now look like this:

W Input Buffers

R
A D Memory Reg. 0 D0 D0
A1 d e Memory Reg. 1 A1
D1 D1
d c
Memory Reg. 2
A0 r o D2 A0 D2
e d Memory Reg. 3
D3 D3
s e
RD s r Output Buffers

MFO RD W
R

35
Tutorial

36
MEC523 – Applied Electronics and

MFO
Microprocessor
Solution:

37
MEC523 – Applied Electronics and

MFO
Microprocessor
Thank you for the attention !
Microprocessor
MEC523 – Applied Electronics and

MFO
Acknowledgement:
Thank you to Fadzliana Saad and Norhazlin Khairudin from FKE for the teaching materials
38

You might also like