Introduction To Microcontroller: 1 Razkiah@kym - Edu.my
Introduction To Microcontroller: 1 Razkiah@kym - Edu.my
Introduction to Microcontroller
[email protected] 1
Major Functions of a Computer
• Computer
Data Processing
Data Storage
[email protected] 2
Major Components of a Computer
• A computer consists of
– CPU
– Memory
– I/O
– System Bus
[email protected] 3
CPU: Central Processing Unit
• CPU
– Is the “brain” of a computer
– It consists of
• Control unit and instruction decoder
• Arithmetic and logic unit
• Registers
[email protected] 4
Memory
Memory Address-1 Memory Location-1
Memory Address-2 Memory Location-2
1 2 3 4 5 6 7 8
[email protected] 5
I/O Module
• Human-readable I/Os:
Suitable for communicating with the user
Examples: monitor, keyboard, mouse, joystick, video display terminals,
printers, scanner, microphone, and speaker.
• Machine-readable I/Os:
Suitable for communicating with equipment: magnetic disk, optical disk,
sensors (temperature, light, motion, and so on), and actuators (motor, relay,
and pneumatic).
Communication I/Os: suitable for communicating with remote devices: infra-
red (IR) interface, radio frequency (RF) interface, bluetooth device, and
Wireless LAN.
[email protected] 6
System Bus
• The collection of paths connecting the various modules of the computer
• Different types of connection for different types of unit
Control bus
Address bus
Data bus
[email protected] 7
Types of Exchanges Between Modules
Read Read
Memory Write Internal
Write Data
Address I/O Module
N words
Address Data External
0 Internal Data
Data MPorts
Data Interrupt
N1 External Signals
Data
Instructions
Control
Data CPU Signals
Data
Interrupt
Signals
[email protected] 8
Basic Instruction Cycle
PC = 0000H Start
Fetch Instruction
Fetch Cycle
PC = PC + n
Execute
Instruction Execute Cycle
End
[email protected] 9
Fetch Cycle
• Program Counter (PC) holds the address of the next instruction to
fetch
• Increment PC
– unless told otherwise
[email protected] 10
Execute Cycle
• Processor-memory
– Data transfer between the CPU and main memory
• Processor-I/O
– Data transfer between the CPU and I/O module
• Data processing
– Some arithmetic or logical operation on data
• Control
– Alteration of sequence of operations
– Example: jump
• Combination of the above
[email protected] 11
Instruction Cycle: State Diagram
Instructi Operand Operand
on Fetch Fetch Store
Multiple Multiple
operands results
CPU Read
Memory
Memory request
Data bus
Address bus
[email protected] 13
Memory Read Operation: Step 2
Accessed location at XXXX
Data bus
Address bus
[email protected] 14
Memory Read Operation: Step 3
The CPU removes the Memory Request
and Read signals
Address bus
[email protected] 15
Memory Write Operation: Step 1
The CPU sends out a Memory Request control
signal to indicate that it wants to perform a
memory operation
CPU Memory
Memory request
Data bus
Address bus
[email protected] 16
Memory Write Operation: Step 2
The CPU sends out a Write control signal to
indicate that valid data is available on the data
bus
CPU Write Memory
Memory request
Register
Data bus
Address bus
[email protected] 17
Memory Write Operation: Step 3
The CPU removes the Write signal to complete
the memory write operation
Address bus
[email protected] 18
What Is Microprocessor?
CPU
A microprocessor is a single-chip CPU used in the computer system. It contains all the
necessary computer components except memory and I/O ports. Microprocessors are most
commonly used as the CPU in computer systems (in the world of personal computers, the
terms “microprocessor” and “CPU” are used interchangeably).
[email protected] 19
What Is Microcontroller?
A microcontroller is a true
single-chip computer
system. It contains a CPU,
memory (RAM and ROM),
I/O modules (serial and
parallel interfaces), timers,
counters, and interrupt
MEMORY
scheduling circuitry – all
I/O SYSTEM within a single IC.
BUS
CPU
[email protected] 20
General Structure of a MCU
I/O
Interrupt
Control Serial Parallel
Interface Interface
CPU
[email protected] 21
Microprocessors vs. Microcontrollers
Perspective Microprocessor Microcontroller
[email protected] 24
8051 Microcontroller / MCS-51 TM
[email protected] 25
Original 8051 Specifications
Feature Quantity
ROM 4K bytes
Timer 2
Serial port 1
Interrupt sources 6
[email protected] 26
ROM Technology
• Mask ROM programmed by the IC manufacturer
• NV RAM allows program codes to be loaded into the on-chip ROM while it
is in the system (in-system programming).
• It has the ability to change the ROM contents one byte at a time, as opposed
to EPROM and flash memory in which the entire ROM must be erased before
it can be reprogrammed.
[email protected] 27
Popular 8051 Variants
Part Number Pin Mfr RAM (bytes) ROM (bytes) Descriptions
AT89C2051 20 Atmel 128 2K Flash 15 I/Os, Analog comparator, LED drive outputs
[email protected] 28
Recommended References
Recommended References:
1) Koo Voon Chet, et. al., “The 8051 Cookbook”, 2nd Edition, Prentice Hall, 2006.
2) James W. Stewart and Kai X. Miao, “The 8051 Microcontroller: Hardware, Software and
Interfacing,” 2nd Edition, Prentice Hall, 1999.
3) Muhammad Ali Mazidi, “The 8051 Microcontroller and Embedded Systems,” Prentice
Hall, 2000.
5) Scott Mackenzie, “The 8051 Microcontroller,” 3rd Edition, Prentice Hall, 1999.