Sie sind auf Seite 1von 12

Chapter 1

Introduction to Microcontrollers



Creating applications for the microcontrollers is different than any other development job in
electronics and computing. Before selecting a particular device for an application, it is important
to understand what the different options and features are and what they can mean with regard
to developing the application.
The purpose of this chapter is to introduce the concept of a microcontroller, present
features of microcontrollers and its applications. The reminder of the book will go through and
present different types of microcontrollers and also programming and interfacing techniques
of microcontroller, mainly 8051, in detail.



Simply an embedded controller is a controller that is embedded in a greater system. A rigid

definition is difficult to formulate, since the usual result is something like most embedded
controllers are... The problem here is most. We cant seem to shake that word from the
definition. No matter how precise one feels his definition is, some people will come and find an
exception, or two, or more.
One could say that an embedded controller is a controller (or computer) that is embedded
into some device for some purpose other than to provide general purpose computing. Of course,
this is not the precise definition.
One common misconception is that an embedded controller is the same as a
microcontroller. How about all of those 68000s, 32032s, x86s, Z80s, and so on that are used as
embedded controllers. They arent microcontrollers.
We might be correct by stating that an embedded controller controls something (for
example controlling a device such as a microwave oven, car braking system, or a cruise missile).
The main thing is not to get to hang up on precise definitions. It all depends on individuals
point of view.



A controller is used to control some process. At one time, controllers were built exclusively
from logic components, and were usually large, heavy boxes. Later on, microprocessors were


used and the entire controller could fit on a small circuit board. This is still commonone can
find many controllers powered by one of the many common microprocessors (including Zilog
Z80, Intel 8088, Motorola 6809, and others).
As the process of miniaturization continued, all of the components needed for a controller
were built right onto one chip. A one chip computer, or microcontroller was born. A CPU built
into a single VLSI chip is called microprocessor. A digital computer having microprocessor as
the CPU along with I/O devices and memory is known as microcomputer.
A microcontroller is a highly integrated chip which includes, on one chip, all or most of
the parts needed for a controller. The microcontroller could be called a one-chip solution. It
typically includes: CPU (central processing unit), RAM (Random Access Memory), EPROM/
PROM/ROM (Erasable Programmable Read Only Memory), I/O (input/output)serial and
parallel timers interrupt controller.
By only including the features specific to the task (control), cost is relatively low. A
typical microcontroller has bit manipulation instructions, easy and direct access to I/O (input/
output), and quick and efficient interrupt processing. Microcontrollers are a one-chip solution
which drastically reduces parts count and design costs. Figure 1.1 shows the block diagram of
a typical microcontroller.










Program Counter

Figure 1.1


A Block Diagram of a microcontroller

Introduction to Microcontrollers



1.3.1 Fabrication Techniques

CMOS (Complementary Metal Oxide Semiconductor)
This is the name of a common technique used to fabricate most (if not all) of the newer
microcontrollers. CMOS requires much less power than older fabrication techniques, which
permits battery operation. CMOS chips also can be fully or near fully static, which means that
the clock can be slowed up (or even stopped) putting the chip in sleep mode-CMOS has a much
higher immunity to noise (power fluctuations or spikes) than the older fabrication techniques.
PMP (Post Metal Programming)
PMP is a high-energy implantation process that allows microcontroller ROM to be
programmed after final metallization. Usually ROM is implemented in the second layer die,
with nine or ten other layers then added on top. That means the ROM pattern must be specified
early in the production process, and completed prototypes devices wont be available typically
for six to eight weeks. With PMP, however, dies can be fully manufactured through metallization
and electrical tests (only the passivation layers need to be added), and held in inventory. This
means that ROM can be programmed late in production cycle, making prototypes available in
only two weeks.
1.3.2 Architectural Features
Von-Neuman ArchitecTure
Microcontrollers based on the Von-Neuman architecture have a single data bus that is used
to fetch both instructions and data. Program instructions and data are stored in a common
main memory. When such a controller addresses main memory, it first fetches an instruction,
and then it fetches the data to support the instruction. The two separate fetches slows up the
controllers operation. Figure 1.2 shows the Von-Neuman Architecture.

