Wednesday, October 01, 2008

An Introduction to Microcontrollers

Many developers new to microcontrollers (which the 8052 is) come from a PC/Windows or Macintosh
environment. While most programming concepts will transfer over to the 8052 environment with no
problem, there are some issues that a surprising number of people stumble upon as they enter the
microcontroller world. Before delving into the details of microcontrollers and, specifically, the 8052,
we.ll address some common stumbling blocks.
1.1 What is a Microcontroller?
A microcontroller (often abbreviated MCU) is a single computer chip (integrated circuit) that executes a
user program, normally for the purpose of controlling some device.hence the name microcontroller.
The program is normally contained either in a second chip, called an EPROM, or within the same chip as
the microcontroller itself. A microcontroller is normally found in devices such as microwave ovens,
automobiles, keyboards, CD players, cell phones, VCRs, security systems, time & attendance clocks, etc.
Microcontrollers are used in devices that require some amount of computing power but don.t require as
much computing power as that provided by a complex (and expensive) 486 or Pentium system which
generally requires a large amount of supporting circuitry (large motherboards, hundreds of megabytes of
RAM, hard drives, hard drive controllers, video cards, etc). A microwave oven just doesn.t need that
much computing power.
Microcontroller-based systems are generally smaller, more reliable, and cheaper. They are ideal for the
types of applications described above where cost and unit size are very important considerations. In such
applications it is almost always desirable to produce circuits that require the smallest number of integrated
circuits, that require the smallest amount of physical space, require the least amount of energy, and cost as
little as possible.
The popular website HowStuffWorks.com has a good article that can provide you with some background
information about microcontrollers in general at http://www.howstuffworks.com/microcontroller.htm.
1.1.1 Microcontroller Program Storage

The program for a microcontroller is normally stored on a memory integrated circuit (IC), called an
EPROM, or on the microcontroller chip itself.
An EPROM (Electrically Programmable Read Only Memory) is a special type of integrated circuit that
does nothing more than store program code or other data but which is maintained even when the power to
the EPROM is turned off. Once you.ve developed software for a microcontroller it is normally
programmed (or .burned.) into an EPROM chip, and that chip is subsequently physically inserted into the
circuitry of your hardware. The microcontroller accesses the program stored in the EPROM and executes
it. Thus the program is made available to the microcontroller without the need for a hard drive, floppy
drive, or any of the other circuitry necessary to access such devices.
In recent years, more and more microcontrollers offer the capability of having programs loaded internally
into the microcontroller chip itself. Thus, rather than having a circuit that includes both a microcontroller
and an external EPROM chip, it is now entirely possible to have a single microcontroller which stores the
program code internally.
8052 Tutorial & Reference . © Copyright 1997-2004 Vault Information Services LLC
www.8052.com: The Online 8052 Resource

1.1.2 .Loading. your Microcontroller Program
The manner in which you transfer your software from your PC to your hardware depends on whether you
are using an EPROM or are transferring the program directly to the microcontroller.
Programming an EPROM requires special hardware, called an EPROM Programmer. An EPROM
programmer is a device that connects to your PC, via either the serial, parallel, or USB port. You then
place the EPROM chip into a socket on the device and then use special software that transfers your
program from the PC to the EPROM Programmer, which in turn .burns. your program into the chip.
Once your program is burned into the EPROM you remove the EPROM and insert it in your circuit.
Programming a microcontroller that stores the program within the microcontroller itself generally requires
a serial port be available for downloading updates to the program. Many of these devices have a .back
door. in that you can still insert the microcontroller into an EPROM Programmer and load the software as
described in the previous paragraph. If you are designing your circuit from scratch, however, it is often a
good idea to plan for the possibility of programming the microcontroller without removing the IC from the
circuit itself.this is especially true of surface-mount parts that may be difficult to remove from the
circuit. The datasheet for the microcontroller you choose to use should provide you the information
necessary to design your circuit for this capability.
1.2 What is an 8051 or 8052?


The 8052 is an 8-bit microcontroller originally developed by Intel in the late 1970s. It included an
instruction set of 255 operation codes (opcodes), 32 input/output lines, three user-controllable timers, an
integrated and automatic serial port, and 256 bytes of on-chip RAM. The 8051 is a very similar MCU but
it has only two timers and 128 bytes of on-chip RAM.
The 8052 was designed such that control of the MCU and all input/output between the MCU and external
devices is accomplished via Special Function Registers (SFRs). Each SFR has an address between 128
and 255. Additional functions can be added to new derivative MCUs by adding additional SFRs while
remaining compatible with the original 8052. This allows the developer to use the same software
development tools with any MCU that is .8052-compatible..
Intel wisely licensed their .8052 core. to other semiconductor firms. This allowed the 8052-architecture
to become an industry-wide standard. Now, more than 20 years later, dozens of semiconductor companies
produce microcontrollers that are based on the original 8052 core. The additional features that each
semiconductor-firm offers in their MCUs are accessed by utilizing new SFRs in addition to the standard
and original 8052-SFRs that are found in all 8052-compatible MCUs.
In this document, the term .8052. will refer to any MCU that is compatible with the original 8052. As a
minimum it will support the 8052 instruction set, support the 8052.s 26 SFRs, provide three user timers,
and have at least 256 bytes of Internal RAM.


