Sei sulla pagina 1di 32

Acknowledgement

Now days this is the area of Electronics circuit which are using microprocessors
or microcontroller in the circuits, i.e. EMBEDDED SYSTEM.. Because these
are intelligent device so these device are making our life easier.

I try to give the basic understanding of the 8051 microcontroller and in this
book we have given all the circuit which is practically implemented. So, this
book written to cover most of the practical aspect for interfacing of the I/O
devices with microcontroller. We have covered interfacing of the TTL, chip,
intelligent LCD displays, and stepper motors etc with microcontroller 8051; in
this we have used internal memory of microcontroller 8051.

I am thankful to CETPA INSTITUTE where I have studied the course of


EMBEDDED SYSTEM. I am also thankful to Er. Rashi Gupta under her
guidance I have learnt the course of EMBEDDED SYSTEM.

VINAY KUMAR
A
Summer Training Project Report
On
“Embedded System”

Submitted in partial fulfillment of the requirement for the awards of

B.TECH (ELECTRONICS & COMMUNICATION)

(U.P.TECHNICAL UNIVERSITY, LUCKNOW)

2010-11

Roll No. 0709731115

VINAY KUMAR

Galgotia’s College of Engineering & Technology


Greater Noida
CONTENTS:

UNIT-1

1.1-Introduction of CETPA……………………………………………1

1.2-Introduction of EMBEDDED SYSTEM............................................2

1.3-History..................................................................................................3

1.4-Scope of EMBEDDED SYSTEM………………………………….4

1.5-What is EMBEDDED SYSTEM…………………………………...5

1.6-Characterstics……………………………………………………….7

UNIT-2

2.1- About the 8051……………………………………………………14

2.2- Typical applications……………………………………………….15

2.3- Basic Pins………………………………………………………….15

2.4- Ports………………………………………………………………..16

2.5- Oscillator Circuits………………………………………………….17

2.6- Internal Architecture……………………………………………….17

2.7- Architecture Features………………………………………………17

2.8.-Data and Program Memory…………………………………..……18

2.9- Program Start Address……………………………………………..18

2.10- Direct Memory…………………………………………………...18

2.11- Special Function Register………………………………………..18

2.12- General Purpose Register………………………………………...19

2.13- A and B Registers………………………………………………...19

2.14- Memory organization…………………………………………….19

2.15- Advantages & Applications………………………………………26


UNIT-1
1.1CETPA Introduction
The mission of CETPA is to work for the promotion of computer education and
technology in India and abroad. CETPA is a group of professionals who are
working for the promotion of technology.CETPA provides open platform for
the development of the various computer software. We are the part of Linux
Promotion Organisation.

CETPA Objectives
* Promoting Computer Education & Technology.
* Open platform for the development jobs.
* Provide World Class Computer Education.
* Organize Paper Presentation & Quizzes.
* Organize Conferences & Seminars.
* Collaboration with other Institute.
* Launch Research Paper & Projects of the Members.
* Research for Advance Technology.
* Honor Outstanding Personalities.

CETPA Education
CETPA is an association dedicated for spreading advance computer education
to all over the world. CETPA provides computer education in advance
technology courses like LINUX, J2EE, VHDL, EMBEDDED SYSTEM,
ADVANCE EMBEDDED SYSTEM, CAD , Pro-E or Mechanical &
Electronics students, .NET, MATLAB, ADVANCE JAVA, ORACLE,
SOFTWARE TESTING etc.

CETPA R&D
CETPA is working continuously in Research and Development field from the
very beginning CETPA has developed a number of advanced software and
currently working in following main projects. 
* Congestion Control in Wireless Traffic.
* Real Time Scheduling for Automatic Guided Vehicles.
* Advancement in Microprocessors Technology.
* CETPA Linux( releasing soon).

1
CETPA Open Platform
CETPA is an association, which is providing open platform for software
development. Our thinking is that development tools should be provided free of
cost so that the technological advancement and refinement can take place
unhindered. In this mission everyone is invited CETPA. Linux is a special
flavour of Linux that can be easily optimized and customized for just about any
application or need .Extreme performance, configurability and a top-notch user
and developer community are all hallmarks of the CETPA experience

1.2 About Embedded System