Instruction decode



and built-in


Figure 1.2


Von-Neuman Architecture


Microcontrollers based on the Harvard Architecture have separate data bus and an instruction
bus. This allows execution to occur in parallel. As an instruction is being pre-fetched,
the current instruction is executing on the data bus. Once the current instruction is complete,
the next instruction is ready to go. This pre-fetch theoretically allows for much faster execution
than Von-Neuman architecture, but there is some added fabrication complexity. Figure 1.3
shows the Harvard Architecture.
Control space




PC stack
Processor and
register interface

Figure 1.3


Harvard Architecture

Almost all of todays microcontrollers are based on the CISC (Complex Instruction Set Computer)
concept. The typical CISC microcontroller has well over 80 instructions, many of them very
powerful and very specialized for specific control tasks. It is quite common for the instructions
to all behave quite differently. Some might only operate on certain address spaces or registers,
and others might only recognize certain addressing modes.
The advantages of the CISC architecture is that many of the instructions are macrolike, allowing the programmer to use one instruction in place of many simpler instructions.
The industry trend for microprocessor design is for Reduced Instruction Set Computers (RISC)
designs. This is beginning to spill over into the microcontroller market. By implementing fewer
instructions, the chip is able to implement some performance enhancing features. The benefits
of RISC design simplicity are a smaller chip, smaller pin count, and very low power consumption.
Among some of the typical features of a RISC processor-Harvard architecture allows
simultaneous access of program and data, and overlapping of some operations for increased
processing performance, Instruction pipelining increases execution speed, Orthogonal
(symmetrical) instruction set for programming simplicity: allows each instruction to operate
on any register or use any addressing mode: instructions have no special combinations,
exceptions, restrictions, or side effects


Introduction to Microcontrollers

Actually, a microcontroller is by definition a Reduced Instruction Set Computer. It could really
be called a Specific Instruction Set Computer (SISC). The [original] idea behind the
microcontroller was to limit the capabilities of the CPU itself, allowing a complete computer
(memory, I/O, interrupts, etc) to fit on the available chip. At the expense of the more general
purpose instructions that make the standard microprocessors (8088, 68000, 32032) so easy to
use, the instruction set was designed for the specific purpose of control (powerful bit
manipulation, easy and efficient I/O, and so on).
1.3.3 Advanced Memory Options
EEPROM (Electrically Erasable Programmable Read Only Memory)
Many microcontrollers have limited amounts of EEPROM on the chip. EEPROM seems more
suited (because of its economics) for small amounts of memory that hold a limited number of
parameters that may have to be changed from time to time. This type of memory is relatively
slow, and the number of erase/write cycles allowed in its lifetime is limited.
Flash provides a better solution than regular EEPROM when there is a requirement for large
amounts of non-volatile program memory. It is both faster and permits more erase/write cycles
than EEPROM.
Battery backed-up static RAM is useful when a large non-volatile program and DATA space is
required. A major advantage of static RAM is that it is much faster than other types of nonvolatile memory so it is well suited for high performance application. Also there are no limits
as to the number of times that it may be written to so it is perfect for applications that keep
and manipulate large amounts of data locally.
Using nonvolatile memory as a place to store program memory allows the device to be
reprogrammed in the field without removing the microcontroller from the system that it controls.
One such application is in automotive engine controllers. Reprogrammable non-volatile program
memory on the engines microcontroller allows the engine controller program to be modified
during routine service to incorporate the latest features.
A OTP (One Time Programmable) part uses standard EPROM, but the package has no
window for erasing. Once your program is written into the device with a standard EPROM
programmer, it cannot be erased or modified.
As product design cycles get shorter, it is more important for micro manufacturers to
offer OTPs as an option. This was commonly used for limited production runs before a ROM
mask in order to test code.
Either by encryption or fuse protection, the programmed software is protected against
unauthorized snooping (reverse engineering, modifications, piracy, etc.).
This is only an option on OTPs and Windowed devices. On Masked ROM devices, security
is not neededthe only way to read code would be to rip the microcontroller apart with a
scanning electron microscope.



