Beruflich Dokumente
Kultur Dokumente
MICROCOMPUTER
ORGANIZATION
M. Jimnez, R. Palomera, & I. Couvertier
Lecture
Slides
Series
OUTLINE
Chapter 3: 2
3.1 BASE
MICROCOMPUTER
STRUCTURE
Base Structure
Architecture
Chapter 3: 3
Input-Output Subsystem
System Buses
Address bus
Data bus
Control bus
Chapter 3: 4
MINIMAL HARDWARE
Central Processing Unit (CPU)
Fetches, decodes, and executes instructions from memory
System Memory
Program memory
Data memory
Input/Output Interface
Connect to the external world
Chapter 3: 5
3.2
MICROCONTROLLERS
VERSUS
MICROPROCESSORS
Microprocessor
Units
Microcontroller
Units
RISC Versus CISC
Architectures
Programmer and
Hardware Model
Chapter 3: 6
MICROPROCESSOR UNITS
Abbreviated MPUs
Contain a General Purpose CPU
ALU, CU, Registers, & BIU
Additional Characteristics
Architecture optimized for accelerating data processing
Include elements to accelerate instruction execution
Chapter 3: 7
MICROCONTROLLER UNITS
Abbreviated MCUs
Contain a Microprocessor Core
Usually less complex than that of an MPU
On-chip Memory
Includes both program and data memory
Typical Peripherals
Timers
I/O ports
Data converters
2014 by M. Jimnez, R. Palomera, & I. Couvertier
Chapter 3: 8
T YPICAL MICROCOMPUTER
Optional
Chapter 3: 9
Chapter 3: 10
RISC VS CISC
CISC (Complex Instruction Set Computer)
Variable length instructions
Large instruction set
Focuses in accomplishing as much as possible with each
instruction
Helps programmers tasks
Augments hardware complexity
Chapter 3: 11
Chapter 3: 12
Chapter 3: 13
Control Unit
3.3 CENTRAL
PROCESSING UNIT
Arithmetic Logic
Unit
Bus Interface Logic
Chapter 3: 14
CPU COMPONENTS
Hardware
Control unit (CU)
Arithmetic Logic Unit
(ALU)
Register set
Bus interface logic
(BIL)
Software
Instruction set
Addressing modes
Chapter 3: 15
CONTROL UNIT
Operation
Governs the CPU working
like a finite state machine
Cycles forever through
three states:
Fetch
Decode, and
Execute
The fetch-decode-execute
cycle is also known as the
instruction cycle or CPU
cycle
Chapter 3: 16
INSTRUCTION CYCLE
Fetch
The program counter (PC) provides the address of the instruction
to be fetched from memory
The instruction pointed by the PC is brought from memory into the
CPUs instruction register (IR)
Decode
The instruction meaning is deciphered
The decoded information is used to send signals to the
appropriate CPU components to execute the instruction
Execute
The CU commands the corresponding functional units to perform
the actions specified by the instruction
At the end of the execution phase, the PC has been incremented
to point to the address of the next instruction in memory
2014 by M. Jimnez, R. Palomera, & I. Couvertier
Chapter 3: 17
Datapath Width
Established by the ALU operand width
Also sets the width of the data bus and data registers
Chapter 3: 18
Chapter 3: 19
REGISTERS
Provide temporary storage for:
Data & operands
Memory addresses
Control words
Register Types
General Purpose
Special Purpose
2014 by M. Jimnez, R. Palomera, & I. Couvertier
Chapter 3: 20
Chapter 3: 21
Chapter 3: 22
Chapter 3: 23
Chapter 3: 24
Chapter 3: 25
Chapter 3: 26
Register Structure
Organized as a 16, 16-bit register file (R0 R15)
Chapter 3: 27
MSP430 ALU
16-bit wide (20-bit in CPUX)
Arithmetic ADD, SUB, CMP operations
BCD arithmetic
Bitwise logic operations
Does not provide for multiplication, division, or FP
Some MSP430 feature a hardware multiplier peripheral device
2014 by M. Jimnez, R. Palomera, & I. Couvertier
Chapter 3: 28
Data Bus
Address Bus
Control Bus
Chapter 3: 29
SYSTEM BUSES
Data bus
Set of lines carrying data and instructions
Data bus lines are bidirectional to allow for reads & writes
READ: A transfer into a CPU register from memory or I/O
WRITE: A transfer or from a CPU register to memory or I/O
Address bus
Set of lines transporting the address information which
uniquely identifies a data cell in memory or peripheral
device
Control bus
Set of lines carrying the signals that regulate the system
activity
2014 by M. Jimnez, R. Palomera, & I. Couvertier
Chapter 3: 30
3.5 MEMORY
ORGANIZATION
MSP430 Memory
Organization
Chapter 3: 31
MEMORY STRUCTURE
The memory subsystem is organized as an array of cells or locations
Each memory location is identified by an address
The contents of a memory cell is a word
A memory word may store instructions or data
Chapter 3: 32
MEMORY T YPES
Chapter 3: 33
Chapter 3: 34
ENDIANNESS
Big Endian:
Data is stored with the most significant byte in the lowest address
and the least significant byte in the highest address
Little Endian
Data is stored the the least significant byte in the lowest address
and the most significant byte in the highest address
Chapter 3: 35
MCU ARCHITECTURES
Von Neumann
A single set of buses for accessing both programs and data
and a single address space
Harvard
Uses separate buses for accessing programs and data and
has separate address spaces
Chapter 3: 36
CS
Chapter 3: 37
Chapter 3: 38
(a)
(b)
Fig. 3.13 Example memory map for a microcomputer with a 16bit address bus. a Global memory map, b Partial memory map.
Chapter 3: 39
Chapter 3: 40
Anatomy of an I/O
Interface
Parallel Versus
Serial I/O
Interfaces
I/O and CPU
Interaction
Timing Diagrams
MSP430 I/O
Subsystem and
Peripherals
Chapter 3: 41
I/O SUBSYSTEM
All the components other than the CPU & memory
connected to the system buses
Timers & Watchdog timers
Communication interfaces
Analog to Digital Converter (ADC)
Digital to Analog Converter (DAC)
Development peripherals
Chapter 3: 42
Chapter 3: 43
Chapter 3: 44
Chapter 3: 45
Chapter 3: 46
Pin
Pin
Chapter 3: 47
TIMING DIAGRAMS
The CPU and hardware components communicate
exchanging signals sent over the system buses
Signal exchanges require protocols
Indicate the times required for the steps in the process
Settling of states
Delays
Order of signals activation, etc.
Chapter 3: 48
Fig. 3.20 : Definitions of timing conventions. (a) Single signal timing, (b) Bus timing
Fig. 3.21 Example of simplified write &read timing diagrams. (a) Read timing, (b) Write timing
2014 by M. Jimnez, R. Palomera, & I. Couvertier
Chapter 3: 49
16-bit Timers
General purpose and Watchdog
Communication Support
USART, SPI, I2C
Data Converters
ADCs and DACs
System Support
POR and brownout reset circuitry
Clock generators and supply voltage supervisors
2014 by M. Jimnez, R. Palomera, & I. Couvertier
Chapter 3: 50
Chapter 3: 51
Register Transfer
Notation
Machine Language
and Assembly
Instructions
Types of
Instructions
The Stack and the
Stack Pointer
Addressing Modes
Orthogonal CPUs
Chapter 3: 52
Source/destination Notation
destination source
Chapter 3: 53
Chapter 3: 54
Assembly Process
Converts an assembly language program into a machine
language program
2014 by M. Jimnez, R. Palomera, & I. Couvertier
Chapter 3: 55
Chapter 3: 56
Chapter 3: 57
INSTRUCTION T YPES
Data Transfer Instructions
Copy data from a source to a destination
Arithmetic-logic Instructions
Perform arithmetic and/or logic operations on operands
Chapter 3: 58
Examples:
MOV R8,R3 ; Copies the contents of R8 into R3
MOV (0xF348),R5 ; Copies into R5 the word at address F348h
PUSH R7 ; Copies onto the top of the stack the contents of R7
2014 by M. Jimnez, R. Palomera, & I. Couvertier
Chapter 3: 59
ARITHMETIC-LOGIC INSTRUCTIONS
Perform arithmetic and/or logic operations on data
destination (DestinationOperand SourceOperand)
Examples:
ADD R7,R5 ; Places on R5 the sum of the contents of R5 and R7
AND #05AD,R6 ; Places on R6 the bitwise result of anding the
contents of R6 and the value 05ADh
ROTL R3 ; Rotates the contents of register R3 one position to the
left
2014 by M. Jimnez, R. Palomera, & I. Couvertier
Chapter 3: 60
Chapter 3: 61
Examples:
JMP #F345h ; Loads PC with the address 0xF345 so program execution
continues there
JZ #F345 ; Loads PC with the address 0xF345 if the Zero Flag is set
CALL Sub1 ; Saves PC onto the stack and loads PC with address Sub1.
When special instruction RET is executed, the PC is
restored from the stack
2014 by M. Jimnez, R. Palomera, & I. Couvertier
Chapter 3: 62
CONDITIONAL JUMPS
Conditional Jump Instructions enable decision
making in programs
Chapter 3: 63
Chapter 3: 64
THE STACK
A portion of memory used to temporarily store data
Access through special register Stack Pointer (SP)
Last-in-First-out (LIFO) operation
Stack contents is volatile
Stack Operations
PUSH: Places data on top of the stack
POP (or pull) : Retrieves data from the top of the stack
Chapter 3: 65
STACK OPERATIONS
Chapter 3: 66
Pop or Pull
Copy the contents in the actual TOS to the destination
Update the stack pointer to point to the new TOS
Chapter 3: 67
Chapter 3: 68
Chapter 3: 69
Function Call
Saves PC onto stack
2.
Function Execution
PC loaded with function address
3.
4.
Chapter 3: 70
ADDRESSING MODES
Addressing modes tell the CPU how to obtain the
data needed to execute an instruction
The data may be
Explicitly supplied with the instruction
Stored in a CPU register
Stored at a memory location
Stored in an I/O device register
Chapter 3: 71
Chapter 3: 72
Chapter 3: 73
Chapter 3: 74
Chapter 3: 75
ORTHOGONAL CPU
A CPU is said to be orthogonal if all its registers and
addressing modes can be used as operands
Either source or destination
Excludes using the immediate addressing mode as
destination
Chapter 3: 76
3.8 MSP430
INSTRUCTIONS AND
ADDRESSING MODES
Instruction Set
Summary
Chapter 3: 77
Chapter 3: 78
3.9 INTRODUCTION TO
INTERRUPTS
Device Services:
Polling Versus
Interrupts
Interrupt Servicing
Events
What is Reset?
Chapter 3: 79
Service by Interrupt
The device notifies the CPU when service is needed
Interrupt request
Meanwhile, the CPU can be used for other tasks or sent to sleep
mode
When service request arrives, CPU interrupts what it is doing to
execute the service instructions (Interrupt Service Routine ISR)
Upon completion (IRET) control is transferred back to interrupted
task
2014 by M. Jimnez, R. Palomera, & I. Couvertier
Chapter 3: 80
INTERRUPT T YPES
Maskable Interrupt
Can be blocked by clearing the GIE flag
Most common type of interrupt
GIE cleared by RESET
GIE automatically cleared when entering an ISR
Chapter 3: 81
Chapter 3: 82
Chapter 3: 83
WHAT IS A RESET?
An asynchronous signal causing the CPU to start from
a predefined known state
Power-on Reset
Generated when power is applied for the first time
Loads PC with Reset Address
Clears Status register, including GIE
Chapter 3: 84
3.10 NOTES ON
PROGRAM DESIGN
Chapter 3: 85
PROGRAMMING RECOMMENDATIONS
Program Planning & Design
Plan your program before start coding
Chapter 3: 86
Chapter 3: 87
Chapter 3: 88
General Features
Naming
Conventions
Chapter 3: 89
Main Features
Standard 16-bit Architecture
1992
x3xx
2002
x1xx
1996
x4xx
Powerful Processing
2005
x2xx
2008
x5xx
2009
x6xx
Internet Sites
3.12 DEVELOPMENT
TOOLS
Programming and
Debugging Tools
Development Tools
Other Resources
Chapter 3: 91
MSP430 TOOLS
Chapter 3: 92
Chapter 3: 93