Sunteți pe pagina 1din 17

Introduction to the 8051 Microcontroller:

Microcontrollers are "embedded" inside some other device (often a consumer


product) so that they can control the features or actions of the product. Another name for a
microcontroller, therefore, is "embedded controller.
Microcontrollers are dedicated to one task and run one specific program. The program
is stored in ROM (read-only memory) and generally does not change. Microcontrollers are
often low-power devices.
A microcontroller has a dedicated input device and often (but not always) has a small
LED or LCD display for output. A microcontroller also takes input from the device it is
controlling and controls the device by sending signals to different components in the device.
For example, the microcontroller inside a TV takes input from the remote control and
displays output on the TV screen. The controller controls the channel selector, the speaker
system and certain adjustments on the picture tube electronics such as tint and brightness.
The engine controller in a car takes input from sensors such as the oxygen and knock
sensors and controls things like fuel mix and spark plug timing. A microwave oven controller
takes input from a keypad, displays output on an LCD display and controls a relay that turns
the microwave generator on and off.
A microcontroller is often small and low cost. The components are chosen to
minimize size and to be as inexpensive as possible. The fixed amount of on-chip ROM,
RAM, and number of I/O ports makes them ideal for many applications in which cost and
space are critical. In many applications, the space it takes, the power it consumes, and the
price per unit are much more critical considerations than the computing power.
An embedded product uses a microprocessor (or microcontroller) to do one task and
one task only. There is only one application software that is typically burned into ROM.

A SMS, in contrast with the embedded system, can be used for any number of
applications. It has RAM memory and an operating system that loads a variety of applications
into RAM and lets the CPU run them. A SMS contains or is connected to various embedded
products. Each one peripheral has a microcontroller inside it that performs only one task.
Many manufactures of general-purpose microprocessors have targeted their
microprocessor for the high end of the embedded market. There are times that a
microcontroller is inadequate for the task.
When a company targets a general purpose microprocessor for the embedded market,
it optimizes the processor used for embedded systems. Very often the terms embedded
processor and microcontroller are used interchangeably.
One of the most critical needs of an embedded system is to decrease power
consumption and space. In high-performance embedded processors, the trend is to integrate
more functions on the CPU chip and let designer decide which features he/she wants to use.
In many cases using x86 SMSs for the high-end embedded applications. Saves money
and shortens development time. A vast library of software already written. Windows is a
widely used and well understood platform. 8-bit microcontrollers are Motorolas 6811, Intels
8051, Zilogs Z8, Microchips PIC and there are also 16-bit and 32-bit microcontrollers made
by various chip makers.

Embedded systems:
We are living in the Embedded World. We are surrounded with many embedded
products and our daily life largely depends on the proper functioning of these gadgets.
Television, Radio, CD player of our living room, Washing Machine or Microwave Oven in
our kitchen, Card readers, Access Controllers, Palm devices of our work space enable us to
do many of our tasks very effectively. Apart from all these, many controllers embedded in our
car take care of car operations between the bumpers and most of the times we tend to ignore
all these controllers.

In recent days, we are showered with variety of information about these embedded
controllers in many places. All kinds of magazines and journals regularly dish out details
about latest technologies, new devices; fast applications which make we believe that basic
survival is controlled by these embedded products. Now we can agree to the fact that these
embedded products have successfully invaded into our world. We must be wondering about
these embedded controllers or systems. What is this Embedded System?
The computer we use to compose were mails, or create a document or analyze the
database is known as the standard desktop computer. These desktop computers are
manufactured to serve many purposes and applications.
We need to install the relevant software to get the required processing facility. So,
these desktop computers can do many things. In contrast, embedded controllers carry a
specific work for which they are designed. Most of the time, engineers design these
embedded controllers with a specific goal in mind. So these controllers cannot be used in any
other place.
Theoretically, an embedded controller is a combination of a piece of microprocessor
based hardware and the suitable software to undertake a specific task.
These days designers have many choices in microprocessors/ microcontrollers.
Especially, in 8 bit and 32 bit, the available variety really may overwhelm even an
experienced designer. Selecting a right microprocessor may turn out as a most difficult first
step and it is getting complicated as new devices continue to pop-up very often.
In the 8 bit segment, the most popular and used architecture is Intel's 8031. Market
acceptance of this particular family has driven many semiconductor manufacturers to develop
something new based on this particular architecture.
Even after 25 years of existence, semiconductor manufacturers still come out with
some kind of device using this 8031 core.