1.3.4 Power Management and Low Voltage

There are a few interesting rules of thumb regarding transistors:
The amount of power they dissipate is proportional to their size. If you make a
transistor half as big, it dissipates half as much power.
Their propagation delay is proportional to their size. If you make a transistor half as
big, its twice as fast.
Their cost is proportional to the square of their size. If you make them half as big,
they cost one quarter as much.
The power, speed, and cost improved by making a transistor smaller. The only drawback
is that they are harder to make.
Brownout protection is usually an on-board protection circuit that resets the device when the
operating voltage (Vcc) is lower than the brownout voltage. The device is held in reset and will
remain in reset when Vcc stays below the Brownout voltage. The device will resume execution
(from reset) after Vcc has risen above the brownout Voltage.
The device can be placed into IDLE/HALT mode by software control. In both Halt and Idle
conditions the state of the microcontroller remains unchanged. RAM is not cleared and any
outputs are not changed.
In IDLE mode, all activities are stopped except: associated on-board oscillator circuitry
watchdog logic (if any), the clock monitor, the idle timer (a free running timer). Power supply
requirements on the microcontroller in this mode are typically around 30% of normal power
requirements of the microprocessor. Idle mode is exited by a reset, or some other stimulus
(such as timer interrupt, serial port, etc.). A special timer/counter (the idle timer) causes the
chip to wake up at a regular interval to check if things are OK. The chip then goes back to
IDLE mode is extremely useful for remote, unattended data logging - the microprocessor
wakes up at regular intervals, takes its measurements, logs the data, and then goes back to
In Halt mode, all activities are stopped (including timers and counters). The only way to
wake up is by a reset or device interrupt (such as an I/O port). The power requirements of the
device are minimal and the applied voltage (Vcc) can sometimes be decreased below operating
voltage without altering the state (RAM/Outputs) of the device Current consumption is typically
less than 1 microampere.
A common application of HALT mode is in laptop keyboards. In order to have maximum
power saving, the controller is in halt until it detects a keystroke (via a device interrupt). It
then wakes up, decodes and sends the keystroke to the host, and then goes back into halt
mode, waiting either for another keystroke, or information from the host.


Introduction to Microcontrollers

The Multi-Input Wakeup (MIWU) feature is used to return (wakeup) the microcontroller from
either HALT or IDLE modes. Alternately MIWU may also be used to generate up to 8 edge
selectable external interrupts. The user can select whether the trigger condition on the pins is
going to be either a positive edge (low to high) or a negative edge (high to low).
1.3.5 Input/Output
A UART (Universal Asynchronous Receiver Transmitter) is a serial port adapter for
asynchronous serial communications.
A USART (Universal Synchronous/Asynchronous Receiver Transmitter) is a serial port adapter
for either asynchronous or synchronous serial communications. Communications using a USART
are typically much faster (as much as 16 times) than with a UART.
A synchronous serial port doesnt require start/stop bits and can operate at much higher clock
rates than an asynchronous serial port. Used to communicate with high speed devices such as
memory servers, display drivers, additional A/D ports, etc. Can also be used to implement a
simple microcontroller network.
Converts an external analog signal (typically relative to voltage) and converts it to a digital
representation. Microcontrollers that have this feature can be used for instrumentation,
environmental data logging, or any application that lives in an analog world.
The various types of A/D converters that can be found in microcontrollers are:
This the most common type of A/D and is used in the majority of microcontrollers. In this
technique, the converter figures out each bit at a time (most significant first) and finds if the
next step is higher or lower. This way has some benefitsit takes exactly the same amount of
time for any conversionit is very common(and therefore very cheap). However it also has
some disadvantagesit is slowfor every bit it takes at least one clock cycle.
This type of A/D converter is found on higher-end DSPs. Delta sigma A/Ds can be broken down
into two main parts.
The modulator which does the A/D conversion and the filter, which turns the output of
the modulator into a format suitable for the microcontroller (or Digital Signal Processor).
The filter comes after the modulator, and this filter is essentially a Digital Signal
Processor block.
This is the basic architecture for the fastest category of A/Ds. The flash converter involves
looking at each level that is possible and instantaneously saying what level the voltage is at.



