Microcontroller
vs. Microprocessor. How are they
different?
One quick and dirty answer is application. Microcontrollers are embedded into special
purpose computers, whereas microprocessors are found at the core of general
purpose computers like laptops and desktop PCs.With
a computer in just about every home these days, everyone knows what a central
processing unit (CPU) is, or at least they think they do, the heart of their
computer. The CPU is where the processing of
software instructions takes place.Measured nowadays in gigahertz (GHz), a CPU can cost hundreds of
dollars, in some cases even over a thousand.
A microcontroller on the other hand is usually much less
expensive and is more likely to have
the speed measured in megahertz (MHz). Microcontrollers, or MCUs, form the key
component to adding what we would consider intelligence to an electronic device
or appliance. Most people interact with
at least one such device everyday--in fact the number is probably closer to
being in the double digits.
For this discussion, let us choose a commonly used and quite
typical microcontroller, a PIC MCU from Microchip Corporation with an 8-bit
architecture and a speed of 4 MHz. Costing only a few dollars, this type of
chip is very powerful.In order for a microprocessor to function properly inside a
computer, it requires an array of support components. These include a clock,
memory (both RAM and ROM), external storage, and I/O ports for communication
with the outside world.In our desktop
and laptop computers, these components are separate modules.In a microcontroller, many, if not all, of
these components are integrated onto the chip. Many MCUs contain addional
functionality with the addition of onboard analog to digital converters (ADCs)
and video display drivers. With all this integation, we can consider an MCU to
be a small, inexpensive computer on a chip.
These powerful little wonders have come a long way as Moore's
Law has continued to play out.
MCU Components Clock It is hard to hear a discussion about an individual's computer
system without the mention of the systems speed, expressed in megahertz (MHz)
or gigahertz (GHz).One might even hear
two young men comparing system speed as if they were boasting about the cubic
inches of their automobiles.While the
clock speed is a significant measure of a systems performance, it is only one
aspect.A higher speed doesn't
necessarily mean a faster computer. The system clock sets the timing for the processor.Hertz is defined as cycles per second, the
measure of frequency. A one megahertz clock or timing circuit divides one
second of time into one million equal intervals. It is during these intervals,
or cycles, that the computer program's instructions are executed.Some processors are capable of executing
multiple instructions during a cycle, where others require many cycles for a
single instruction.The 8-bit PIC
contollers for example require four cycles to execute most instructions. Thus,
a PIC microcontroller with a clock speed of 4-MHz is able to execute one
million instructions per second.Now,
think about modern computers with gigahertz speeds capable of executing many
instructions per cycle. Memory A computer system requires memory in order to operate. A place
where the computer program can reside, or where the computer can temporarily
store values used during calculations. This requirement is met with random
access memory(RAM) which is very
quickly accessed by the computer, but all the contents are lost when power is
removed. A more permanent solution is oIbviously required for
microcontrollers to be able to store their computer programs. EEPROM are or ROM
is used in the MCU to store the software.Read-only memory (ROM) is found production run MCUs that need only be
programmed once. These are not suprisingly called OTP units, one time
programmable.For those MCU devices
that require the ability to be programmed multiple times, such as during
software development, we have electrically-erasable programmable read-only
memory (EEPROM).