Microcontroller versus Microprocessor:


What is the difference between a Microprocessor and Microcontroller? By
microprocessor is meant the general purpose Microprocessors such as Intel's X86 family
(8086, 80286, 80386, 80486, and the Pentium) or Motorola's 680X0 family (68000, 68010,
68020, 68030, 68040, etc.)
These microprocessors contain no RAM, no ROM, and no I/O ports on the chip itself
for this reason, they are commonly referred to as general-purpose Microprocessors.
A system designer using a general-purpose microprocessor such as the Pentium or the
68040 must add RAM, ROM, I/O ports, and timers externally to make them functional.
Although the addition of external RAM, ROM, and I/O ports makes these systems
bulkier and much more expensive, they have the advantage of versatility such that the
designer can decide on the amount of RAM, ROM and I/O ports needed to fit the task at
hand. This is not the case with Microcontrollers.
A Microcontroller has a CPU (a microprocessor) in addition to a fixed amount of
RAM, ROM, I/O ports, and a timer all on a single chip. In other words, the processor, the
RAM, ROM, I/O ports and the timer are all embedded together on one chip; therefore, the
designer cannot add any external memory, I/O ports, or timer to it. The fixed amount of onchip ROM, RAM, and number of I/O ports in Microcontrollers makes them ideal for many
applications in which cost and space are critical.
In many applications, for example a TV remote control, there is no need for the
computing power of a 486 or even an 8086 microprocessor. These applications most often
require some I/O operations to read signals and turn on and off certain bits.

Microcontrollers for Embedded Systems:


In the Literature discussing microprocessors, we often see the term Embedded
System. Microprocessors and Microcontrollers are widely used in embedded system
products. An embedded system product uses a microprocessor (or Microcontroller) to do one
task only.
A printer is an example of embedded system since the processor inside it performs
one task only; namely getting the data and printing it. Contrast this with a Pentium based
SMS. A SMS can be used for any number of applications such as word processor, printserver, bank teller terminal, Video game, network server, or Internet terminal.
Software for a variety of applications can be loaded and run. Of course the reason a
SMS can perform myriad tasks is that it has RAM memory and an operating system that
loads the application software into RAM memory and lets the CPU run it.
In an Embedded system, there is only one application software that is typically burned
into ROM. An x86 SMS contains or is connected to various embedded products such as
keyboard, printer, modem, disk controller, sound card, CD-ROM drives, mouse, and so on.
Each one of these peripherals has a Microcontroller inside it that performs only one
task for example, inside every mouse there is a Microcontroller to perform the task of finding
Home

Office

Automobiles

Appliances

Telephones

Trip Computer

Intercom

Computers

Engine control

Washing Machines

Security systems

Instrumentation

Security systems

Fax Machine

Security systems

Answering machines

Copier

Transmission control

Fax machines

Laser Printer

Climate control

Home computers

Paging

Keyless Entry

TV's

Scanner

Entertainment

the mouse position and sending it to the SMS. Table 1-1 lists some embedded products.

Table 1-1

8051 Microcontroller Projects, free ebooks, project codes, AVR Projects, 8051
tutorials, electronic projects, ECE CSE BE final year projects, Embedded systems, AVR
codes, embedded technology, LCD Interfacing tutorial, final year project ideas project
downloads, engineering projects, Examples projects, 8051 Libraries, 8052, Microcontroller,
Microprocessor, 8085, 8051 codes, SMSB designing, Project Kits, kit.

The 8051 Derivatives:


Along the way, this 8031 architecture gained enviable market acceptance. Many
semiconductor manufacturers started either manufacturing the 8031 devices as such (Intel
was liberal in giving away license to whoever asked) or developing a new kind of
microcontrollers based on 8031 core architecture. Manufacturers modified the basic 8031
architecture and added many new peripheral functions to make them attractive to the
designers.
Because of the rush, electronic community started getting a variety of 8031 based
devices with range of options. To beat the competition, manufacturers developed different
microcontrollers with many unique features.
These parts are popularly known as '8031 Derivatives'. Almost every decent
manufacturer boasted of having an 8031 based microcontroller in the line card.
First major manufacturer was the Philips who brought out more than 40-50
derivatives with a variety of I/O options, memory combinations, and peripheral functions.
Devices became available in regular DIP and SMD packages.
With the basic 8031 core, Philips ported high capacity Program Memory (up to
32K/64K), its patented I2C interface bus, 8/10 bit Analog to Digital Converters, CAN Bus,
Capture and Compare registers, Watch dog timer, PWM facilities and etc. More I/O ports (as
many as eight ports), additional timer/counter, second serial port was also made available in
Philips devices.

Apart from all these, Philips developed many consumer devices meant for telecom,
computer and TV applications. A smart card controller was also developed by incorporating a
cryptographic engine. So Philips clearly established itself as the market leader in 8031
derivatives and still caters to this segment.

Then came Dallas semiconductor. Dallas redesigned the 8031 architecture and
eliminated waste clock cycles of original core and made all instructions executed in less clock
cycles (maximum of 4) which has traditionally taken up to 12 clock cycles. So, came the birth
of High speed 8031 Derivatives.
Dallas also maintained the same device pin out configurations to enable the user get
up to 3X performance by replacing slower parts with a Dallas device. So, existing compiled
code started running faster without any modification. These days, we can find Dallas devices
giving up to 50 MIPS (Million Instructions per Second).
Apart from this, Dallas introduced additional Serial port, Watch Dog Timer, Precision
Reset Circuitry, Real Time Clock, Power Fail Monitor in the 8031 devices. Also a second
data pointer, more on chip RAM space and more interrupt lines were also made available.
Dallas semiconductor also has got a range of secure microcontrollers based on 8031
core. This microcontroller family uses non-volatile RAM to keep both program and data.
Because of this RAM, the controller gives the system reprogram ability.
Dallas has combined this microcontroller, SRAM and lithium cell in a single pack.
This device guarantees 10+ years of data retention in the RAM area. This 8031 also boasts
the tamper proof security features like Real Time Memory Encryption, user selected 48 bit
Encryption key, memory contents, security lock and the facility to hide interrupt vector table.
As we can agree, this particular 8031 device has found a niche market in banking and
security related applications.
Atmel Corporation is the other major semiconductor manufacturer who introduced
many flash memory based 8031 derivatives at a competitive cost.Atmel used its expertise in

flash memory technology into the basic 8031 core and brought out microcontrollers with a
variety of flash memory options and few devices also carry In System Reprogramming
facility.
We can program/reprogram this microcontroller after soldering the device in the target
board. If this programming facility is embedded in the system software, then the tasks like
remote calibration, onsite system up gradation become as easy as sending data/program in a
floppy disk or by internet. Atmel devices sport security lock to its flash memory to protect the
contents from the prying eyes.
Meantime, Intel itself tried to cash in the popularity of this 8031 architecture and
introduced improved versions of microcontrollers: 80151 and 80251 families. These devices
sport 16 bit architecture using 8031 core and unfortunately these devices have not become as
popular as 8031.Even after many years of introduction, 8031 core is still going strong in 8 bit
arena.

The 8051 Microcontroller Pin Description:

VCC
This pin is connected to +5V DC Supply voltage.

GND
This pin is intended to connect to the ground.

Port 0:
Port 0 is an 8-bit open-drain bi-directional I/O port. As an output port, each pin can
sink eight TTL inputs. When 1s are written to port 0 pins, the pins can be used as high
impedance inputs. Port 0 may also be configured to be the multiplexed low order address/data
bus during accesses to external program and data memory.