This is done by setting up comparators as threshold detectors with each detector being set up
for a voltage exactly 1 LSB higher than the detector below it. The benefit of this architecture is
that with a single clock cycle, one can tell exactly what the input voltage isthat is why it is so
fast. The disadvantage is that to achieve 8-bit accuracy one need 256 comparators and to
achieve 10-bit accuracy one need 1024 comparators. To make these comparators operate at
higher speeds, they have to draw large amount of current, and beyond 10 bits, the number of
comparators required becomes unmanageable.
Polling is a software technique whereby the controller continually asks a peripheral if it needs
servicing. The peripheral sets a flag when it has data ready for transferring to the controller,
which the controller notices on its next poll. Several such peripherals can be polled in succession,
with the controller jumping to different software routines, depending on which flags have
been set.
Rather than have the microcontroller continually pollingthat is, asking peripherals (timers/
UARTS / A/Ds / external components) whether they have any data available (and finding most
of the time they do not), a more efficient method is to have the peripherals tell the controller
when they have data ready. The controller can be carrying out its normal function, only
responding to peripherals when there is data to respond to. On receipt of an interrupt, the
controller suspends its current operation, identifies the interrupting peripheral, then jumps to
the appropriate interrupt service routine.
The advantage of interrupts, compared with polling, is the speed of response to external
events and reduced software overhead.
Most microcontrollers have at least one external interrupt, which can be edge selectable
(rising or falling) or level triggered. Both systems (edge/level) have advantages. Edgeis not
time sensitive, but it is susceptible to glitches. Level must be held high (or low) for a specific
4 bit microcontrollers usually have either a polling or non-vectored type of interrupt
scheme. 8 and 16 bit microcontrollers usually have some type of vectored arbitration type of
interrupt scheme. 32 bit microcontrollers usually will have some type of vectored priority type
of interrupt scheme. One should consult data sheet to make sure type of interrupts available
before designing the project.
A maskable interrupt is one that can be disable or enable (masking it out means disabling the
interrupt), whereas non-maskable interrupts cant be disable. The benefit of maskable interrupts
is that one can turn off a particular interrupts (for example a UART) during some time critical
task. Then, those particular interrupts will be ignored thus allowing the microcontroller to
deal with the task at hand. Most microcontrollers (as well as most microprocessors) have some
type of Global Interrupt Enable (GIE) which allows to turn off (or ON) all of the maskable
interrupts with one bit. (GIE usually does not effect any NMI)
Simple (non-vectored) interrupts is one of the simplest interrupt schemes. Whenever there is
an interrupt, the system needs to check the interrupts (one at a time) to see which peripheral


Introduction to Microcontrollers

