Introduction To The 8051 Microcontroller
Introduction To The 8051 Microcontroller
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.
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.
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.
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.
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.
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.
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.