In this mode P0 has internal pull-ups. Port 0 also receives the code bytes during Flash
programming, and outputs the code bytes during program verification. External pull-ups are
required during program verification.

Port 1:
Port 1 is an 8-bit bi-directional I/O port with internal pull-ups. The Port 1 output
buffers can sink/source four TTL inputs. When 1s are written to Port 1 pins they are pulled
high by the internal pull-ups and can be used as inputs.
As inputs, Port 1 pins that are externally being pulled low will source current (IIL)
because of the internal pull-ups. Port 1 also receives the low- order address bytes during
Flash programming and verification.

Port 2:
Port 2 is an 8-bit bi-directional I/O port with internal pull-ups. The Port 2 output
buffers can sink/source four TTL inputs. When 1s are written to Port 2 pins they are pulled
high by the internal pull-ups and can be used as inputs.
As inputs, Port 2 pins that are externally being pulled low will source current (IIL)
because of the internal pull-ups. Port 2 emits the high-order address byte during fetches from
external program memory and during accesses to external data memory that uses 16-bit
addresses (MOVX @ DPTR). In this application, it uses strong internal pull-ups when
emitting 1s.

Port 3:
Port 3 is an 8-bit bi-directional I/O port with internal pull-ups. The Port 3 output
buffers can sink/source four TTL inputs. When 1s are written to Port 3 pins they are pulled
high by the internal pull-ups and can be used as inputs.
As inputs, Port 3 pins that are externally being pulled low will source current (IIL)
because of the pull-ups. Port 3 also serves the functions of various special features of the
8051 as listed below:

Port pin
P3.0
P3.1
P3.2
P3.3
P3.4
P3.5
P3.6
P3.7

Alternate functions
RXD (serial input port)
TXD (serial output port)
INT0 (external interrupt 0)
INT1 (external interrupt 1)
T0 (timer 0 external input)
T1 (timer 1 external input)
WR (external data memory Write strobe)
RD (external data memory read strobe)

Port 3 also receives some control signals for Flash programming and verification.

RST:
Reset input. A high on this pin for two machine cycles while the oscillator is running
resets the device.

ALE/PROG:
Address Latch Enable output pulse for latching the low byte of the address during
accesses to external memory. This pin is also the program pulse input (PROG) during Flash
programming.
In normal operation ALE is emitted at a constant rate of 1/6 the oscillator frequency,
and may be used for external timing or clocking purposes. Note, however, that one ALE pulse
is skipped during each access to external Data Memory.
If desired, ALE operation can be disabled by setting bit 0 of SFR location 8EH. W ith
the bit set, ALE is active only during a MOVX or MOVC instruction. Otherwise, the pin is
weakly pulled high. Setting the ALE-disable bit has no effect if the microcontroller is in
external execution mode.

PSEN:
Program Store Enable is the read strobe to external program memory. When the 8051
is executing code from external program memory, PSEN is activated twice each machine
cycle, except that two PSEN activations are skipped during each access to external data
memory.

EA /VPP:

External Access Enable must be strapped to GND in order to enable the device to
fetch code from external program memory locations starting at 0000H up to FFFFH.

Note, however, that if lock bit 1 is programmed, EA will be internally latched on


reset. EA should be strapped to VCC for internal program executions. This pin also receives
the 12- volt programming enable voltage (VPP) during Flash programming, for parts that
require 12- volt VPP.

XTAL1:
Input to the inverting oscillator amplifier and input to the internal clock operating
circuit.

XTAL2:
Output from the inverting oscillator amplifier.

Memory Organization:
The 8051 architecture provides the user with three physically distinct memory spaces.
Each memory space consists of contiguous addresses from 0 to maximum size, in bytes, of
the memory space .Address overlaps are resolved by utilizing these instructions which refer
specifically to a given address space.

THE CODE SPACE:


The first memory space is the CODE segment in which the executable program
resides. This segment can be upto 64K (since it is addressed by 16 address lines). The
processor treats this segment as read only and will generate signals appropriate to access a
memory device such as an EPROM. However, this does not mean that the CODE segment