has caused the interrupt to occur. The time between the interrupt happening and the time the
service routine is entered depends on how the system designer sets up their ranking. The
peripheral that is checked last takes the longest to process. Most microcontrollers that have
fewer than 3 5 interrupts use this method. The benefit of this is that the system designer can
set the priority. The most important peripheral gets checked first, and you get to decide which
peripheral that is.
Vectored interrupts are easier to set up, but the system designer has less control of the
system. When an interrupt occurs, the hardware interrupt handler automatically branches to
a specific address (called as vector address) depending on what interrupt occurred. This is
much faster than the non-vectored approach described, however the system designer does not
get to decide what peripheral gets checked first.
A watchdog timer provides a means of graceful recovery from a system problem. System problem
could be a program that goes into an endless loop, or a hardware problem that prevents the
program from operating correctly. If the program fails to reset the watchdog at some
predetermined interval, a hardware reset will be initiated. The bug may still exist, but at least
the system has a way to recover. This is especially useful for unattended systems.
Microcontrollers react to and control eventsDSPs execute repetitive math-intensive
algorithms. Today many embedded applications require both types of processors, and
semiconductor manufacturers have responded by introducing microcontrollers with on-chip
DSP capability and DSPs with on-chip microcontrollers.
The most basic thing a DSP will do is a MACC (Multiply and Accumulate). The number
of data bits a DSP can multiply and Accumulate will determine the dynamic range (and therefore
the application).
A clock monitor can shut the microcontroller down (by holding the microcontroller in reset) if
the input clock is too slow. This can usually be turned on or off under software control.
Loads a program by Initializing program/data memory from either a serial or parallel port.
RPL is convenient for prototyping or trying out new features, eliminates the erase/burn/program
cycle typical with EPROMs, and allows convenient updating of a system even from an offsite
A monitor is a program installed in the microcontroller which provides basic development and
debug capabilities. Typical capabilities of a microcontroller monitor include: loading object
files into system RAM, executing programs, examining and modifying memory and registers,
code disassembly, setting breakpoints, and single- stepping through code. Some simple monitors




only allow basic functions such as memory inspection, and the more sophisticated monitors
are capable of a full range of debug functions.
Monitors can either communicate with a dumb terminal or with a host computer such
as a PC. Much of the work of the monitor (such as user interface) can be offloaded to the host
PC running a program designed to work with the monitor. This makes it possible to reduce the
size and complexity of the code that must be installed in the target system.



In addition to control applications such as the home monitoring system, microcontrollers are
frequently found in embedded applications. Among the many uses that you can find one or
more microcontrollers: automotive applications, appliances (microwave oven, refrigerators,
television and VCRs, stereos), automobiles (engine control, diagnostics, climate control),
environmental control (greenhouse, factory, home), instrumentation, aerospace, and thousands
of other uses.
Microcontrollers are used extensively in robotics. In this application, many specific tasks
might be distributed among a large number of microcontrollers in one system. Communications
between each microcontroller and a central, more powerful microcontroller (or microcomputer)
would enable information to be processed by the central computer, or to be passed around to
other microcontrollers in the system.
A special application that microcontrollers are well suited for is data logging. Stick one
of these chips out in the middle of a corn field or up in a balloon, and monitor and record
environmental parameters (temperature, humidity, rain, etc). Small size, low power
consumption, and flexibility make these devices ideal for unattended data monitoring and



Microcontrollers come in many flavors and varieties. Depending on the power and features
that are needed, one might choose a 4 bit, 8 bit, 16 bit, or 32 bit microcontroller. In addition,
some specialized versions are available which include features specific for communications,
keyboard handling, signal processing, video processing, and other tasks. The examples of
different types of microcontrlles are given in Tables.
Table 1.0 4 bit Microcontroller
Model (Manufacturer)


COP400 Family (National)

The COP400 Family is a P2CMOS 4-bit microcontroller which offers

512 bytes to 2K ROM and 32x4 to 160x4 RAM. Packages are varied
from 20 to 28 pin (DIP/SO/PLCC). Functions include timers,
counters, 2.3 to 6.0 Volt operation, ROMless modes, and OTP


Introduction to Microcontrollers
Table 1.0


8 bit Microcontrollers

Model (Manufacturer)


8048 (Intel)

Modified Harvard architecture with program ROM on chip with an

additional 64 to 256 bytes of RAM also on chip. I/O is mapped in its
own space.

8051 (Intel)

Modified Harvard architecture with separate address spaces for

