Sana’a University
Engineering College
Lect1. Introd. To MicroProcessors
&
Control Systems
By: Dr. Farouk Al-Fuhaidy
Text Books
The 8051 Microcontroller and Embedded Systems.
Author: Mohammad Ali Mazidi & Janice Gillispie Mazidi
❖ PIC Microcontroller and Embedded Systems Using Assembly and C.
Author: Mohammad Ali Mazidi, et al.
Grading Policy:(100)
➢Attendance, Assignments + Quizzes: 10(every week)
➢Midterm Exam: 10(Will be ISA on 30th Nov. 2017)
➢Project and Lab Exam : 20 ( Due to 28th Dec. 2017)
➢Final Exam: 60 (Depends on Univ. Policy)
Introduction
Lecture note 1
outline
• Microprocessor
• Micro-computer
• Microcontroller
• 3_Bus (Data, Address, Control)
• I/O
• Memory
Microprocessor (µP)(MPU)
µP = CPU on a single chip
Components of CPU
Registers: Temporary storage locations for program
instruction or data.
The Arithmetic Logic unit (ALU): performs both
arithmetic and logical operations
Timing and Control Circuits: keeps all working
together in the right time sequence
Bus: n_bit (internal) path for data exchange
CPU
Microprocessor
• Microprocessor=µP=MPU
• Tasks
– processing data
– controlling all components
• µP executes instructions in memory (ROM)
– Fetch, Decode, Execute
Microcomputers
• Micro-computer (µ-Computer)
• small computer
• specifically for data acquisition and control applications
Microcomputers
All Microcomputers consist of (at least) :
Microprocessor Unit (µP)
Program Memory (ROM)
Data Memory (RAM)
Input / Output ports (IO)
Bus System (Internal and External)
(and Software)
MPU is the brain of microcomputer
The Input/Output (I/O) System
• I/O links MPU to outside world.
• Input port : a circuit through which an external device
can send signals (data) to the MPU.
• Output port is a circuit that allows the MPU to send
signals (data) to external devices.
• I/O ports connect both digital and analogue devices by
DAC , ADC , Display , Keypad, switches , etc.
Bus
• A common communications pathway that carry
information between the various elements of system
• The term BUS refers to
– A group of wires .
– Or conduction tracks on a printed circuit board (PCB).
Through which binary information is transferred.
• Subsystems are connected together through BUS
3_Bus
• There are three main bus grouPs
– ADDRESS BUS
– DATA BUS
– CONTROL BUS
Data Bus
• The Data Bus carries the data which is transferred
throughout the system ( bi-directional) (Tow ways)
• Examples of data transfers
– Program instructions being read from memory into
MPU.
– Data being sent from MPU to I/O port.
– Data being read from I/O port going to MPU.
– Results from MPU sent to Memory.
• These are called read and write operations.
Address Bus
Address = binary number that identifies a specific
memory storage location or I/O port involved in a
data transfer.
Address Bus = pathway transmit address to memory
or I/O port.
Address Bus is unidirectional (one way)
addresses are always issued by the MPU
Control Bus
Control Bus = grouP of control signals
Control signals are unidirectional, and are
mainly outputs from the MPU.
provide synchronization (timing control)
between MPU and other components.
Example
RD: (read signal) read data into MPU
WR: (write signal) write data from MPU
Main memory
Memory
Stores programs
Provides data to the MPU
Accepts result from the MPU for storage
Main memory Types
ROM : read only memory, Contains program (Firmware),
does not lose its contents when power is removed (Non-
volatile).
RAM: random access memory (read/write memory) used
as variable data, loses contents when power is removed
(volatile). When power up RAM will contain random data
values.
Read-Only Memory (ROM)
• µP can read instructions from ROM quickly
• Cannot write new data to the ROM ( It can only write
data to special type of ROM.
• ROM remembers the data, even after power cycled.
• When power is turned on, the microprocessor will start
fetching instructions from ROM (bootstrap )
Available ROMs
• Masked ROM or just ROM
• PROM or programmable ROM(once only)
• EPROM (erasable via ultraviolet light) =UVROM
• EEPROM (electrically erasable ROM)
– fast writing slow reading
– can program millions of times
– useless for storing program
– good for save configuration information.
• Flash EPROM or Flash EEPROM
– re-writable about 10000 times
– usually must write a whole block not just 1 or 2 bytes,
– slow writing fast reading
ROM
A0 D
A1 0
D
1
m bit A2 D n bit
Address 2 Data
Am-1 2 m ( n) Dn-1
m ROM
Capacity :
2 PROM
EEPROM
: Output Enable
OEconnect to RD of µP
CE (CS ) : Chip Enable
CE OE
RAM (Random Access
Memory)
µP can read the data from RAM quickly
µP can write new data to RAM quickly
RAM forgets its data if power is turned off
Two type is available :
Static RAM(SRAM): FF base, fast, expensive, applied
for cache , no refresh
Dynamic RAM (DRAM): Cap. base, slow , low cost
high capacity/volume , need refresh.
RAM
A0 D
A1 0
D
1
m bit A2 D n bit
Address 2 Data
m Am-1 2 m ( n) Dn-1
Capacity : 2
RAM Data bus is
Bidirectional
RD : Read signal
connect to MemRD of µP
WR : Write signal
connect to MemWR of µP
CS : Chip Select CS WR RD
The differences between
µP & µC
Intruduction
• Microprocessor = CPU on a single chip.
– ALU + registers + control +…
• Micro-computer = small computer
– µP + I/O + memory + peripheral + …
• Microcontroller (µC)
– µ-Computer on a single chip of silicon
µP vs. µC
MICROPROCESSOR
MICROCONTROLLER
µC base system
• Small power consumption
• Single chip, small board
• Implementation is easy
• Low cost
• µC can reprogram on the fly(ISP)
µP vs. µC Applications
• µ Ps are suitable to processing information in computer
systems → Limited applications
• µ Cs are suitable to control of I/O devices in designs requiring
a minimum component→ Wide applications
µC Applications(Embedded System)
µCs
• Many µCs are existing right now.
– 8051, 68HC11, Z8, ARM series, PIC series and etc.
• We may widely divide it with
– How it is designed (RISC/CISC architecture)
– n-bits Microcontroller Processor ( 8, 16, 32, …)
– Manufacturer (Intel, Atmel, Microchip, Philips, Siemens, Dallas
Semiconductor, …)
– ROM technology (EROM, EEPROM, Flash ,… Programming
Serial/Parallel)
– RAM/ROM capacity
– Other features (ADC/DAC, WatchDog,timer/counter, Number of
IO pins, No. of Interrupt sources , … )
Choosing a Microcontroller
• meeting the computing needs of the task efficiently and
cost effectively
– speed, the amount of ROM and RAM, the number of I/O ports
and timers, size (packaging), power consumption
– easy to upgrade
– cost per unit
• availability of software development tools
– assemblers, debuggers, compilers, emulator (simulator), technical
support
• wide availability and reliable sources of the
microcontrollers
MICROCONTROLLER
How can I program a microcontroller?
➢Microcontrollers have traditionally been programmed using the assembly language of
the target device.
➢Microcontrollers can also be programmed using a high-level language, such as BASIC,
PASCAL, or C.
How a microcontroller does operate?
➢Basically, a microcontroller executes a user program which is loaded in its program
memory.
➢Under the control of this program, data is received from the external devices (inputs),
manipulated and then sent to external devices (outputs).
REQUIRED HARDAWRE AND SOFTWARE
Introducing Embedded Systems
and the Microcontrollers
Chapter One
Dr. Gheith Abandah 36
Outline
• Definition of Embedded Systems
• Examples
• Computer Essentials
• Microprocessors and Microcontrollers
• PIC Microcontrollers
• 12 Series PIC
Dr. Gheith Abandah 37
Definition of Embedded Systems
• Embedded system: is a system whose
principal function is not computational,
but which is controlled by a computer
embedded within it.
Dr. Gheith Abandah 38
Examples: Refrigerator
Dr. Gheith Abandah 39
Examples: Car Door
Dr. Gheith Abandah 40
Examples: Electronic Ping-pong
Dr. Gheith Abandah 41
Examples: Derbot Autonomous Guided
Vehicle
Dr. Gheith Abandah 42
Examples: Derbot Autonomous Guided
Vehicle
Dr. Gheith Abandah 43
Outline
• Definition of Embedded Systems
• Examples
• Computer Essentials
• Microprocessors and Microcontrollers
• PIC Microcontrollers
• 12 Series PIC
Dr. Gheith Abandah 44
Computer Essentials
Dr. Gheith Abandah 45
Computer Essentials
• Instruction Sets
– CISC: Complex Instruction Set Computer
– RISC: Reduced Instruction Set Computer
• Memory Types
– Volatile: Random Access Memory (RAM)
– Non-volatile: Read Only Memory (ROM)
Dr. Gheith Abandah 46
Von Neumann and Harvard Computers
Dr. Gheith Abandah 47
Microprocessors and Microcontrollers
• The microprocessor is a processor on one
silicon chip.
• The microcontrollers are used in embedded
computing.
• The microcontroller is a microprocessor with
added circuitry.
Dr. Gheith Abandah 48
Microcontrollers
Dr. Gheith Abandah 49
Microcontroller Families
Dr. Gheith Abandah 50
Microcontroller Packaging and
Appearance
From left to right: PIC 12F508, PIC 16F84A, PIC
16C72, Motorola 68HC05B16, PIC 16F877,
Motorola 68000
Dr. Gheith Abandah 51
Outline
• Definition of Embedded Systems
• Examples
• Computer Essentials
• Microprocessors and Microcontrollers
• PIC Microcontrollers
• 12 Series PIC
Dr. Gheith Abandah 52
PIC Microcontrollers
• Peripheral Interface Controller (PIC) was
originally designed by General Instruments
• In the late 1970s, GI introduced PIC® 1650 and
1655 – RISC with 30 instructions.
• PIC was sold to Microchip
• Features: low-cost, self-contained, 8-bit,
Harvard structure, pipelined, RISC, single
accumulator, with fixed reset and interrupt
vectors.
Dr. Gheith Abandah 53
PIC Families
PIC Family Stack Size Instruction No of Interrupt
Word Size Instructions Vectors
12CX/12FX 2 12- or 14-bit 33 None
16C5X/16F5X 2 12-bit 33 None
16CX/16FX 8 14-bit 35 1
17CX 16 16-bit 58 4
18CX/18FX 32 16-bit 75 2
‘C’ implies CMOS technology; Complementary Metal Oxide Semiconductor
‘F’ insert indicates incorporation of Flash memory technology
Example: 16C84 was the first of its kind. It was later reissued as the 16F84,
incorporating Flash memory technology. It was then reissued as 16F84A.
Dr. Gheith Abandah 54
12 Series PIC
The small 12F508
Dr. Gheith Abandah 55
PIC 12F508/509 pin connection
diagram
Dr. Gheith Abandah 56
The 12F508 Architecture
Dr. Gheith Abandah 57
Summary
• An embedded system is a product that has one or more computers
embedded within it, which exercise primarily a control function.
• The embedded computer is usually a microcontroller: a microprocessor
adapted for embedded control applications.
• Microcontrollers are designed according to accepted electronic and
computer principles, and are fundamentally made up of microprocessor
core, memory and peripherals.
• Microchip offers a wide range of microcontrollers, divided into a number
of different families. Each family has identical central architecture and
instruction set. However, common features also appear across all their
microcontrollers.
• The Microchip 12F508 is a good microcontroller to introduce a range of
features of microcontrollers in general and of PIC microcontrollers in
particular.
Dr. Gheith Abandah 58