An embedded system is a special-purpose computer system designed to perform
one or a few dedicated functions,often with real-time computing constraints. It
is usually embedded as part of a complete device including hardware and
mechanical parts. In contrast, a general-purpose computer, such as a personal
computer, can do many different tasks depending on programming. Embedded
systems control many of the common devices in use today.Since the embedded
system is dedicated to specific tasks, design engineers can optimize it, reducing
the size and cost of the product, or increasing the reliability and performance.
Some embedded systems are mass-produced, benefiting from economies of
scale.
Physically, embedded systems range from portable devices such as digital
watches and MP4 players, to large stationary installations like traffic lights,
factory controllers, or the systems controlling nuclear power plants. Complexity
varies from low, with a single microcontroller chip, to very high with multiple
units, peripherals and networks mounted inside a large chassis or enclosure.
In general, "embedded system" is not an exactly defined term, as many systems
have some element of programmability. For example, Handheld computers
share some elements with embedded systems such as the operating systems and
microprocessors which power them but are not truly embedded systems,
because they allow different applications to be loaded and peripherals to be
connected.
Embedded systems span all aspects of modern life and there are many examples
of their use.
If you are an Electronics or Computer Engineer, you know very well that most
of the Electronic Devices are having brain of their own i.e. Microprocessor or
Micro controller. Example: PCO Machine, EPABX, Fax Machine, Robots,
Space Shuttle, Data Loggers etc. All these devices have their own logic unit for
making decisions. You may know the popularity of the world's most used 8-bit
micro controller 8051, developed originally by the leading semiconductor
manufacturer, Intel Corp. 8-bit micro processor became so popular because it is

2
used by many second source manufacturers. This course is built according to
the use of 8051 micro controller in the designing of Embedded System.

1.3 HISTORY
In the earliest years of computers in the 1940–50s, computers were sometimes
dedicated to a single task, but were far too large and expensive for most kinds of
tasks performed by embedded computers of today. Over time however, the
concept of programmable controller evolved from electromechanical sequence
via solid state devices, to the use of computer technology.
The first microprocessor for example, the Intel 4004 was
designed for calculators and other small systems but still required many external
memory and support chips. In 1978 National Engineering Manufacturers
Association released a "standard" for programmable microcontrollers, including
almost any computer-based controllers, such as single board computers,
numerical, and event-based controllers.
As the cost of microprocessors and microcontrollers fell it became feasible to
replace expensive knob-based analog components such
as potentiometrs and variable capatiors with up/down buttons or knobs read out
by a microprocessor even in some consumer products. By the mid-1980s, most
of the common previously external system components had been integrated into
the same chip as the processor and this modern form of
the microcontroller allowed an even more widespread use, which by the end of
the decade were the norm rather than the exception for almost all electronics
devices.
The integration of microcontrollers has further increased the applications for
which embedded systems are used into areas where traditionally a computer
would not have been considered. A general purpose and comparatively low-cost
microcontroller may often be programmed to fulfill the same role as a large
number of separate components. Although in this context an embedded system
is usually more complex than a traditional solution, most of the complexity is
contained within the microcontroller itself. Very few additional components
may be needed and most of the design effort is in the software. The intangible
nature of software makes it much easier to prototype and test new revisions
compared with the design and construction of a new circuit not using an
embedded processor.

3
1.4 Scope of Embedded System
Embedded systems are designed to do some specific task, rather than be a
general-purpose computer for multiple tasks. Some also have real-time
performance constraints that must be met, for reasons such as safety and
usability others may have low or no performance requirements, allowing the
system hardware to be simplified to reduce costs.  
Embedded systems are not always standalone devices. Many embedded
systems consist of small, computerized parts within a larger device that serves a
more general purpose. For example, the Gibson Robot Guitar features an
embedded system for tuning the strings, but the overall purpose of the Robot
Guitar is, of course, to play musicThe program instructions written for
embedded systems are referred to as firmware, and are stored in read-only
memory or Flash memory chips. They run with limited computer hardware
resources: little memory, small or non-existent keyboard and/or screen.
1.5 What is embedded system
An embedded system is a computer system designed to perform one or a few
dedicated functions often with real-time computing constraints. It is embedded
as part of a complete device often including hardware and mechanical parts..

A system containing a processor where the processor is not generally