program memory and data memory. The program memory can be
up to 64K. The 8051 can address up to 64K of external data memory,
and is accessed only by indirect addressing. The 8051 has 128 bytes
of on-chip RAM, plus a number of special function registers (SFRs).
I/O is mapped in its own space. The 8051 has features of boolean

COP800 Family (National)

The COP800 Basic Family is a fully static 8-bit microcontroller,

fabricated using double metal silicon gate microCMOS technology.
Features include: 8-bit memory mapped architect, serial I/O, UART,
memory mapped I/O, many 16 bit timer/counters with capture
registers, a multi-sourced vectored interrupt, comparator,
WATCHDOG Timer and Clock monitor, 8-channel A/D converter
with prescaler, brownout protection, halt mode, idle mode etc.

6805 (Motorola)

It has a Von-Neuman architecture in which instructions, data, I/O,

and timers all share the same space. Stack pointer is 5 bits wide
which limits the stack to 32 bytes deep. Some members of this family
include on chip A/D, PLL frequency synthesizer, serial I/O etc.

68hc11 (Motorola)

The 68hc11 is a powerful 8-bit data, 16-bit address microcontroller.

The 68hc11 has a common memory architecture in which
instructions, data, I/O, and timers all share the same memory space.
Depending on the variety, the 68hc11 has built-in EPROM/OTPROM,
RAM, digital I/O, timers, A/D converter, PWM generator, pulse
accumulator, and synchronous and asynchronous communications
channels. Typical current draw is less than 20ma.

TMS370 (Texas Instruments)

It is similar to the 8051 in having 256 registers, A and B

accumulators, stack in the register page, etc. It has a host of onboard
support devices, include: RAM, ROM (mask, OTP, or EEPROM), 2
timers (configurable as timers/ counters/comparators/PWM output),
watchdog timer, SCI (synchronous serial port), SPI (asynchronous
serial port), A/D (8 bit, 8 channel), interrupts. Instruction set is
mostly 8 bit with some 16 bit support. Clock speeds are up to 20MHz
which gives 5MHz for buss access and instruction cycles.

PIC (MicroChip)

The PIC microcontrollers were the first RISC microcontrollers.

Having few instructions (eg. 33 instructions for the 16C5X line versus
over 90 for the Intel 8048), Separate buses for instructions and data
(Harvard architecture) allows simultaneous access of program and
data, and overlapping of some operations for increased processing
performance. The benefits of design simplicity are a very small chip,
small pin count, and very low power consumption. Available in three
lines: the PIC16C5x, PIC16Cxx, and PIC17Cxx families.



Table 1.0

16 bit Microcontrollers

Model (Manufacturer)


80c196 (Intel)

The 80c196 is a 16 bit processor. Originally fabricated in NMOS

(8096), it is now mainly available in CMOS. Many features it includes
are: hardware multiply and divide, 6 addressing modes, high speed
I/O, A/D, serial communications channel, up to 40 I/O ports, 8 source
priority interrupt controller, PWM generator, and watchdog timer.

HPC Family (National)

The HPC Family of High Performance microcontrollers is a 16-bit

controller fabricated using microCMOS technology. The architecture
is a Von-Neuman architecture where the program and data memory
share the same address space. Features include: 16-bit memorymapped architecture with software configurable external address/
data bus, Microwire/Plus serial I/O, UART, 16-bit timer/counters
with input capture capability, High-Level Data Link Control (HDLC)
for ISO-standard data communications, 8-channel A/D converter with
prescaler, power-saving modes, Multiply/Accumulate Unit with builtin circular buffer management for low to medium DSP applications,
software configurable chip-select outputs, 64KB address space
directly addressable, low-voltage (3.3V) operation.


1. Write major differences between a microprocessor and a microcontroller.
2. Discuss the evolution of microcontrollers.
3. Write short notes on following microcontroller features:
Fabrication Techniques
Power Management and Low Voltage
Watchdog timer
4. What are the applications of microcontrollers?
5. Discuss architectural features of microcontrollers.