must be implemented using an EPROM.


Many embedded systems these days are using EEPROM which allows the memory to
be overwritten either by the 8051 itself or by an external device. This makes upgrade to the
product easy to do since new software can be downloaded into the EEPROM rather than
having to disassemble it and install a new EPROM.

Block Diagram for Memory organization

THE DATA SPACE:


The second memory space is the 128 bytes of internal RAM on the 8051, or the first
128 bytes of internal RAM on the 8052. This segment is typically referred to as the DATA
segment. The RAM locations in this segment are accessed in one or two cycles depending on
the instruction.
This access time is much quicker than access to the XDATA segment because memory
is directly rather than via a memory pointer such as DPTR which must first be initialized.
Therefore, frequently used variables and temporary scratch variables are usually assigned to
the DATA segment.
Variables stored in the DATA segment can also be accessed indirectly via R0 or
R1.The register being used as the memory pointer must contain the address of the byte to be
retrieved or altered. These instructions can take one or two processor cycles depending on the
source/destination data byte.

The Processor Status:


The Processor status is kept in a bit addressable SFR called PSW (Processor Status W
ord).This register contains the carry bit, an auxiliary bit which is used with BCD operations,
the Accumulator parity flag and overflow flag, two general purpose flags, and two bits which
select the register bank to use as the default.
As mentioned before, the register bank selection bits make a two bit number from 0 to
3 which indicate the bank to be used. Bank 0 begins at the base of the DATA segment
(address 00H), bank 1 begins at 08H, bank 2. Begins at address 10H and bank 3 at address

18H.
Any of these memory locations are always available for direct and indirect memory
accesses via their addresses regardless of the register bank selection.

Power Control:
The CHMOS versions of the 8051 feature two power saving modes that can be
activated by software: idle mode and power down mode. These modes are accessed via the
SMSON (Power Control). The idle mode is activated by setting the IDLE bit high.
The idle mode causes all program execution to stop. Internal RAM contents are
preserved and the oscillator continues to run but is blocked from the CPU. The timers and the
UART continue to function as normal. Idle mode is terminated by the activation of any
interrupt. Upon completion of the interrupt service routine, execution will continue from the
instruction following the instruction which set the IDLE bit.

The Interrupts of 8051:


The basic 8051 supports six interrupt sources: two external interrupts, two
timer/counter interrupts, and a serial byte in/out interrupt. These interrupt sources force the
processor to vector to one of five locations in the lowest part of the CODE address space
(serial input and serial output interrupts share the same vector). The interrupt service routine
must either reside there or be branched from there.

On board Timers and Counters:


The standard 8051 has two timer/counters (other 8051 family members have varying

amounts), each of which case they count processor cycles or can be used to count falling
edges on the signal applied to their respective I/O pin (either T0 or T1).
When used as a counter, the input signal must have a frequency equal to or lower than
the instruction cycle frequency divided by 2 i.e.: the oscillator frequency /24, since the
incoming signal is sampled every instruction cycle, and the counter is incremented only when
a 1 to 0 transition is detected which will require two samples.

If desired, the timer/counters can force a software interrupt when they overflow. The
TCON (Timer Control) SFR is used to start or stop the timers as well as hold the overflow
flags of the timers. The timer/counters are started or stopped by changing the timer run bits
(TR0 and TR1) in the TCON.

Features of 8051 Microcontroller:

Endurance:1000 write/erase Cycles 4.0 V to 5.5


Operating range Fully static Operation:0 to 33 MHz
Three-level program Memory lock
128x x 8 bit Internal RAM

32 programmable I/O lines


Two 16-Bit timer/counters
Six interrupt Sources
Full duplex UART serial channel
Low-power idle and power- down modes
Interrupt Recovery from Power- down mode
Watchdog Timer
Dual Data Pointer
Power-off Flag
Fast Programming Time

Flexible ISP Programming (Byte and Page Mode)

S-ar putea să vă placă și