Warning: While most microcontrollers based on the 8052 core will include the standard
SFRs from the 8052 core, some derivatives may only implement a subset of them. They
may also change the function of some bits. This is generally not the case, but it is
something to look out for when using derivative chips.
The term .8051. will refer to any 8052-compatible MCU that doesn.t meet the specifications in the
previous paragraph, rather mirroring Intel.s 8051 microcontroller which was a more limited version of the
8052. As a minimum, an 8051 must support the 21 SFRs supported by the original 8051 and support the
standard 8052 instruction set. Generally an 8051 will have two user timers and 128 bytes of RAM onchip,
although some designs have as little as 64 bytes of on-chip RAM.

1.2.1 Derivative Chips

The term .derivative chip., in this document, will refer to any 8051 or 8052-compatible MCU that is
produced by any semiconductor firm. There are currently hundreds of derivative chips produced by
dozens of semiconductor firms.
A derivative chip will generally (but not always) be able to execute a standard 8051 or 8052 program
without modification. A derivative chip must be based on the 8052 instruction set and support the
appropriate SFRs (at least 21 SFRs for an 8051 or 26 for an 8052).
Software development tools designed for the 8052 can always be used to develop software for any
derivative chip as long as the programmer explicitly defines any new SFRs that are supported by the
derivative chip that they are using.
1.3 Using Windows or Linux
A surprising number of people ask whether or not a microcontroller is Windows-compatible, or if they can
load Linux on their microcontroller. These questions demonstrate a fundamental lack of understanding
about what a microcontroller is.
No, a microcontroller cannot run Windows nor can it run Linux. Nor is a microcontroller Windowscompatible,
per se. Does your microwave oven run Linux? Is your automobile Windows-compatible?
These questions are as silly as asking whether a microcontroller runs Windows.
It is important to remember what microcontrollers are used for. A microcontroller is not a personal
computer. It is an integrated circuit that will run your programs to control hardware devices such as those
mentioned earlier. A microwave oven doesn.t need Windows and your automobile certainly doesn.t need
Linux to maintain the correct air-fuel mixture.
That said, you can.and many developers do.use Windows or Linux to develop programs for
microcontrollers. Many Windows products exist that allow you to write 8052 software in the Windows
environment even though the software will ultimately be executed by a microcontroller. Once the
software is executed by a microcontroller it doesn.t matter whether it was originally developed under
Windows, Linux, or any other operating system.


The term .8051. will refer to any 8052-compatible MCU that doesn.t meet the specifications in the
previous paragraph, rather mirroring Intel.s 8051 microcontroller which was a more limited version of the
8052. As a minimum, an 8051 must support the 21 SFRs supported by the original 8051 and support the
standard 8052 instruction set. Generally an 8051 will have two user timers and 128 bytes of RAM onchip,
although some designs have as little as 64 bytes of on-chip RAM.

1.2.1 Derivative Chips

The term .derivative chip., in this document, will refer to any 8051 or 8052-compatible MCU that is
produced by any semiconductor firm. There are currently hundreds of derivative chips produced by
dozens of semiconductor firms.
A derivative chip will generally (but not always) be able to execute a standard 8051 or 8052 program
without modification. A derivative chip must be based on the 8052 instruction set and support the
appropriate SFRs (at least 21 SFRs for an 8051 or 26 for an 8052).
Software development tools designed for the 8052 can always be used to develop software for any
derivative chip as long as the programmer explicitly defines any new SFRs that are supported by the
derivative chip that they are using.

1.3 Using Windows or Linux

A surprising number of people ask whether or not a microcontroller is Windows-compatible, or if they can
load Linux on their microcontroller. These questions demonstrate a fundamental lack of understanding
about what a microcontroller is.
No, a microcontroller cannot run Windows nor can it run Linux. Nor is a microcontroller Windowscompatible,
per se. Does your microwave oven run Linux? Is your automobile Windows-compatible?
These questions are as silly as asking whether a microcontroller runs Windows.
It is important to remember what microcontrollers are used for. A microcontroller is not a personal
computer. It is an integrated circuit that will run your programs to control hardware devices such as those
mentioned earlier. A microwave oven doesn.t need Windows and your automobile certainly doesn.t need
Linux to maintain the correct air-fuel mixture.
That said, you can.and many developers do.use Windows or Linux to develop programs for
microcontrollers. Many Windows products exist that allow you to write 8052 software in the Windows
environment even though the software will ultimately be executed by a microcontroller. Once the
software is executed by a microcontroller it doesn.t matter whether it was originally developed under
Windows, Linux, or any other operating system.

Please give your suggestion and follow us if you are interested, which encourage us to create new topics for you. And Thankyou for your support.