reprogrammable by the end user. For example, a cell phone containing a DSP
processor is an embedded system
A computer system that is a component of a larger machine or system.
Embedded systems can respond to events in real time. Hosts of embedded
systems include watches, household appliances, cars, and cellular telephones.
An embedded system is a computer system designed to perform one or a few
dedicated functions  often with real time constraints. It is embedded as part of a
complete device often including hardware and mechanical parts. By contrast, a
general-purpose computer, such as a personel computer (PC), is designed to be
flexible and to meet a wide range of end-user needs. Embedded systems control
many devices in common use today.
Embedded systems are controlled by one or more main processing cores that are
may require very powerful processors. For example, air traffic control systems
radar 4
Since the embedded system is dedicated to specific tasks, design engineers can
optimize it to reduce the size and cost of the product and increase the reliability
and performance. Some embedded systems are mass-produced, benefiting
from economies of scale.
Physically, embedded systems range from portable devices such as digital
watches and MP3 players, to large stationary installations like traffic
lights, factory controllers, or the systems controlling nuclear power plants.
Complexity varies from low, with a single microcontroller chip, to very high
with multiple units, peripherals and networks mounted inside a large chassis or
enclosure.

In general, "embedded system" is not a strictly definable term, as most systems


have some element of extensibility or programmability. For example, computers
share some elements with embedded systems such as the operating systems and
microprocessors which power them, but they allow different applications to be
loaded and peripherals to be connected. Moreover, even systems which don't
expose programmability as a primary feature generally need to support software
updates. On a continuum from "general purpose" to "embedded", large
application systems will have subcomponents at most points even if the system
as a whole is "designed to perform one or a few dedicated functions", and is
thus appropriate to call "embedded".

Picture of the internals of an ADSL modem/router. A modern example of an


embedded system. Labeled parts include a microprocessor RAM and flash
memory 

6
1.6 Characteristics:
1. Embedded systems are designed to do some specific task, rather than be a
general-purpose computer for multiple tasks. Some also have real-
time performance constraints that must be met, for reasons such as safety
and usability; others may have low or no performance requirements,
allowing the system hardware to be simplified to reduce costs.

Fig: Gumstix Overdo COM, a tiny, OMAP-based embedded module with Wi-Fi and Bluetooth.

2. Embedded systems are not always standalone devices. Many embedded


systems consist of small, computerized parts within a larger device that
serves a more general purpose. For example, the Gibson Robot
Guitar features an embedded system for tuning the strings, but the overall
purpose of the Robot Guitar is, of course, to play music. [5] Similarly, an
embedded system in an automobile provides a specific function as a
subsystem of the car itself.

7
Fig: e-con Systems eSOM270 & eSOM300 Computer on Modules

1. The program instructions written for embedded systems are referred to


as firmware, and are stored in read-only memory or Flash memory chips.
They run with limited computer hardware resources: little memory, small
or non-existent keyboard and/or screen.

User interface:
Embedded systems range from no user interface at all dedicated only to one task
to complex interfaces that resemble modern computer desktop operating
systems. Simple embedded devices use buttons, LEDs, graphic or
character LCDs (for example popular HD44780 LCD) with a simple menu
system.

Fig: Embedded system interface using MicroVGA

A more sophisticated devices use graphical screen with touch sensing or screen-


