Professional Documents
Culture Documents
MICROPROCESSOR/
MICROCONTROLLER FUNDAMENTALS
MICROCONTROLLER
(IN MODERN SYSTEMS)
A microprocessor
• key element of a mechatronic device
• responsible for:
– collecting information
– processing and decision making
– storing
• handle data in digital form
• differences from logic control circuits etc. include:
– programmability
– digital processing
– speed
– ease of integration
– Cost, size..
General Purpose vs Embedded Processors
• embedded systems are often required to be low cost, low power and
small size.
Outline
• Review Microprocessor Fundamentals
– MPU Register set and Internal Architecture
– MPU buses
– Memory Considerations
– MPU interfacing
• M68HC11 Microcontroller
– Architechture
– Ports and registers
– Application programming
Review Of MPU Fundamentals
• For Simplicity look at a simple model of
an MPU
– 8-bit
– 64K address space
– Intel style interface
The CPU
• processes the data by executing a program stored
in the memory
• performs sequence of fetch-and-execute
operations
• consists of:
– Control Unit, ALU, Registers
FFFFh
0000h
1 byte
µP memory devices
static
RAM
dynamic
MEMORY
PROM
DEVICES
ROM EPROM
EEPROM (E2PROM)
Buses
• Data bus - to transfer the data associated
with the processing function of the
microprocessor. 8 lines, typically
• Address bus - contains the address of a
specific memory location for accessing stored
data. 16, typically
• Control bus - carries the control signals to
the memory and the I/O devices. Arbitrary
number, often 15
Buses
• concepts of address and data is fundamental to
the operation of the microprocessor
• memory - consists of locations uniquely
identified by CPU through their address
• CPU communicates with those addresses to
read and write the data - all data.
• the communications go via buses
• the CPU - responsible for control of address,
data and control buses
Buses
• All devices attached to data bus - potential clash
• Devices connected to data buses can be driven
to high-impedance states
• The ability of devices to set their output at either
logic 1, logic 0 or in a high impedance state is
an essential feature of common bus systems
and is termed a tristate device.
typical 64k memory map
0xFFFF
0xF000 OS ROM 4K bytes
0x9000
0x8000 I/O peripheral 4K bytes
64K byte
Free 24K bytes
0x2000
0x1000 RAM 4K bytes
0x0000 ROM 4K bytes
Memory – physical arrangement
Memory Read and Write Cycles
Chip Enable
Output Enable
Read Enable
Processor asserts the
Memory Read signal
Write Cycle
Processor puts out RAM
address on the Address
Bus, e.g. 9
0000 0000 0000 1001
Address
Data
8K bytes D0..D7
Chip Enable
Output Enable
Write Enable
Processor asserts the
Memory Write signal
Timing diagrams - read/write cycle
1 2
CLOCK CLOCK
DATA DATA
data valid data valid
READ WRITE
CLOCK CLOCK
DATA DATA
data valid data valid
READ WRITE
Interrupt Received
Push Registers
onto the Stack
Complete Current Instruction
PushFlags Register onto Stack
Push Instruction Pointer onto Stack
Clear Interrupt Enable Falg
Trap to Start of ISR BODY of the ISR
Operations shown in
boxes are carried
automatically by MPU
hardware
Pop Registers
from the Stack
Main Program
Resumes
Instruction sets
• The set of instructions given to the µP to
execute a task is called an instruction set
• Generally, instructions can be classified into the
following categories:
– Data transfer
– Arithmetic
– Logical
– Program control
• Differ depending on the manufacturer, but some
are reasonably common to most µP's.
Data transfer
• 1. Load
• reads the content of a specified memory location
and copies it to the specified register location in
the CPU
• 2. Store
• copies the current contents of a specified
register into a specified memory location.
Arithmetic
• 3. Add
• Adds the contents of a specified memory location
to the data in some register
• 4. Decrement
• subtracts 1 from the content of a specified
location.
• 5. Compare
• indicates whether the contents of a register are
greater than, less than or same as the contents of
a specified memory location. The result appears
as a flag in the status register.
Logical
• 6. AND
• carries out the logical AND operation with the
contents of a specified memory location and the
data in some register
• 7. EXCLUSIVE OR - (similar to 6, but for exclusive OR)
• 8. Logical shift
• moving the pattern of bits in the register one place
to the left or right by moving zero (0) to the end of
the number
• 9. Arithmetic shift
• moving the pattern of bits one place left/right but
with copying of the end number into the vacancy
created by shift
Program control
• 11. Jump
• changes the sequence in which the program is
executed. So the program counter jumps to some
specified location (other than sequential)
• 12. Branch
• a conditional instruction which might be 'branch if
zero' or 'branch if plus'. It is followed if the right
conditions are met.
• 13. Halt
• stops all further microprocessor activities
Fetch Decode Execute Cycle
Obtain instruction from program storage
Instruction
Fetch
Next
Determine successor instruction
Instruction
Machine Cycles and the System Clock