component in modern electronic systems
Completely self-contained with memory and I/O
role: provide inexpensive, programmable logic control and interfacing to
e.g., turn devices on/off, monitor external conditions
Microcontrollers used in a wide number of electronic systems such as:
·Engine management systems in automobiles
·Keyboard of a PC
·Electronic measurement instruments (e.g., digital multimeters, frequency synthesisers, and oscilloscopes)
·Cordless and cellular phones
·Televisions, radios, CD players, tape recording equipment
·Security alarm systems, fire alarm systems, and building services systems
·Remote control devices
·Many, many more
What is a microprocessor?
device that integrates a number of useful functions into a single IC package
Some functions are:
·Ability to execute a stored set of instructions to carry out user defined tasks.
·Ability to access external memory chips to read/write data from/to memory.
·Ability to interface with I/O devices
These form the basic connections between the microprocessor and its memory devices.
What is I/O?
I/O is Input/Output. It can be:
number of digital bits formed into a number of digital inputs or outputs
called a port
usually eight bits
referred to as a BYTE wide port
serial line from/to the microprocessor
(Transmit or TX) and a
serial line to the microprocessor (Receive or RX)
Allows serial data (bit stream) to be transmitted/received via a two-wire interface
Analog to Digital
Converters (ADC) and Digital to Analog Converters (DAC)
Can be obtained as separate ICs (e.g., Intel 8255 PPI, 8259 PIC, 8254 PIT)
Connected to microprocessor in a similar manner to that of the memory devices
Often contain their own memory to support internal operations (ie. registers).
What is a microcontroller?
Basically, a device which integrates a number of the components of a microprocessor system onto a single chip
Only need to be supplied power and clocking
Microcontroller combines on the same chip:
·The CPU core
Variable RAM memory
Most microcontrollers will also combine other devices such as:
·A Timer module to allow the microcontroller to perform tasks for certain time periods.
·Serial I/O (UART) for data flow between microcontroller and devices such as a PC or other microcontroller.
·Analog input and output (e.g., to receive data from sensors or control motors)
·Interrupt capability (from a variety of sources)
·Bus/external memory interfaces (for RAM or ROM)
·Built-in monitor/debugger program
·Support for external peripherals (e.g., I/O and bus extenders)
A typical microcontroller; the different sub units integrated onto the microcontroller chip.
heart of the microcontroller is the CPU core
Traditionally based on an 8-bit microprocessor unit
e.g., Motorola uses basic 6800 microprocessor core in M68HC11 microcontroller devices
Some differences between microprocessors and microcontrollers
suited to contro of I/O devices requiring a minimum component count
MC: suited to processing information in computer systems
MP: processing intensive
powerful addressing modes
instructions to perform complex operations & manipulate large volumes of data
processing capability of MCs never approaches those of MPs
large instructions -- e.g., 80X86 7-byte long instructions
MC: cater to control of inputs and outputs
instructions to set/clear bits
boolean operations (AND, OR, XOR, NOT, jump if a bit is set/cleared), etc.
Extremely compact instructions, many implemented in one byte
(Control program must often fit in the small, on-chip ROM)
& Instructionset support:
MC: built-in I/O operations, event timing, enabling & setting up priority levels
for interrupts caused by external stimuli
MP: usually require external circuitry to do similar things (e.g, 8255 PPI, 8254 PIT,
MP: very wide
large memory address spaces (>4 Gbytes)
lots of data (Data bus: 32, 64, 128 bits wide)
relatively small memory address spaces (typically kBytes)
less data (Data bus typically 4, 8, 16 bits wide)
MP very fast (> 1 GHz)
MC: Relatively slow (typically 10-20 MHz)
since most I/O devices being controlled are relatively slow
MP's expensive (often > $100)
MCs cheap (often $1 - $10)
4-bit: < $1.00
8-bit: $1.00 - $8.00
16-32-bit: $6.00 - $20.00
Microcontroller Software and Programming Tools
Generally done in either the core's native assembly language or C
Sometimes HLL support (often BASIC) is available
Assemblers/Linkers often supplied free by the micro's manufacturer
C compilers vary from free and very buggy to very expensive and only moderately buggy
Environments generally not friendly or reliable
Program development usually done on a PC
Software tools must produce a file to download to the MC's EPROM
Several standard formats (e.g., binary, hex)
EPROM burner often necessary
Can download program to an EPROM emulator
But to reprogram, must us an UV erasor first
Flash memory programmers make this easier
Very easy to reprogram with inexpensive "in-circuit debugger"
Interacts with MC via 3 pins + power + ground
Or can be programmed/debugged with a resident monitor program
on-chip UART for communications with PC
No burner or UV erasor needed
No expensive quartz window required
Expedites program-test-erase-reprogram code development cycle
A program module that communicates with PC software
Typically uses a serial port to talk to a PC's terminal program
Capabilities vary widely
Usually can send/receive text and ASCII-converted numbers
Often has commands to examine/change registers, memory locations, I/O ports
Code and data strorage areas (address spaces) on separate buses
Potentially more efficient
Instructions execute in fewer cycles
Since greater instruction parallelism possible
Instructions and data fetched simultaneously
(new instruction fetches can occur during prior instruction execution)
Example: Microchip's PIC microcontroller
won early competition
Better suited to technology of the time
CISC vs. RISC
(Complex Instruction Set Computers)
Tend to have many instruction in instruction set
Can carry out complex operations
(many used very infrequently)
Many are very long (many bits)
And require many clock cycles
(Reduced Instruction Set Computer)
Short (few bits) and fast
Often orthogonal instruction sets
Can read/write/use all registers in same way
Allows for great power and flexibility
Many other microcontrollers use RISC
Some microprocessors offer both CISC and RISC features
Microcoded versus Hardwired processors
The under cover design of a processor
Processor within a processor
Signals required to execute instructions "fetched" from internal "Control ROM" memory
Allows for great flexibility in instruction set
Easier to design
Slower than hardwired
Signals required to execute instruction generated by logic gates (combinational circuitry)
The "control matrix"
Hitachi H8 (used in the LEGOS RIS RCX)
in late 70s
At the heart of the biggest variety of micros on earth
Biggest player now Philips Electronics (Intel concentrating on PC CPU chipset)
Powerful bit manipulation instructions
part of RAM and many special registers are bit-addressable.
Multiply and divide instructions.
At least two 16-bit timers.
UART capable of 500kb/s at 16MHz on all but very small parts.
Plentiful internal RAM.
Straightforward code addressing - always starts at zero.
I/O design makes bi-directional I/O easy.
Excellent free assembler from Metalink
Free C compiler available
Very quirky instruction set
Confusing variety of internal and external memory spaces.
I/O design prevents true floating inputs, and pins are always high after reset.
Not very fast due to clock division.
Access to external data very weak - single pointer register only.
Poor compiler support - no stack-relative access.
Watchdog not standard
PIC16F452 trainer used in first half of this course
Microchip's MPLAB free development environment
Wide range of sizes and peripheral choices
Many language and tool choices
4 times slower at same clock speed
Relatively weak instruction set
Limited code and data addressing
Complex "banked" addressing
Accumulator-based data processing
Single "working" acculumulator
Von Neumann architecture is easy to understand
Powerful, easy-to-use instruction set
Popular parts are good value
Good support for C compilers
Good support from Motorola
No consistency within family - many variants specialised
Evaluation board (EVB) is expensive, unreliable
in LEGO Mindstorms Robotics Invention System RCX
Similar architecture to the HC11
devices with flash.
Powerful instruction set with good C support
Wide range of 8 and 16-bit devices
Good free C compiler
Nice evaluation/programming boards available
Abundant timers and interrupts