edge buttons provide flexibility while minimizing space used: the meaning of
the buttons can change with the screen, and selection involves the natural
behavior of pointing at what's desired. Handheld systems often have a screen
with a "joystick button" for a pointing device. 8
Some systems provide user interface remotely with the help of a serial (e.g. RS-
232, USB, I²C, etc.) or network (e.g. Ethernet) connection. In spite of the
potentially necessary proprietary client software and/or specialist cables that are
needed, this approach usually gives a lot of advantages: extends the capabilities
of embedded system, avoids the cost of a display, simplifies BSP, allows to
build rich user interface on the PC. A good example of this is the combination
of an embedded web server running on an embedded device (such as an IP
camera or a network routers. The user interface is displayed in a web
browser on a PC connected to the device, therefore needing no bespoke
software to be installed.
Processors in embedded systems:
Firstly, Embedded processors can be broken into two broad categories: ordinary
microprocessors (μP) and microcontrollers (μC), which have many more
peripherals on chip, reducing cost and size. Contrasting to the personal
computer and server markets, a fairly large number of basic CPU
architectures are used; there are Von Neumann as well as various degrees
of Harvard architectures, RISC as well as non-RISC and VLIW; word lengths
vary from 4-bit to 64-bits and beyond (mainly in DSP processors) although the
most typical remain 8/16-bit. Most architectures come in a large number of
different variants and shapes, many of which are also manufactured by several
different companies.
Ready made computer boards:
PC/104 and PC/104+ are examples of standards for ready made computer
boards intended for small, low-volume embedded and ruggedized systems,
mostly x86-based. These often use DOS, Linux, NetBSD, or an embedded real-
time operating system such as MicroC/OS-II, QNX or VxWorks. Sometimes
these boards use non-x86 processors.
In certain applications, where small size or power efficiency are not primary
concerns, the components used may be compatible with those used in general
purpose x86 personal computers. Boards such as the VIA EPIA range help to
bridge the gap by being PC-compatible but highly integrated, physically smaller
or have other attributes making them attractive to embedded engineers. The
advantage of this approach is that low-cost commodity components may be
used along with the same software development tools used for general software
development. Systems built in this way are still regarded as embedded since
they are integrated into larger devices and fulfill a single role. Examples of
devices that may adopt this approach are ATMs and arcade machines, which
contain code specific to the application. 9
However, most ready-made embedded systems boards are not PC-centered and
do not use the ISA or PCI busses. When a System-on-a-chip processor is
involved, there may be little benefit to having a standardized bus connecting
discrete components, and the environment for both hardware and software tools
may be very different.
One common design style uses a small system module, perhaps the size of a
business card, holding high density BGA chips such as an ARM-based System-
on-a-chip processor and peripherals, external flash memory for storage,
and DRAM for runtime memory. The module vendor will usually provide boot
software and make sure there is a selection of operating systems, usually
including Linux and some real time choices. These modules can be
manufactured in high volume, by organizations familiar with their specialized
testing issues, and combined with much lower volume custom main boards with
application-specific external peripherals. Gumstix product lines are a Linux-
centric example of this model.

ASIC and FPGA solutions:


A common array of n configuration for very-high-volume embedded systems is
the system on a chip (SOC) which contains a complete system consisting of
multiple processors, multipliers, caches and interfaces on a single chip. SOCs
can be implemented as an application-specific integrated circuit (ASIC) or using
a field-programmable gate array (FPGA)
Peripherals
Embedded Systems talk with the outside world via peripherals, such as:

 Serial Communication Interfaces (SCI): RS-232, RS-422, RS-485 etc.


 Synchronous Serial Communication Interface: I2C, SPI, SSC and ESSI
(Enhanced Synchronous Serial Interface)
 Universal Serial Bus (USB)
 Multi Media Cards (SD Cards, Compact Flash etc.)
 Networks: Ethernet, Controller Area Network, LonWorks, etc.
 Timers: PLL(s), Capture/Compare and Time Processing Units
 Discrete IO: aka General Purpose Input/Output (GPIO)
 Analog to Digital/Digital to Analog (ADC/DAC)
 Debugging: JTAG, ISP, ICSP, BDM Port, BITP, and DP9 ports.

Tools 10
As for other software, embedded system designers use compilers, assemblers,
and debuggers to develop embedded system software. However, they may also
use some more specific tools:

 In circuit debuggers or emulators utilities to add a checksum or CRC to a


program, so the embedded system can check if the program is valid.

 For systems using digital signal processing, developers may use a math


workbench such
as Scilab / Scicos, MATLAB / Simulink, EICASLAB, MathCad, 
Mathematics or FlowStone DSP to simulate the mathematics. They might
also use libraries for both the host and target which eliminates developing
DSP routines as done in DSPnano RTOS and Unison Operating System.
 Custom compilers and linkers may be used to improve optimisation for
the particular hardware.
 An embedded system may have its own special language or design tool,
or add enhancements to an existing language such as Forth or Basic.
 Another alternative is to add a real-time operating system or embedded
operating system, which may have DSP capabilities like DSPnano RTOS.
 Modeling and code generating tools often based on state machines

Software tools can come from several sources:

 Software companies that specialize in the embedded market


 Ported from the GNU software development tools
 Sometimes, development tools for a personal computer can be used if the
embedded processor is a close relative to a common PC processor

As the complexity of embedded systems grows, higher level tools and


operating systems are migrating into machinery where it makes sense. For
example, cell phones, personal digital assistants and other consumer computers
often need significant software that is purchased or provided by a person other
than the manufacturer of the electronics. In these systems, an open
programming environment such as Linux, NetBSD, OSGi or Embedded Java is
required so that the third-party software provider can sell to a large market.

11
Debugging
Embedded debugging may be performed at different levels, depending on the
facilities available. From simplest to most sophisticated they can be roughly
grouped into the following areas:

 Interactive resident debugging, using the simple shell provided by the


embedded operating system (e.g. Forth and Basic)
 External debugging using logging or serial port output to trace operation
using either a monitor in flash or using a debug server like the Remedy
Debugger which even works for heterogeneous multicore systems.
 An in-circuit debugger (ICD), a hardware device that connects to the
microprocessor via a JTAG or Nexus interface. This allows the operation of
the microprocessor to be controlled externally, but is typically restricted to
specific debugging capabilities in the processor.
 An in-circuit emulator replaces the microprocessor with a simulated
equivalent, providing full control over all aspects of the microprocessor.
 A complete emulator provides a simulation of all aspects of the hardware,
allowing all of it to be controlled and modified, and allowing debugging on a
normal PC.

Unless restricted to external debugging, the programmer can typically load and
run software through the tools, view the code running in the processor, and start
or stop its operation. The view of the code may be as assembly code or source-
code.
Because an embedded system is often composed of a wide variety of elements,
the debugging strategy may vary. For instance, debugging a software- (and
microprocessor-) centric embedded system is different from debugging an
embedded system where most of the processing is performed by peripherals
(DSP, FPGA, co-processor). An increasing number of embedded systems today
use more than one single processor core. A common problem with multi-core
development is the proper synchronization of software execution. In such a
case, the embedded system design may wish to check the data traffic on the
busses between the processor cores, which requires very low-level debugging,
at signal/bus level, with a logic analyzer, for instance.

12
Reliability
Embedded systems often reside in machines that are expected to run
continuously for years without errors, and in some cases recover by themselves
if an error occurs. Therefore the software is usually developed and tested more
carefully than that for personal computers, and unreliable mechanical moving
parts such as disk drives, switches or buttons are avoided.
Specific reliability issues may include:

1. The system cannot safely be shut down for repair, or it is too inaccessible
to repair. Examples include space systems, undersea cables, navigational
beacons, bore-hole systems, and automobiles.
2. The system must be kept running for safety reasons. "Limp modes" are
less tolerable. Often backups are selected by an operator. Examples
include aircraft navigation, reactor control systems, safety-critical
chemical factory controls, train signals, engines on single-engine aircraft.
3. The system will lose large amounts of money when shut down:
Telephone switches, factory controls, bridge and elevator controls, funds
transfer and market making, automated sales and service.

A variety of techniques are used, sometimes in combination, to recover from


errors—both software bugs such as memory leaks, and also soft errors in the
hardware:

 watchdog timer that resets the computer unless the software periodically


notifies the watchdog
 subsystems with redundant spares that can be switched over to
 software "limp modes" that provide partial function
 Designing with a Trusted Computing Base (TCB) architecture[6] ensures a
highly secure & reliable system environment
 An Embedded Hypervisor is able to provide secure encapsulation for any
subsystem component, so that a compromised software component cannot
interfere with other subsystems, or privileged-level system software. This
encapsulation keeps faults from propagating from one subsystem to another,
improving reliability. This may also allow a subsystem to be automatically
shut down and restarted on fault detection.

13
Immunity Aware Programming High vs low volume
For high volume systems such as portable music players or mobile phones,
minimizing cost is usually the primary design consideration. Engineers typically
select hardware that is just “good enough” to implement the necessary
functions.
For low-volume or prototype embedded systems, general purpose computers
may be adapted by limiting the programs or by replacing the operating system
with a real-time operating system.

UNIT 2

2.1 About the 8051


The Intel 8051 is an 8-bit microcontroller which means that most available
operations are limited to 8 bits. There are 3 basic "sizes" of the 8051: Short,
Standard, and Extended. The Short and Standard chips are often available in
DIP form, but the Extended 8051 models often have a different form factor, and
are not "drop-in compatible". All these things are called 8051 because they can
all be programmed using 8051 assembly language, and they all share certain
features (although the different models all have their own special features).
Some of the features that have made the 8051 popular are:

 8-bit data bus


 16-bit address bus
 32 general purpose registers each of 8 bits
 16 bit timers (usually 2, but may have more, or less).
 3 internal and 2 external interrupts.
 Bit as well as byte addressable RAM area of 16 bytes.
 Four 8-bit ports, (short models have two 8-bit ports).
 16-bit program counter and data pointer

14
2.2 Typical applications
8051 chips are used in a wide variety of control systems, telecom applications,
robotics as well as in the automotive industry. By some estimations, 8051
family chips make up over 50% of the embedded chip market.

Pin diagram of the 8051 DIP

2.3 Basic Pins


PIN 9: PIN 9 is the reset pin which is used reset the microcontroller’s internal
registers and ports upon starting up.2 machine cycle should be high at this pin.
PINS 18 & 19: The 8051 has a built-in oscillator amplifier hence we need to
only connect a crystal at these pins to provide clock pulses to the circuit.
PIN 40 and 20: Pins 40 and 20 are VCC and ground respectively. The 8051 chip
needs +5V 500mA to function properly, although there are lower powered
versions like the Atmel 2051 which is a scaled down version of the 8051 which
runs on +3V.
PINS 29, 30 & 31: As described in the features of the 8051, this chip contains a
built-in flash memory. In order to program this we need to supply a voltage of
+12V at pin 31. If external memory is connected then PIN 31, also called
EA/VPP, should be connected to ground to indicate the presence of external

15
memory. PIN 30 is called ALE (address latch enable), which is used when
multiple memory chips are connected to the controller and only one of them
needs to be selected. We will deal with this in depth in the later chapters. PIN
29 is called PSEN. This is "program select enable". In order to use the external
memory it is required to provide the low voltage (0) on both PSEN and EA pins.

2.4 Ports
There are four 8 bit ports: P0, P1, P2 and P3.
PORT P1 (Pins 1 to 8): The port P1 is a general purpose input/output port which
can be used for a variety of interfacing tasks. The other ports P0, P2 and P3
have dual roles or additional functions associated with them based upon the
context of their usage.
PORT P3 (Pins 10 to 17): PORT P3 acts as a normal IO port, but Port P3 has
additional functions such as, serial transmit and receive pins, 2 external
interrupt pins, 2 external counter inputs, read and write pins for memory access.
PORT P2 (pins 21 to 28): PORT P2 can also be used as a general purpose 8 bit
port when no external memory is present, but if external memory access is
required then PORT P2 will act as an address bus in conjunction with PORT P0
to access external memory. PORT P2 acts as A8-A15.
PORT P0 (pins 32 to 39) PORT P0 can be used as a general purpose 8 bit port
when no external memory is present, but if external memory access is required
then PORT P0 acts as a multiplexed address and data bus that can be used to
access external memory in conjunction with PORT P2. P0 acts as AD0-AD7, as
can be seen from fig 1.1

16
2.
5 Oscillator Circuits
The 8051 requires the existence of an external oscillator circuit. The oscillator
circuit usually runs around 12MHz, although the 8051 (depending on which
specific model) is capable of running at a maximum of 40MHz. Each machine
cycle in the 8051 is 12 clock cycles, giving an effective cycle rate at 1MHz (for
a 12MHz clock) to 3.33MHz (for the maximum 40MHz clock).

2.6 Internal Architecture

2.7 Architecture Feature

• 8-Bit CPU Optimized for Control Applications


• Extensive Boolean Processing Capabilities (Single-Bit Logic)
• On-Chip Flash Program Memory
• On-Chip Data RAM
• Bidirectional and Individually Addressable I/O Lines
• Multiple 16-Bit Timer/Counters
• Full Duplex UART
• Multiple Source/Vector/Priority Interrupt Structure
• On-Chip Clock Oscillator
• On-chip EEPROM (AT89S series) 17
• SPI Serial Bus Interface (AT89S Series)
• Watchdog Timer (AT89S Series)

2.8 Data and Program Memory


The 8051 Microprocessor can be programmed in PL/M, 8051 Assembly, C and
a number of other high-level languages. Many compilers even have support for
compiling C++ for an 8051.
Program memory in the 8051 is read-only, while the data memory is considered
to be read/write accessible. When stored on EEPROM or Flash, the program
memory can be rewritten when the microcontroller is in the special programmer
circuit.

2.9Program Start Address


The 8051 starts executing program instructions from address 0x00 in the
program.

2.10 Direct Memory


The 8051 has 256 bytes of internal addressable RAM, although only the first
128 bytes are available for general use by the programmer. The first 128 bytes
of RAM (from 0x00 to 0x7F) are called the Direct Memory, and can be used to
store data.

2.11 Special Function Register


The Special Function Register (SFR) is the upper area of addressable memory,
from address 0x80 to 0xFF. This area of memory cannot be used for data or
program storage, but is instead a series of memory-mapped ports and registers.
All port input and output can therefore be performed by
memory mov operations on specified addresses in the SFR. Also, different
status registers are mapped into the SFR, for use in checking the status of the
8051, and changing some operational parameters of the 8051.

18
2.12 General Purpose Registers
The 8051 has 4 selectable banks of 8 addressable 8-bit registers, R0 to R7. This
means that there are essentially 32 available general purpose registers, although
only 8 (one bank) can be directly accessed at a time. To access the other banks,
we need to change the current bank number in the flag status register.

2.13 A and B Registers


The A register is located in the SFR and by default it receives the result of all
arithmetic operations. The B register is used in a similar manner, except that it
can receive the extended answers from the multiply and divide operations.
When not being used for multiplication and Division, the B register is available.

2.14 Memory Organization


Logical Separation of Program Data Memory
All Atmel Flash microcontrollers have separate address spaces for program and
data memory. The logical separation of program and data memory allows the
data memory to be accessed by 8-bit addresses, which can be more quickly
stored and manipulated by an 8- bit CPU. Nevertheless, 16-bit data memory
addresses can also be generated through the DPTR register. Program memory
can only be read. There can be up to 64K bytes of directly addressable program
memory. The read strobe for external program memory is the Program Store
Enable signal (PSEN). Data memory occupies a separate address space from
program memory. Up to 64K bytes of external memory can be directly
addressed in the external data memory space. The CPU generates read and write
signals, RD and WR, during external data memory accesses. External program
memory and external data memory can be combined by applying the RD and
PSEN signals to the input of an AND gate and using the output of the gate as
the read strobe to the external program/data memory.

Program Memory
After reset, the CPU begins execution from location 0000H. each interrupt is
assigned a fixed location in program memory. The interrupt causes the CPU to
jump to that location, where it executes the service routine. External Interrupt 0,
for example, is assigned to location 0003H. If External Interrupt is used, its
19
service routine must begin at location 0003H. If the interrupt is not used, its
service location is available as general purpose program memory. The interrupt
service locations are spaced at 8-byte intervals:
0003H for External Interrupt 0, 000BH for Timer 0,
0013H for External Interrupt 1, 001BH for Timer 1, and so on. If an interrupt
service routine is short enough (as is often the case in control applications), it
can reside entirely within that 8-byte interval. Longer service routines can use a
jump instruction to skip over subsequent interrupt locations, if other interrupts
are in use. The lowest addresses of program memory can be either in
the on-chip Flash or in an external memory. To make this selection, strap the
External Access (EA) pin to either VCC or GND. For example, in the AT89C51
with 4K bytes of on-chip Flash, if the EA pin is strapped to VCC, program
fetches to addresses 0000H through 0FFFH are directed to the internal Flash.
Program fetches to addresses 1000H through FFFFH are directed to external
memory. In the AT89C52 (8K bytes Flash), EA = VCC selects addresses 0000H
through 1FFFH to be internal and addresses 2000H through FFFFH to be
external. If the EA pin is strapped to GND, all program fetches are directed to
external memory. The read strobe to external memory, PSEN, is used for all
external program fetches. Internal program fetches do not activate PSEN.
The hardware configuration for external program execution. Note that 16 I/O
lines (Ports 0 and 2)
are dedicated to bus functions during external program memory fetches. Port 0
(P0 in Figure 5) serves as a multiplexed address/data bus. It emits the low byte
of the Program Counter (PCL) as an address and then goes into a float state
while waiting for the arrival of the code byte from
the program memory. During the time that the low byte of the Program Counter
is valid on P0, the signal ALE (Address Latch Enable) clocks this byte into an
address latch. Meanwhile, Port 2 emits the high byte of the Program Counter
(PCH). Then PSEN strobes the external memory, and the microcontroller reads
the code byte.

20
Program Memory

Program memory addresses are always 16 bits wide, even though the actual
amount of program memory used may be less than 64K bytes. External program
execution sacrifices two of the 8-bit ports, P0 and P2, to the function of
addressing the program memory.

Data Memory
The right half of the internal and external data memory spaces available on
Atmel’s Flash microcontrollers. Hardware configuration for accessing up to 2K
bytes of external RAM. In this case, the CPU executes from internal Flash. Port
0 serves as a multiplexed address/data bus to the RAM, and 3 lines of Port 2 are
used to page the RAM. The CPU generates RD and WR signals as needed
during external RAM accesses. You can assign up to 64K bytes of external data
memory. External data memory addresses can be either 1 or 2 bytes wide. One-
byte addresses are often used in conjunction with one or more other I/O lines to
page the RAM. Two-byte addresses can also be used, in which case the high
address byte is emitted at Port 2.

21
Internal data memory addresses are always 1 byte wide, which implies an
address space of only 256 bytes. However, the addressing modes for internal
RAM can in fact accommodate 384 bytes. Direct addresses higher than 7FH
access one memory space, and indirect addresses higher than 7FH access a
different memory space. Thus, the Upper 128 and SFR space occupying the

same block of addresses, 80H through FFH, although they are physically
separate entities. The lowest 32 bytes are grouped into 4 banks of 8 registers.
Program instructions call out these registers as R0 through R7. Two bits in the
Program Status Word (PSW) select which register bank is in use. This
architecture allows more efficient use of code space, since register instructions
are shorter than instructions that use direct addressing.

22
23
Programming Status Word:

Program Status Word


The Program Status Word (PSW) contains status bits that reflect the current
state of the CPU. The PSW, shown in Figure 11, resides in SFR space. The
PSW contains the Carry bit, the Auxiliary Carry (for BCD operations), the two
register bank select bits, the Overflow flag, a Parity bit, and two user-definable
status flags. The Carry bit, in addition to serving as a Carry bit in arithmetic
operations, also serves as the “Accumulator” for a number of Boolean
operations.
The bits RS0 and RS1 select one of the four register banks shown in Figure 8. A
number of instructions refer to these RAM locations as R0 through R7. The
status of the RS0 and RS1 bits at execution time determines which of the four
banks is selected. The Parity bit reflects the number of 1s in the Accumulator:
P=1 if the Accumulator contains an odd number of 1s, and P=0 if the
Accumulator contains an even number of 1s. Thus, the number of 1s in the
Accumulator plus P is always even. Two bits in the PSW are uncommitted and
can be used as general purpose status flags.

23
Addressing Modes

The addressing modes in the Flash microcontroller instruction set are as


follows.
Direct Addressing
In direct addressing, the operand is specified by an 8-bit address field in the
instruction. Only internal data RAM and SFRs can be directly addressed.

Indirect Addressing
In indirect addressing, the instruction specifies a register that contains the
address of the operand. Both internal and external RAM can be indirectly
addressed. The address register for 8-bit addresses can be either the Stack
Pointer or R0 or R1 of the selected register bank. The address register for 16-bit
addresses can be only the 16-bit data pointer register, DPTR.

Register Instructions

The register banks, which contain registers R0 through R7, can be accessed by
instructions whose opcodes carry a 3- bit register specification. Instructions that
access the registers this way make efficient use of code, since this mode
eliminates an address byte. When the instruction is executed, one of the eight
registers in the selected bank is accessed. One of four banks is selected at
execution time by the two bank select bits in the PSW.

Register-Specific Instructions
Some instructions are specific to a certain register. For example, some
instructions always operate on the Accumulator, so no address byte is needed to
point to it. In these cases, the opcode itself points to the correct register.
Instructions that refer to the Accumulator as an assemble as Accumulator-
specific opcodes.

Indexed Addressing
Program memory can only be accessed via indexed addressing. This addressing
mode is intended for reading look-up tables in program memory. A 16-bit base
register (either DPTR or the Program Counter) points to the base of the table,
and the Accumulator is set up with the table entry number. The address of the
table entry in program memory is formed by adding the Accumulator data to the
base pointer.

24
Another type of indexed addressing is used in the “case
jump” instruction. In this case the dest ination address of a jump instruction is
computed as the sum of the base pointer and the Accumulator data.

The Instruction Set


All members of the Atmel microcontroller family execute the same instruction
set. This instruction set is optimized for 8- bit control applications and it
provides a variety of fast addressing modes for accessing the internal RAM to
facilitate byte operations on small data structures. The instruction set provides
extensive support for 1-bit variables as a separate data type, allowing direct bit
manipulation in control and logic systems that require Boolean processing. The
following overview of the instruction set gives a brief description of how certain
instructions can be used

Serial communication
The concept of serial communication is the process of sending data one bit at a
time, sequentially, over a communication channel or computer bus. This is in
contrast to parallel communication, where several bits are sent as a whole, on a
link with several parallel channels. Serial communication is used for all long-haul
communication and most computer networks, where the cost
of cable and synchronization difficulties make parallel communication impractical.
Serial computer buses are becoming more common even at shorter distances, as
improved signal integrity and transmission speeds in newer serial technologies
have begun to outweigh the parallel bus's advantage of simplicity

2.15 Advantage
 Enables real-time, deterministic scheduling and task prioritization
 Abstracts away the complexities of the processor
 Provides a solid infrastructure constructed of rules and policies
 Simplifies development and improves developer productivity
 Integrates and manages resources needed by communications stacks and
middleware
 Optimizes use of system resources
 Improves product reliability, maintainability and quality
 Promotes product evolution and scaling
25

2.15 Applications
 Communications applications
 Medical electronics technology
 Military and aerospace embedded software applications
 Electronics applications and consumer devices
 Industrial automation and process control software

Conclusion
After completing this report I have understood the importance of this very topic.
I have tried my level best in briefly each and every dimension the specified
topics so it may a source of impactful information to the readers

REFERENCES:
From the book of M.S.Mazidi
From the Wikipedia

26
26

Potrebbero piacerti anche