2. Chapter 1
Tiny Computers, Hidden Control
The aims of this chapter are to introduce:
• The meaning of the term ‘embedded system’;
• The microcontroller which lies at the heart of the embedded system;
• The Microchip PIC® family;
• A first PIC microcontroller, the 12F508.
2
3. What examples of embedded
systems do you know?
What is an embedded system?
3
4. Example 2: Car Door Control, within a Larger Network
o
p
e
n
d
o
o
rs
e
n
s
o
r
w
i
n
d
o
w
c
o
n
t
r
o
lb
u
t
t
o
n
s
l
o
c
k
c
o
n
t
r
o
l
l
o
c
k
a
c
t
u
a
t
o
r
w
i
n
d
o
w
m
o
t
o
r
w
i
n
d
o
w
s
t
a
l
ls
e
n
s
o
r
4
7. PIC
Pulse Width Modulation
Serial Data
Serial
Microcontroller
Compass
Motor Drive
Interface
Streamx2
Ultrasound
Ranging
Pulse Echo
Motor
Bump Sensor
Power
Management
Regulation &
9V
Alkaline
5V
9V
Right
Bump Sensor
Left
LightSensor
Left
LightSensor
Right
Analog to Digital
Converter
Left
Motor
Clock
Module
Serial Extension Bus
LightSensor
Rear
Ultrasound
Servo
Right 7
8. An embedded system is a system whose principal function is not computational,
but which is controlled by a computer embedded within it.
Generic Block Diagram
Input
Variables
Output
(User Interface)
Variables
(Link to other Systems)
Embedded Computer
Software
Hardware
Signal
Conditioning
Data
Conversion
Output
Drive
(display, keypad etc.)
8
9. The Embedded System - What Disciplines does it Involve?
Embedded Systems
Electronics
Electric Motors &
Computer Architecture
Software Engineering
Integrated Circuit
Design
Digital
Analogue
Electronics
Actuators
Sensors and
Measurements
Control
Engineering
Data
Communications
9
10. • A computer “executes” instructions in its (ALU).
• Running through a series of instructions called a program.
• The ALU in turn forms part of the (CPU).
• (A) is the “Accumulator”, a digital register where the
computations actually occur.
• (M) is a location in memory.
• A typical 8-bit ALU can do the list shown below.
What can the Computer Actually Do?
10
11. Increment A
Decrement A
Add A to M
Subtract M from A
AND A with M
OR A with M
Exclusive OR A with M
Shift A left
Shift A right
Rotate A left
Rotate A right
Complement A
Clear A
A = A plus 1
A = A - 1
A = A plus M
A = A - M
A = A.M
A = A + M
A = A M
+
A = 2A
A = A/2
A = NOT A
A = 0
What can the Computer Actually Do?
11
12. • CPU has a set of instructions that it recognizes and responds to
all programs.
• We want computers to execute code as fast as possible.
• This leads to CISC (Complex Instruction Set Computer).
• A CISC has many instructions, but sophisticated.
• Simple ones can be expressed in a short instruction code, say
one byte of data, and execute quickly.
• Complex ones need several bytes, and take a long time.
How Instruction Sets are Made: “CISC”
12
13. How Instruction Sets are Made: “CISC”
A CISC machine is generally recognised by:
• Many instructions (say < 100), with considerable sophistication
• Instruction words are of different length;
• Instructions take different lengths of time to execute.
13
14. • RISC (Reduced Instruction Set Computer) keep the CPU very
simple and fast, and have a limited instruction set.
• One characteristic of the RISC approach is that each instruction
is contained within a single binary word.
• That word must hold all information necessary, including:
(instruction code - address - data ).
• Every instruction takes the same amount of time.
How Instruction Sets are Made: “RISC”
14
15. A RISC machine is generally recognised by:
• Few instructions (say > 100),
• Each performs a very simple action;
• All instructions are single word;
• Almost all instructions take the same length of time to execute.
How Instruction Sets are Made: “RISC”
15
16. A microcontroller is a microprocessor designed primarily to
perform simple control functions.
Microcontrollers usually have these features
• low cost,
• physically small,
• input/output intensive, and capable of easy interfacing,
• limited memory capability,
• ability to operate in a real-time environment.
The Microcontroller
16
17. In certain applications, following further features are essential:
• ability to operate in hostile environment, e.g. high or low
temperature, tolerant to electromagnetic interference,
• low power, with features adapted to battery power.
The Microcontroller
17
18. A microcontroller = microprocessor core + memory + peripherals
Digital
Program
I/0
Microprocessor
Data
Memory
Memory
Core
Analog
I/0
& Timers
Counters
Reset
Power
Clock
Address Buses
Internal Data &
Further
Peripheral
Further
Peripheral
Interrupt(s)
18
19. PIC 16F84A
PIC 16F877
PIC 12F508
Motorola
68HC05B16
PIC 16C72
Motorola 68000
A Gathering of Microprocessors and Microcontrollers
19
20. Family Example
Devices
Instruction
word size
Stack
size
(words)
Number of
instruction
Interrupt
vectors
Baseline 10F200,
12F508,
16F57
12-bit 2 33 None
Mid-range 12F609,
16F84A,
16F631,
16F873A
14-bit 8 35 1
High
Performance
18F242,
18F2420
16-bit 32 75,
including
hardware
multiply
2
(prioritized)
Comparison of 8-bit PIC families:
20
23. Summary
• An embedded system is a product that has one or more computers
embedded within it (Microcontroller).
• Microcontrollers are designed according to accepted electronic and
computer principles.
• A microcontroller = microprocessor core + memory + peripherals
• Microchip offers a wide range of microcontrollers, with different families.
• Each family has identical (or very similar) central architecture and
instruction set.
23