Anda di halaman 1dari 64

Department of ECE Embedded Systems Lab

VRR0HRHRN 0LLE0E 0F EN0lNEERlN0, $HRH$HRBR0 VRR0HRHRN 0LLE0E 0F EN0lNEERlN0, $HRH$HRBR0 VRR0HRHRN 0LLE0E 0F EN0lNEERlN0, $HRH$HRBR0 VRR0HRHRN 0LLE0E 0F EN0lNEERlN0, $HRH$HRBR0
1

EMBEDDED SYSTEMS

Embedded system overview:
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 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 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.
Examples of embedded systems







PC Engines' ALIX.1C Mini-ITX embedded board with an x86 AMD Geode LX 800 together
with Compact Flash, miniPCI and PCI slots, 44-pin IDE interface, audio, USB and 256MB
RAM
An embedded RouterBoard 112 with U.FL-RSMA pigtail and R52
miniPCI Wi-Fi card widely used by wireless Internet service
providers (WISPs) in the Czech Republic. Embedded systems span
all aspects of modern life and there are many examples of their
use.
www.jntuworld.com
www.jntuworld.com
www.jwjobs.net
Department of ECE Embedded Systems Lab

VRR0HRHRN 0LLE0E 0F EN0lNEERlN0, $HRH$HRBR0 VRR0HRHRN 0LLE0E 0F EN0lNEERlN0, $HRH$HRBR0 VRR0HRHRN 0LLE0E 0F EN0lNEERlN0, $HRH$HRBR0 VRR0HRHRN 0LLE0E 0F EN0lNEERlN0, $HRH$HRBR0
2
Telecommunications systems employ numerous embedded systems from telephone switches for the
network to mobile phones at the end-user. Computer networking uses dedicated routers and network
bridges to route data.

Consumer electronics include personal digital assistants (PDAs), mp3 players, mobile phones,
videogame consoles, digital cameras, DVD players, GPS receivers, and printers. Many household
appliances, such as microwave ovens, washing machines and dishwashers, are including embedded
systems to provide flexibility, efficiency and features. Advanced HVAC systems use networked
thermostats to more accurately and efficiently control temperature that can change by time of day and
season. Home automation uses wired- and wireless-networking that can be used to control lights,
climate, security, audio/visual, etc., all of which use embedded devices for sensing and controlling.

Transportation systems from flight to automobiles increasingly use embedded systems. New airplanes
contain advanced avionics such as inertial guidance systems and GPS receivers that also have
considerable safety requirements. Various electric motors - brushless DC motors, induction motors and
DC motors - are using electric/electronic motor controllers. Automobiles, electric vehicles, and hybrid
vehicles are increasingly using embedded systems to maximize efficiency and reduce pollution. Other
automotive safety systems such as anti-lock braking system (ABS), Electronic Stability Control
(ESC/ESP), traction control (TCS) and automatic four-wheel drive.

Medical equipment is continuing to advance with more embedded systems for vital signs monitoring,
electronic stethoscopes for amplifying sounds, and various medical imaging (PET, SPECT, CT, MRI) for
non-invasive internal inspections.

In addition to commonly described embedded systems based on small computers, a new class of
miniature wireless devices called motes are quickly gaining popularity as the field of wireless sensor
networking rises. Wireless sensor networking, WSN, makes use of miniturization made possible by
advanced IC design to couple full wireless subsystems to sophisticated sensor, enabling people and
companies to measure a myriad of things in the physical world and act on this information through IT
monitoring and control systems. These motes are completely self contained, and will typically run off a
battery source for many years before the batteries need to be changed or charged.
History
In the earliest years of computers in the 1930-40s, 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 controllers evolved from traditional
electromechanical sequencers, via solid state devices, to the use of computer technology.

One of the first recognizably modern embedded systems was the Apollo Guidance Computer,
developed by Charles Stark Draper at the MIT Instrumentation Laboratory. At the project's inception, the
Apollo guidance computer was considered the riskiest item in the Apollo project as it employed the then
www.jntuworld.com
www.jntuworld.com
www.jwjobs.net
Department of ECE Embedded Systems Lab

VRR0HRHRN 0LLE0E 0F EN0lNEERlN0, $HRH$HRBR0 VRR0HRHRN 0LLE0E 0F EN0lNEERlN0, $HRH$HRBR0 VRR0HRHRN 0LLE0E 0F EN0lNEERlN0, $HRH$HRBR0 VRR0HRHRN 0LLE0E 0F EN0lNEERlN0, $HRH$HRBR0
3
newly developed monolithic integrated circuits to reduce the size and weight. An early massproduced
embedded system was the Autonetics D-17 guidance computer for the Minuteman missile, released in
1961. It was built from transistor logic and had a hard disk for main memory. When the Minuteman II
went into production in 1966, the D-17 was replaced with a new computer that was the first high-volume
use of integrated circuits. This program alone reduced prices on quad nand gate ICs from $1000/each to
$3/each, permitting their use in commercial products.

Since these early applications in the 1960s, embedded systems have come down in price and there has
been a dramatic rise in processing power and functionality. 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 potentiometers and variable capacitors 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.

Characteristics









www.jntuworld.com
www.jntuworld.com
www.jwjobs.net
Department of ECE Embedded Systems Lab

VRR0HRHRN 0LLE0E 0F EN0lNEERlN0, $HRH$HRBR0 VRR0HRHRN 0LLE0E 0F EN0lNEERlN0, $HRH$HRBR0 VRR0HRHRN 0LLE0E 0F EN0lNEERlN0, $HRH$HRBR0 VRR0HRHRN 0LLE0E 0F EN0lNEERlN0, $HRH$HRBR0
4
Soekris net4801, an embedded system targeted at network applications.

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.
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.
[2]
Similarly, an embedded
system in an automobile provides a specific function as a subsystem of the car itself.
3. 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 interfaces
Embedded system Text user interface using MicroVGA
Embedded systems range from no user interface at all - dedicated only
to one task - to complex graphical user interfaces that resemble modern
computer desktop operating systems.

Simple systems

Simple embedded devices use buttons, LEDs, and small character- or digit-only displays, often with a
simple menu system.

In more complex systems
A full graphical screen, with touch sensing or screen-edge buttons provides flexibility while minimising
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.

The rise of the World Wide Web has given embedded designers another quite different option:
providing a web page interface over a network connection. This avoids the cost of a sophisticated
display, yet provides complex input and display capabilities when needed, on another computer. This is
successful for remote, permanently installed equipment such as Pan-Tilt-Zoom cameras and
network routers.


www.jntuworld.com
www.jntuworld.com
www.jwjobs.net
Department of ECE Embedded Systems Lab

VRR0HRHRN 0LLE0E 0F EN0lNEERlN0, $HRH$HRBR0 VRR0HRHRN 0LLE0E 0F EN0lNEERlN0, $HRH$HRBR0 VRR0HRHRN 0LLE0E 0F EN0lNEERlN0, $HRH$HRBR0 VRR0HRHRN 0LLE0E 0F EN0lNEERlN0, $HRH$HRBR0
5
CPU platforms

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.

A long but still not exhaustive list of common architectures are: 65816, 65C02, 68HC08, 68HC11, 68k,
8051, ARM, AVR, AVR32, Blackfin, C167, Coldfire, COP8, eZ8, eZ80, FR-V, H8, HT48, M16C, M32C,
MIPS, MSP430, PIC, PowerPC, R8C, SHARC, ST6, SuperH, TLCS-47, TLCS-870, TLCS-900, Tricore,
V850, x86, XE8000, Z80, etc.

Ready made computer boards

PC/104 and PC/104+ are examples of available ready made computer boards intended for small, low-
volume embedded and ruggedized systems. These often use DOS, Linux, NetBSD, or an embedded
real-time operating system such as MicroC/OS-II, QNX or VxWorks.

In certain applications, where small size is not a primary concern, the components used may be
compatible with those used in general purpose 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 lowcost
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.

ASIC and FPGA solutions

A common 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).


www.jntuworld.com
www.jntuworld.com
www.jwjobs.net
Department of ECE Embedded Systems Lab

VRR0HRHRN 0LLE0E 0F EN0lNEERlN0, $HRH$HRBR0 VRR0HRHRN 0LLE0E 0F EN0lNEERlN0, $HRH$HRBR0 VRR0HRHRN 0LLE0E 0F EN0lNEERlN0, $HRH$HRBR0 VRR0HRHRN 0LLE0E 0F EN0lNEERlN0, $HRH$HRBR0
6
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
Universal Serial Bus (USB)
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, ...

Tools

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 (see next section).
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, MathCad, or Mathematica 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.

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
www.jntuworld.com
www.jntuworld.com
www.jwjobs.net
Department of ECE Embedded Systems Lab

VRR0HRHRN 0LLE0E 0F EN0lNEERlN0, $HRH$HRBR0 VRR0HRHRN 0LLE0E 0F EN0lNEERlN0, $HRH$HRBR0 VRR0HRHRN 0LLE0E 0F EN0lNEERlN0, $HRH$HRBR0 VRR0HRHRN 0LLE0E 0F EN0lNEERlN0, $HRH$HRBR0
7
As the complexity of embedded systems grows, higher level tools and operating systems are migrating
into machinery where it makes sense. For example, cellphones, 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.

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.


www.jntuworld.com
www.jntuworld.com
www.jwjobs.net
Department of ECE Embedded Systems Lab

VRR0HRHRN 0LLE0E 0F EN0lNEERlN0, $HRH$HRBR0 VRR0HRHRN 0LLE0E 0F EN0lNEERlN0, $HRH$HRBR0 VRR0HRHRN 0LLE0E 0F EN0lNEERlN0, $HRH$HRBR0 VRR0HRHRN 0LLE0E 0F EN0lNEERlN0, $HRH$HRBR0
8
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
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.


www.jntuworld.com
www.jntuworld.com
www.jwjobs.net
Department of ECE Embedded Systems Lab

VRR0HRHRN 0LLE0E 0F EN0lNEERlN0, $HRH$HRBR0 VRR0HRHRN 0LLE0E 0F EN0lNEERlN0, $HRH$HRBR0 VRR0HRHRN 0LLE0E 0F EN0lNEERlN0, $HRH$HRBR0 VRR0HRHRN 0LLE0E 0F EN0lNEERlN0, $HRH$HRBR0
9
Embedded software architectures
There are several different types of software architecture in common use.

Simple control loop

In this design, the software simply has a loop. The loop calls subroutines, each of which manages a part
of the hardware or software.

Interrupt controlled system

Some embedded systems are predominantly interrupt controlled. This means that tasks performed by the
system are triggered by different kinds of events. An interrupt could be generated for example by a timer
in a predefined frequency, or by a serial port controller receiving a byte.

These kinds of systems are used if event handlers need low latency and the event handlers are short and
simple.

Usually these kinds of systems run a simple task in a main loop also, but this task is not very sensitive to
unexpected delays.

Sometimes the interrupt handler will add longer tasks to a queue structure. Later, after the interrupt
handler has finished, these tasks are executed by the main loop. This method brings the system close to
a multitasking kernel with discrete processes.

Cooperative multitasking

A nonpreemptive multitasking system is very similar to the simple control loop scheme, except that the
loop is hidden in an API. The programmer defines a series of tasks, and each task gets its own
environment to "run" in. Then, when a task is idle, it calls an idle routine (usually called "pause",
"wait", "yield", "nop" (Stands for no operation), etc.).

The advantages and disadvantages are very similar to the control loop, except that adding new
software is easier, by simply writing a new task, or adding to the queue-interpreter.




www.jntuworld.com
www.jntuworld.com
www.jwjobs.net
Department of ECE Embedded Systems Lab

VRR0HRHRN 0LLE0E 0F EN0lNEERlN0, $HRH$HRBR0 VRR0HRHRN 0LLE0E 0F EN0lNEERlN0, $HRH$HRBR0 VRR0HRHRN 0LLE0E 0F EN0lNEERlN0, $HRH$HRBR0 VRR0HRHRN 0LLE0E 0F EN0lNEERlN0, $HRH$HRBR0
10
Preemptive multitasking or multi-threading

In this type of system, a low-level piece of code switches between tasks or threads based on a timer
(connected to an interrupt). This is the level at which the system is generally considered to have an
"operating system" kernel. Depending on how much functionality is required, it introduces more or less
of the complexities of managing multiple tasks running conceptually in parallel.

As any code can potentially damage the data of another task (except in larger systems using an MMU)
programs must be carefully designed and tested, and access to shared data must be controlled by
some synchronization strategy, such as message queues, semaphores or a non-blocking
synchronization scheme.

Because of these complexities, it is common for organizations to buy a real-time operating system,
allowing the application programmers to concentrate on device functionality rather than operating
system services, at least for large systems; smaller systems often cannot afford the overhead
associated with a generic real time system, due to limitations regarding memory size, performance,
and/or battery life.

Micro kernels and exo kernels

A microkernel is a logical step up from a real-time OS. The usual arrangement is that the operating
system kernel allocates memory and switches the CPU to different threads of execution. User mode
processes implement major functions such as file systems, network interfaces, etc.

In general, microkernels succeed when the task switching and intertask communication is fast, and fail
when they are slow.

Exokernels communicate efficiently by normal subroutine calls. The hardware, and all the software in the
system are available to, and extensible by application programmers.

Monolithic kernels

In this case, a relatively large kernel with sophisticated capabilities is adapted to suit an embedded
environment. This gives programmers an environment similar to a desktop operating system like
Linux or Microsoft Windows, and is therefore very productive for development; on the downside, it
requires considerably more hardware resources, is often more expensive, and because of the
complexity of these kernels can be less predictable and reliable.


www.jntuworld.com
www.jntuworld.com
www.jwjobs.net
Department of ECE Embedded Systems Lab

VRR0HRHRN 0LLE0E 0F EN0lNEERlN0, $HRH$HRBR0 VRR0HRHRN 0LLE0E 0F EN0lNEERlN0, $HRH$HRBR0 VRR0HRHRN 0LLE0E 0F EN0lNEERlN0, $HRH$HRBR0 VRR0HRHRN 0LLE0E 0F EN0lNEERlN0, $HRH$HRBR0
11
Common examples of embedded monolithic kernels are Embedded Linux and Windows CE.

Despite the increased cost in hardware, this type of embedded system is increasing in popularity,
especially on the more powerful embedded devices such as Wireless Routers and GPS Navigation
Systems. Here are some of the reasons:

Ports to common embedded chip sets are available.
They permit re-use of publicly available code for Device Drivers, Web Servers, Firewalls, and
other code.
Development systems can start out with broad feature-sets, and then the distribution can be
configured to exclude unneeded functionality, and save the expense of the memory that it
would consume.
Many engineers believe that running application code in user mode is more reliable, easier to
debug and that therefore the development process is easier and the code more portable.
Many embedded systems lack the tight real time requirements of a control system. A system
such as Embedded Linux has fast enough response for many applications.
Features requiring faster response than can be guaranteed can often be placed in hardware.
Many RTOS systems have a per-unit cost. When used on a product that is or will become a
commodity, that cost is significant.

Exotic custom operating systems

A small fraction of embedded systems require safe, timely, reliable or efficient behavior unobtainable
with the one of the above architectures. In this case an organization builds a system to suit. In some
cases, the system may be partitioned into a "mechanism controller" using special techniques, and a
"display controller" with a conventional operating system. A communication system passes data
between the two.

Additional software components

In addition to the core operating system, many embedded systems have additional upper-layer
software components. These components consists of networking protocol stacks like CAN, TCP/IP, FTP,
HTTP, and HTTPS, and also included storage capabilities like FAT and Flash memory management
systems. If the embedded devices has audio and video capabilities, then the appropriate drivers and
codecs will be present in the system. In the case of the monolithic kernels, many of these software
layers are included. In the RTOS category, the availability of the additional software components
depends upon the commercial offering.

www.jntuworld.com
www.jntuworld.com
www.jwjobs.net
Department of ECE Embedded Systems Lab

VRR0HRHRN 0LLE0E 0F EN0lNEERlN0, $HRH$HRBR0 VRR0HRHRN 0LLE0E 0F EN0lNEERlN0, $HRH$HRBR0 VRR0HRHRN 0LLE0E 0F EN0lNEERlN0, $HRH$HRBR0 VRR0HRHRN 0LLE0E 0F EN0lNEERlN0, $HRH$HRBR0
12
The integrated circuit from an Intel 8742, an 8-bit
microcontroller that includes a CPU running at 12 MHz, 128
bytes of RAM, 2048 bytes of EPROM, and I/O in the same chip.

A microcontroller (also MCU or C) is a functional computer
system-on-a-chip. It contains a processor core, memory, and
programmable input/output peripherals.

Microcontrollers include an integrated CPU, memory (a small
amount of RAM, program memory, or both) and peripherals
capable of input and output.
[1]

It emphasizes high integration, in contrast to a microprocessor which only contains a CPU (the kind used
in a PC). In addition to the usual arithmetic and logic elements of a general purpose
microprocessor, the microcontroller integrates additional elements such as read-write memory for
data storage, read-only memory for program storage, Flash memory for permanent data storage,
peripherals, and input/output interfaces. At clock speeds of as little as 32KHz, microcontrollers often
operate at very low speed compared to microprocessors, but this is adequate for typical applications.
They consume relatively little power (milliwatts or even microwatts), and will generally have the ability to
retain functionality while waiting for an event such as a button press or interrupt. Power
consumption while sleeping (CPU clock and peripherals disabled) may be just nanowatts, making them
ideal for low power and long lasting battery applications.
Microcontrollers are used in automatically controlled products and devices, such as automobile engine
control systems, remote controls, office machines, appliances, power tools, and toys. By reducing the
size, cost, and power consumption compared to a design using a separate microprocessor, memory,
and input/output devices, microcontrollers make it economical to electronically control many more
processes.

Embedded design

The majority of computer systems in use today are embedded in other machinery, such as
automobiles, telephones, appliances, and peripherals for computer systems. These are called
embedded systems. While some embedded systems are very sophisticated, many have minimal
requirements for memory and program length, with no operating system, and low software
complexity. Typical input and output devices include switches, relays, solenoids, LEDs, small or
custom LCD displays, radio frequency devices, and sensors for data such as temperature, humidity, light
level etc. Embedded systems usually have no keyboard, screen, disks, printers, or other
recognizable I/O devices of a personal computer, and may lack human interaction devices of any kind.

www.jntuworld.com
www.jntuworld.com
www.jwjobs.net
Department of ECE Embedded Systems Lab

VRR0HRHRN 0LLE0E 0F EN0lNEERlN0, $HRH$HRBR0 VRR0HRHRN 0LLE0E 0F EN0lNEERlN0, $HRH$HRBR0 VRR0HRHRN 0LLE0E 0F EN0lNEERlN0, $HRH$HRBR0 VRR0HRHRN 0LLE0E 0F EN0lNEERlN0, $HRH$HRBR0
13
Interrupts

It is mandatory that microcontrollers provide real time response to events in the embedded system they
are controlling. When certain events occur, an interrupt system can signal the processor to suspend
processing the current instruction sequence and to begin an interrupt service routine (ISR). The ISR will
perform any processing required based on the source of the interrupt before returning to the original
instruction sequence. Possible interrupt sources are device dependent, and often include events such as
an internal timer overflow, completing an analog to digital conversion, a logic level change on an input
such as from a button being pressed, and data received on a communication link. Where power
consumption is important as in battery operated devices, interrupts may also wake a microcontroller
from a low power sleep state where the processor is halted until required to do something by a
peripheral event.

Programs

Microcontroller programs must fit in the available on-chip program memory, since it would be costly to
provide a system with external, expandable, memory. Compilers and assembly language are used to
turn high-level language programs into a compact machine code for storage in the microcontroller's
memory. Depending on the device, the program memory may be permanent, read-only memory that
can only be programmed at the factory, or program memory may be field-alterable flash or erasable
read-only memory.

Other microcontroller features

Since embedded processors are usually used to control devices, they sometimes need to accept input
from the device they are controlling. This is the purpose of the analog to digital converter. Since
processors are built to interpret and process digital data, i.e. 1s and 0s, they won't be able to do
anything with the analog signals that may be being sent to it by a device. So the analog to digital
converter is used to convert the incoming data into a form that the processor can recognize. There is also
a digital to analog converter that allows the processor to send data to the device it is controlling.

In addition to the converters, many embedded microprocessors include a variety of timers as well.
One of the most common types of timers is the Programmable Interval Timer, or PIT for short. A PIT
just counts down from some value to zero. Once it reaches zero, it sends an interrupt to the processor
indicating that it has finished counting. This is useful for devices such as thermostats, which
periodically test the temperature around them to see if they need to turn the air conditioner on, the
heater on, etc.


www.jntuworld.com
www.jntuworld.com
www.jwjobs.net
Department of ECE Embedded Systems Lab

VRR0HRHRN 0LLE0E 0F EN0lNEERlN0, $HRH$HRBR0 VRR0HRHRN 0LLE0E 0F EN0lNEERlN0, $HRH$HRBR0 VRR0HRHRN 0LLE0E 0F EN0lNEERlN0, $HRH$HRBR0 VRR0HRHRN 0LLE0E 0F EN0lNEERlN0, $HRH$HRBR0
14
Time Processing Unit or TPU for short. Is essentially just another timer, but more sophisticated. In
addition to counting down, the TPU can detect input events, generate output events, and other useful
operations.

Dedicated Pulse Width Modulation (PWM) block makes it possible for the CPU to control power
converters, resistive loads, motors, etc., without using lots of CPU resources in tight timer loops.

Universal Asynchronous Receiver/Transmitter (UART) block makes it possible to receive and transmit
data over a serial line with very little load on the CPU.

For those wanting ethernet one can use an external chip like Crystal Semiconductor CS8900A, Realtek
RTL8019, or Microchip ENC 28J60. All of them allow easy interfacing with low pin count.

Higher integration
In contrast to general-purpose CPUs, microcontrollers may not implement an external address or data bus
as they integrate RAM and non-volatile memory on the same chip as the CPU. Using fewer pins, the chip
can be placed in a much smaller, cheaper package.
Integrating the memory and other peripherals on a single chip and testing them as a unit increases the
cost of that chip, but often results in decreased net cost of the embedded system as a whole. Even if the
cost of a CPU that has integrated peripherals is slightly more than the cost of a CPU + external
peripherals, having fewer chips typically allows a smaller and cheaper circuit board, and reduces the
labor required to assemble and test the circuit board.

A microcontroller is a single integrated circuit, commonly with the following features:

central processing unit - ranging from small and simple 4-bit processors to complex 32- or 64-
bit processors
discrete input and output bits, allowing control or detection of the logic state of an individual
package pin
serial input/output such as serial ports (UARTs)
other serial communications interfaces like IC, Serial Peripheral Interface and Controller Area
Network for system interconnect
peripherals such as timers, event counters, PWM generators, and watchdog
volatile memory (RAM) for data storage
ROM, EPROM, EEPROM or Flash memory for program and operating parameter storage
clock generator - often an oscillator for a quartz timing crystal, resonator or RC circuit
many include analog-to-digital converters
in-circuit programming and debugging support
www.jntuworld.com
www.jntuworld.com
www.jwjobs.net
Department of ECE Embedded Systems Lab

VRR0HRHRN 0LLE0E 0F EN0lNEERlN0, $HRH$HRBR0 VRR0HRHRN 0LLE0E 0F EN0lNEERlN0, $HRH$HRBR0 VRR0HRHRN 0LLE0E 0F EN0lNEERlN0, $HRH$HRBR0 VRR0HRHRN 0LLE0E 0F EN0lNEERlN0, $HRH$HRBR0
15

This integration drastically reduces the number of chips and the amount of wiring and circuit board
space that would be needed to produce equivalent systems using separate chips. Furthermore, and on low
pin count devices in particular, each pin may interface to several internal peripherals, with the pin function
selected by software. This allows a part to be used in a wider variety of applications than if pins had
dedicated functions. Microcontrollers have proved to be highly popular in embedded systems since their
introduction in the 1970s.

Some microcontrollers use a Harvard architecture: separate memory buses for instructions and data,
allowing accesses to take place concurrently. Where a Harvard architecture is used, instruction words for
the processor may be a different bit size than the length of internal memory and registers; for
example: 12-bit instructions used with 8-bit data registers.

The decision of which peripheral to integrate is often difficult. The microcontroller vendors often trade
operating frequencies and system design flexibility against time-to-market requirements from their
customers and overall lower system cost. Manufacturers have to balance the need to minimize the chip
size against additional functionality.

Microcontroller architectures vary widely. Some designs include general-purpose microprocessor
cores, with one or more ROM, RAM, or I/O functions integrated onto the package. Other designs are
purpose built for control applications. A microcontroller instruction set usually has many instructions
intended for bit-wise operations to make control programs more compact. For example, a general
purpose processor might require several instructions to test a bit in a register and branch if the bit is
set, where a microcontroller could have a single instruction that would provide that commonly-
required function.

Microcontrollers typically do not have a math coprocessor, so floating point multiplication and division are
carried out using a standard library, or the faster and more compact Horner method.


Volumes
About 55% of all CPUs sold in the world are 8-bit microcontrollers. According to Semico, Over 4 billion 8-
bit microcontrollers were sold in 2006.
[2]
A typical home in a developed country is likely to have only four general-purpose microprocessors but
around three dozen microcontrollers. A typical mid range automobile has as many as 30 or more
microcontrollers. They can also be found in any electrical device: washing machines, microwave
ovens, telephones etc.

www.jntuworld.com
www.jntuworld.com
www.jwjobs.net
Department of ECE Embedded Systems Lab

VRR0HRHRN 0LLE0E 0F EN0lNEERlN0, $HRH$HRBR0 VRR0HRHRN 0LLE0E 0F EN0lNEERlN0, $HRH$HRBR0 VRR0HRHRN 0LLE0E 0F EN0lNEERlN0, $HRH$HRBR0 VRR0HRHRN 0LLE0E 0F EN0lNEERlN0, $HRH$HRBR0
16
A PIC 18F8720 microcontroller in an 80-pin TQFP package.
Manufacturers have often produced special versions of their
microcontrollers in order to help the hardware and software
development of the target system. Originally these included EPROM
versions that have a "window" on the top of the device through which
program memory can be erased by ultra violet light, ready for
reprogramming after a programming ("burn") and test cycle. Since
1998, EPROM versions are rare and have been replaced by EEPROM
and flash, which are easier to use (can be erased electronically) and
cheaper to manufacture.

Other versions may be available where the ROM is accessed as an external device rather than as
internal memory, however these are becoming increasingly rare due to the widespread availability of
cheap microcontroller programmers.

The use of field-programmable devices on a microcontroller may allow field update of the firmware or
permit late factory revisions to products that have been assembled but not yet shipped.
Programmable memory also reduces the lead time required for deployment of a new product.

Where hundreds of thousands of identical devices are required, using parts programmed at the time of
manufacture can be an economical option. These 'Mask Programmed' parts have the program laid
down in the same way as the logic of the chip, at the same time.

Programming environments

Microcontrollers were originally programmed only in assembly language, but various high-level
programming languages are now also in common use to target microcontrollers. These languages are
either designed specially for the purpose, or versions of general purpose languages such as the C
programming language. Compilers for general purpose languages will typically have some restrictions as
well as enhancements to better support the unique characteristics of microcontrollers. Some
microcontrollers have environments to aid developing certain types of applications. Microcontroller
vendors often make tools freely available to make it easier to adopt their hardware.

Many microcontrollers are so quirky that they effectively require their own non-standard dialects of C,
such as SDCC for the 8051, which prevent using standard tools (such as code libraries or static
analysis tools) even for code unrelated to hardware features. Interpreters are often used to hide such low
level quirks.


www.jntuworld.com
www.jntuworld.com
www.jwjobs.net
Department of ECE Embedded Systems Lab

VRR0HRHRN 0LLE0E 0F EN0lNEERlN0, $HRH$HRBR0 VRR0HRHRN 0LLE0E 0F EN0lNEERlN0, $HRH$HRBR0 VRR0HRHRN 0LLE0E 0F EN0lNEERlN0, $HRH$HRBR0 VRR0HRHRN 0LLE0E 0F EN0lNEERlN0, $HRH$HRBR0
17
Interpreter firmware is also available for some microcontrollers. For example, BASIC on the early
microcontrollers Intel 8052
[3]
; BASIC and FORTH on the Zilog Z8 as well as some modern devices.
Typically these interpreters support interactive programming.

Simulators are available for some microcontrollers, such as in Microchip's MPLAB environment. These
allow a developer to analyse what the behaviour of the microcontroller and their program should be if
they were using the actual part. A simulator will show the internal processor state and also that of the
outputs, as well as allowing input signals to be generated. While on the one hand most simulators will be
limited from being unable to simulate much other hardware in a system, they can exercise
conditions that may otherwise be hard to reproduce at will in the physical implementation, and can be the
quickest way to debug and analyse problems.
Recent microcontrollers are often integrated with on-chip debug circuitry that when accessed by an
Incircuit emulator via JTAG, allow debugging of the firmware with a debugger.
Types of microcontrollers
As of 2008 there are several common architectures:

CF (32-bit)
ARM
MIPS (32-bit PIC32)
S08
AVR
PIC (8-bit PIC16, PIC18, 16-bit dsPIC33 / PIC24)
V850
PowerPC ISE
PSoC (Programmable System-on-Chip)
Others typically are used in very narrow range of applications or are more like processors than
microcontrollers.
Interrupt latency
In contrast to general-purpose computers, microcontrollers used in embedded systems often seek to
minimize interrupt latency over instruction throughput.
When an electronic device causes an interrupt, the intermediate results, the registers, have to be
saved before the software responsible for handling the interrupt can run, and then must be put back
after it is finished. If there are more registers, this saving and restoring process takes more time,
increasing the latency.
Low-latency MCUs generally have relatively few registers in their central processing units, or they
have "shadow registers", a duplicate register set that is only used by the interrupt software.


www.jntuworld.com
www.jntuworld.com
www.jwjobs.net
Department of ECE Embedded Systems Lab

VRR0HRHRN 0LLE0E 0F EN0lNEERlN0, $HRH$HRBR0 VRR0HRHRN 0LLE0E 0F EN0lNEERlN0, $HRH$HRBR0 VRR0HRHRN 0LLE0E 0F EN0lNEERlN0, $HRH$HRBR0 VRR0HRHRN 0LLE0E 0F EN0lNEERlN0, $HRH$HRBR0
18


















XPHtMNTS ON MH & HAL TtM SYSTMS
































www.jntuworld.com
www.jntuworld.com
www.jwjobs.net
Department of ECE Embedded Systems Lab

VRR0HRHRN 0LLE0E 0F EN0lNEERlN0, $HRH$HRBR0 VRR0HRHRN 0LLE0E 0F EN0lNEERlN0, $HRH$HRBR0 VRR0HRHRN 0LLE0E 0F EN0lNEERlN0, $HRH$HRBR0 VRR0HRHRN 0LLE0E 0F EN0lNEERlN0, $HRH$HRBR0
19


Experiment No:-1

SEVEN SEGMENT DISPLAY

Aim: To write a program to activate the seven segment display and to study the working of the display.
Apparatus: The embedded kit which comprises of the microcontroller and different
components, a general purpose computer, Eclipse software to write the program, Flash magic
software to dump the program into the microcontroller.

Theory:
The Light Emitting Diode (LED), finds its place in many applications in this modern electronic
fields. One of them is the Seven Segment Display. Seven-segment displays contains the
arrangement of the LEDs in "Eight (8) fashion, and a Dot (.) with a common electrode, lead
(Anode or Cathode). The purpose of arranging it in that passion is that we can make any
number out of that by switching ON and OFF the particular LED's. Here is the block diagram of the
Seven Segment LED arrangement.

Pin configuration of a seven segment display:
















LED's are basically of two types

Common Cathode (CC)
All the 8 anode legs uses only one cathode, which is common.
Common Anode (CA)
The common leg for all the cathode is of Anode type.
For the discussion purpose, we use CC LED. By just reversing the logical voltages, we can
implement the same for CA LED also.

In a CC LED, all the 8 legs ('a' through 'h') are of anode type and the common cathode will be
connected to the GND of the supply. By energizing any of the legs with +5 Volts will lead to switch the
corresponding segment ON. In the microprocessor binary system, 0Volts will be considered as Binary
0, and 5Volts will be considered as Binary1. Considering these two conditions, we can make an
arrangement as the microcontroller gives OUT the 0s and 1s through its ports, which is connected to
www.jntuworld.com
www.jntuworld.com
www.jwjobs.net
Department of ECE Embedded Systems Lab

VRR0HRHRN 0LLE0E 0F EN0lNEERlN0, $HRH$HRBR0 VRR0HRHRN 0LLE0E 0F EN0lNEERlN0, $HRH$HRBR0 VRR0HRHRN 0LLE0E 0F EN0lNEERlN0, $HRH$HRBR0 VRR0HRHRN 0LLE0E 0F EN0lNEERlN0, $HRH$HRBR0
20
the 8 legs of the LED. Of course, we can control the Port Output; implicitly we can Switch-ON required
legs of the display.
Here we discuss 2 methods of interfacing LED with the Microcontroller Intel 8051/8951.
Using lookup table. This uses 7 output pins of microcontroller
Using 7447 decoder. This method uses 4 output pins of microcontroller


The difference between the two main methods is simple and clear. In both the cases, microcontroller
communicates with external world through its ports. But, in the 1st case, we connect all the 8 pins of the
port directly to the LED and control the voltage through the ports manually to display the desired
number. But, in the second case, we send the BCD of the number that we wanted to display to a
middleware IC 7447, the BCD to LED code converter, which by itself gives out the corresponding 7
segment codes to the LED.






















Circuit diagram for Common Anode 7-Segment Display




















Circuit diagram for Common Cathode 7-Segment Display

www.jntuworld.com
www.jntuworld.com
www.jwjobs.net
Department of ECE Embedded Systems Lab

VRR0HRHRN 0LLE0E 0F EN0lNEERlN0, $HRH$HRBR0 VRR0HRHRN 0LLE0E 0F EN0lNEERlN0, $HRH$HRBR0 VRR0HRHRN 0LLE0E 0F EN0lNEERlN0, $HRH$HRBR0 VRR0HRHRN 0LLE0E 0F EN0lNEERlN0, $HRH$HRBR0
21
Program:

#include <8051.H>

#include<stdio.h>

_xdata __at 0xffc2 unsigned char segmentselPtr; //sevensegment address
__xdata __at 0xffc3 unsigned char swPtr; //sevensegment selection address
unsigned int switch_data;
unsigned int data1[] = {0x3f,0x06,0x5b,0x4F,0x66,0x6D,0x7C,0x07,0x7F,0x6F};
unsigned int k;


void delay()
{
unsigned int i,j;
for(i=0;i<0xff;i++)
for(j=0;j<0xff;j++);
}
void main()
{
while(1)
{
swPtr = 0x20;
for(k=0;k<10;k++)
{
segmentselPtr = data1[k];
delay();
}

swPtr = 0x10;
for(k=0;k<10;k++)
{
segmentselPtr = data1[k];
www.jntuworld.com
www.jntuworld.com
www.jwjobs.net
Department of ECE Embedded Systems Lab

VRR0HRHRN 0LLE0E 0F EN0lNEERlN0, $HRH$HRBR0 VRR0HRHRN 0LLE0E 0F EN0lNEERlN0, $HRH$HRBR0 VRR0HRHRN 0LLE0E 0F EN0lNEERlN0, $HRH$HRBR0 VRR0HRHRN 0LLE0E 0F EN0lNEERlN0, $HRH$HRBR0
22
delay();
}

}

}






Observations:








Conclusions:








Results:






www.jntuworld.com
www.jntuworld.com
www.jwjobs.net
Department of ECE Embedded Systems Lab

VRR0HRHRN 0LLE0E 0F EN0lNEERlN0, $HRH$HRBR0 VRR0HRHRN 0LLE0E 0F EN0lNEERlN0, $HRH$HRBR0 VRR0HRHRN 0LLE0E 0F EN0lNEERlN0, $HRH$HRBR0 VRR0HRHRN 0LLE0E 0F EN0lNEERlN0, $HRH$HRBR0
23
Experiment No :-2
ADC OPERATION
Aim: To write a program to perform the Analog to Digital Conversion using the 89c51
microcontroller and observe the result for different values.
Apparatus: The embedded kit which comprises of the microcontroller and different components, a
general purpose computer, Eclipse software to write the program, Flash magic software to dump the
program into the microcontroller.

Theory:
An analog-to-digital converter (abbreviated ADC, A/D or A to D) is a device which converts
continuous signals to discrete digital numbers. The reverse operation is performed by a
digital-to-analog converter (DAC). Typically, an ADC is an electronic device that converts an
input analog voltage (or current) to a digital number. However, some non-electronic or only
partially electronic devices, such as rotary encoders, can also be considered ADCs. The
digital output may use different coding schemes, such as binary, Gray code or two's
complement binary.

Resolution

The resolution of the converter indicates the number of
discrete values it can produce over the range of analog
values. The values are usually stored electronically in
binary form, so the resolution is usually expressed in bits.
In consequence, the number of discrete values available,
or "levels", is usually a power of two. For example, an ADC
with a resolution of 8 bits can encode an analog input to
one in 256 different levels, since 2
8
= 256. The values can
represent the ranges from 0 to 255 (i.e. unsigned integer)
or from -128 to 127 (i.e. signed integer), depending on the
application.

Sampling rate

The analog signal is continuous in time and it is necessary to convert this to a flow of digital values. It is
therefore required to define the rate at which new digital values are sampled from the analog signal. The
rate of new values is called the sampling rate or sampling frequency of the converter. Since a practical
ADC cannot make an instantaneous conversion, the input value must necessarily be held constant
during the time that the converter performs a conversion (called the conversion time). An input circuit
called a sample and hold performs this task-in most cases by using a capacitor to store the analogue
voltage at the input, and using an electronic switch or gate to disconnect the capacitor from the input.
Many ADC integrated circuits include the sample and hold subsystem internally.

Aliasing

All ADCs work by sampling their input at discrete intervals of time. Their output is therefore an
incomplete picture of the behaviour of the input. There is no way of knowing, by looking at the output,
what the input was doing between one sampling instant and the next. If the input is known to be
changing slowly compared to the sampling rate, then it can be assumed that the value of the signal
between two sample instants was somewhere between the two sampled values. If, however, the input
signal is changing fast compared to the sample rate, then this assumption is not valid. If the digital
values produced by the ADC are, at some later stage in the system, converted back to analog values by a
www.jntuworld.com
www.jntuworld.com
www.jwjobs.net
Department of ECE Embedded Systems Lab

VRR0HRHRN 0LLE0E 0F EN0lNEERlN0, $HRH$HRBR0 VRR0HRHRN 0LLE0E 0F EN0lNEERlN0, $HRH$HRBR0 VRR0HRHRN 0LLE0E 0F EN0lNEERlN0, $HRH$HRBR0 VRR0HRHRN 0LLE0E 0F EN0lNEERlN0, $HRH$HRBR0
24
digital to analog converter or DAC, it is desirable that the output of the DAC be a faithful
representation of the original signal. If the input signal is changing much faster than the sample rate,
then this will not be the case, and spurious signals called aliases will be produced at the output of the
DAC. The frequency of the aliased signal is the difference between the signal frequency and the
sampling rate. For example, a 2 kHz sinewave being sampled at 1.5 kHz would be reconstructed as a 500
Hz sinewave. This problem is called aliasing. To avoid aliasing, the input to an ADC must be low-
pass filtered to remove frequencies above half the sampling rate. This filter is called an anti-aliasing
filter, and is essential for a practical ADC system that is applied to analog signals with higher
frequency content. Although aliasing in most systems is unwanted, it should also be noted that it can
be exploited to provide simultaneous down-mixing of a band-limited high
frequency mixer).

Program:

#include<8051.h>

#include<stdio.h>

#include<serial_IO.h>

#define HIGH 01;

#define LOW 00;

__idata unsigned char dat;

__idata unsigned char i;

__bit __at(0x94) SCLK;

__bit __at(0x95) SDA;

bit ACK;

void I2C_Start(void);

void I2C_Stop(void);

void I2C_Write(unsigned char j);

unsigned char I2C_Read(void);

void Delay_Time();

void serial() //uart baud rate set to 9600

{

TMOD = 0x20;

TH1 = 0xfd;

TL1 = 0x00;


VARDHAMAN COLLEGE OF ENGINEERING, SHAMSHABAD, HYDERABAD
frequency signal (see
www.jntuworld.com
www.jntuworld.com
www.jwjobs.net
Department of ECE Embedded Systems Lab

VRR0HRHRN 0LLE0E 0F EN0lNEERlN0, $HRH$HRBR0 VRR0HRHRN 0LLE0E 0F EN0lNEERlN0, $HRH$HRBR0 VRR0HRHRN 0LLE0E 0F EN0lNEERlN0, $HRH$HRBR0 VRR0HRHRN 0LLE0E 0F EN0lNEERlN0, $HRH$HRBR0
25


TCON = 0x40;

SCON = 0x50;

}



void I2C_Start(void)

{

SCLK=LOW;

SDA=LOW;

Delay_Time();

SCLK = HIGH;

Delay_Time();

SDA=HIGH;

Delay_Time();

SDA = LOW;

Delay_Time();

SCLK = LOW;

}



void I2C_Stop(void)

{

SCLK = LOW;

Delay_Time();

SDA = HIGH;

}













//Start I2C by creating clock by setting and clearing the port pins





























//Stop I2C operation by clearing the SCLK Pin

void I2C_Write(unsigned char j) // shifting data bit by bit to MSB and moving through i2c
{
dat=j;
www.jntuworld.com
www.jntuworld.com
www.jwjobs.net
Department of ECE Embedded Systems Lab

VRR0HRHRN 0LLE0E 0F EN0lNEERlN0, $HRH$HRBR0 VRR0HRHRN 0LLE0E 0F EN0lNEERlN0, $HRH$HRBR0 VRR0HRHRN 0LLE0E 0F EN0lNEERlN0, $HRH$HRBR0 VRR0HRHRN 0LLE0E 0F EN0lNEERlN0, $HRH$HRBR0
26


for(i=0;i<8;i++)



{

SDA = dat & 0x80;

dat=dat<<1;

SCLK = HIGH;

Delay_Time();

SCLK = LOW;

}



SDA=HIGH;

Delay_Time();

SCLK = HIGH;

Delay_Time();

ACK = SDA;

Delay_Time();

SCLK = LOW;

}



unsigned char I2C_Read(void) //reading from i2c device bit by bit

{

unsigned char i,j;

j = 0;

i = SDA;

for(i=0;i<8;i++)

{

j<<=1;

SCLK = HIGH;
www.jntuworld.com
www.jntuworld.com
www.jwjobs.net
Department of ECE Embedded Systems Lab

VRR0HRHRN 0LLE0E 0F EN0lNEERlN0, $HRH$HRBR0 VRR0HRHRN 0LLE0E 0F EN0lNEERlN0, $HRH$HRBR0 VRR0HRHRN 0LLE0E 0F EN0lNEERlN0, $HRH$HRBR0 VRR0HRHRN 0LLE0E 0F EN0lNEERlN0, $HRH$HRBR0
27

j |= SDA;
Delay_Time();
SCLK = LOW;
}
Delay_Time();
SDA = LOW;
Delay_Time();
SCLK = HIGH;
Delay_Time();
SCLK = LOW;
Delay_Time();
SDA = HIGH;
return j;
}

void main()
{
int data1;
int i=0x24;



I2C_Start();

I2C_Write(0x9E); //send device address

I2C_Write(0x40);

I2C_Start();

I2C_Write(0x9f);



while(1)

{

//send device's control register address


www.jntuworld.com
www.jntuworld.com
www.jwjobs.net
Department of ECE Embedded Systems Lab

VRR0HRHRN 0LLE0E 0F EN0lNEERlN0, $HRH$HRBR0 VRR0HRHRN 0LLE0E 0F EN0lNEERlN0, $HRH$HRBR0 VRR0HRHRN 0LLE0E 0F EN0lNEERlN0, $HRH$HRBR0 VRR0HRHRN 0LLE0E 0F EN0lNEERlN0, $HRH$HRBR0
28

// send command for read


data1=I2C_Read();
serial();
SBUF=' ';
printf("\n\rADC Value is: %x",data1);
Delay_Time();
}

}

void Delay_Time()
{
unsigned int i;
for(i=0;i<=5000;i++);
}



Observation:






Conclusion:








Result:





www.jntuworld.com
www.jntuworld.com
www.jwjobs.net
Department of ECE Embedded Systems Lab

VRR0HRHRN 0LLE0E 0F EN0lNEERlN0, $HRH$HRBR0 VRR0HRHRN 0LLE0E 0F EN0lNEERlN0, $HRH$HRBR0 VRR0HRHRN 0LLE0E 0F EN0lNEERlN0, $HRH$HRBR0 VRR0HRHRN 0LLE0E 0F EN0lNEERlN0, $HRH$HRBR0
29
Experiment No :-3

BLINKING THE LED'S



Aim: To write a program to blink the LEDs using 89c51 microcontroller and to display the results.
Apparatus: The embedded kit which comprises of the microcontroller and different components, a
general purpose computer, Eclipse software to write the program, Flash magic software to dump the
program into the microcontroller.

Theory:
A light-emitting-diode (LED) is a semiconductor diode that emits light when an electric current is
applied in the forward direction of the device, as in the simple LED circuit. The effect is a form of
electroluminescence where incoherent and narrow-spectrum light is emitted from the p-n junction in a
solid state material.

LEDs are widely used as indicator lights on electronic devices and increasingly in higher power
applications such as flashlights and area lighting. An LED is usually a small area (less than 1 mm2) light
source, often with optics added directly on top of the chip to shape its radiation pattern and assist in
reflection. The color of the emitted light depends on the composition and condition of the
semiconducting material used, and can be infrared, visible, or ultraviolet. Besides lighting, interesting
applications include using UV-LEDs for sterilization of water and disinfection of devices, and as a grow
light to enhance photosynthesis in plants.

Here we are interfacing the LEDs to the microcontroller and then we are writing a program which can
make the LEDs link in different sequential formats. The LEDs are interfaced to the appropriate pins of
the microcontroller and then the program is written according to the pin connections made and
then the output is observed for different sequences.

Program:

//LED//

#include<8051.h>

__xdata __at (0xffc0) unsigned int ledptr;
unsigned char array[]={0x01,0x02,0x04,0x08,0x10,0x20,0x40,0x80,0xff};
void delay()
{

int i,j;

for(i=0;i<0x0fff;i++);

for(j=0;j<0x0ffff;j++);

}


www.jntuworld.com
www.jntuworld.com
www.jwjobs.net
Department of ECE Embedded Systems Lab

VRR0HRHRN 0LLE0E 0F EN0lNEERlN0, $HRH$HRBR0 VRR0HRHRN 0LLE0E 0F EN0lNEERlN0, $HRH$HRBR0 VRR0HRHRN 0LLE0E 0F EN0lNEERlN0, $HRH$HRBR0 VRR0HRHRN 0LLE0E 0F EN0lNEERlN0, $HRH$HRBR0
30




void main()
{
unsigned int i;



while(1)

{
for(i=0;i<=8;i++)
{
ledptr=array[i];
delay();
}
}
}



Observations:







Conclusions:









Results:






www.jntuworld.com
www.jntuworld.com
www.jwjobs.net
Department of ECE Embedded Systems Lab

VRR0HRHRN 0LLE0E 0F EN0lNEERlN0, $HRH$HRBR0 VRR0HRHRN 0LLE0E 0F EN0lNEERlN0, $HRH$HRBR0 VRR0HRHRN 0LLE0E 0F EN0lNEERlN0, $HRH$HRBR0 VRR0HRHRN 0LLE0E 0F EN0lNEERlN0, $HRH$HRBR0
31
Experiment No:-4
DAC OPERATION
Aim: To write a program to perform Digital to Analog conversion using 89c51 microcontroller.
Apparatus: The embedded kit which comprises of the microcontroller and different components, a
general purpose computer, Eclipse software to write the program, Flash magic software to dump the
program into the microcontroller.

Theory:

In electronics, a digital-to-analog converter (DAC or D-to-A) is a device for converting a digital
(usually binary) code to an analog signal (current, voltage or electric charge). An analog-to-digital
converter (ADC) performs the reverse operation.

Basic ideal operation
Ideally sampled signal. Signal of a typical interpolating DAC outputThe DAC fundamentally converts
finite-precision numbers (usually fixed-point binary numbers) into a continuously varying physical
quantity, usually an analogue electrical voltage.
In an ideal DAC, the numbers are output as a sequence of impulses, that are then filtered by a
reconstruction filter. This would, in principle, reproduce a sampled signal precisely up to the Nyquist
frequency, although a perfect reconstruction filter cannot be practically constructed as it has infinite
phase delay; and there are errors due to quantization.

Practical operation

Instead of impulses, usually the sequence of numbers update the analogue voltage at uniform
sampling intervals.

These numbers are written to the DAC, typically with a clock signal that causes each number to be
latched in sequence, at which time the DAC output voltage changes rapidly from the previous value to the
value represented by the currently latched number. The effect of this is that the output voltage is held in
time at the current value until the next input number is latched resulting in a piecewise constant or
'staircase' shaped output. This is equivalent to a zero-order hold operation and has an effect on the
frequency response of the reconstructed signal.

Piecewise constant signal typical of a zero-order (non-interpolating) DAC output.

The fact that practical DACs output a sequence of piecewise constant values or rectangular pulses
would cause multiple harmonics above the nyquist frequency. These are typically removed with a low
pass filter acting as a reconstruction filter.

However, this filter means that there is an inherent effect of the zero-order hold on the effective
frequency response of the DAC resulting in a mild roll-off of gain at the higher frequencies (often a
3.9224 dB loss at the Nyquist frequency) and depending on the filter, phase distortion. This
highfrequency roll-off is the output characteristic of the DAC, and is not an inherent property of the
sampled data.




www.jntuworld.com
www.jntuworld.com
www.jwjobs.net
Department of ECE Embedded Systems Lab

VRR0HRHRN 0LLE0E 0F EN0lNEERlN0, $HRH$HRBR0 VRR0HRHRN 0LLE0E 0F EN0lNEERlN0, $HRH$HRBR0 VRR0HRHRN 0LLE0E 0F EN0lNEERlN0, $HRH$HRBR0 VRR0HRHRN 0LLE0E 0F EN0lNEERlN0, $HRH$HRBR0
32

Here the connections are made to the microcontroller with the Digital to Analog converter and the
program is written and dumped and then for different inputs the outputs are observed.

Program:
#include<8051.h>
#define HIGH 01;
#define LOW 00;
__xdata __at 0xffc5 unsigned char swt;
__xdata __at 0xffc0 unsigned char led;
__idata unsigned char dat;
__idata unsigned char i;
__bit __at(0x94) SCLK;
__bit __at(0x95) SDA;
bit ACK;
void I2C_Start(void);
void I2C_Stop(void);
void I2C_Write(unsigned char j);
unsigned char I2C_Read(void);
void Delay_Time();

void I2C_Start(void) //Start I2C by creating clock by setting and clearing the port pins

{
SCLK=LOW;
SDA=LOW;
Delay_Time();
SCLK = HIGH;
Delay_Time();
SDA=HIGH;
Delay_Time();
SDA = LOW;
Delay_Time();
SCLK = LOW;
www.jntuworld.com
www.jntuworld.com
www.jwjobs.net
Department of ECE Embedded Systems Lab

VRR0HRHRN 0LLE0E 0F EN0lNEERlN0, $HRH$HRBR0 VRR0HRHRN 0LLE0E 0F EN0lNEERlN0, $HRH$HRBR0 VRR0HRHRN 0LLE0E 0F EN0lNEERlN0, $HRH$HRBR0 VRR0HRHRN 0LLE0E 0F EN0lNEERlN0, $HRH$HRBR0
33

}

void I2C_Stop(void) //Stop I2C operation by clearing the SCLK Pin

{
SCLK = LOW;
Delay_Time();
SDA = HIGH;
}
void I2C_Write(unsigned char j) // shifting data bit by bit to MSB and moving through i2c
{
dat=j;

for(i=0;i<8;i++)



{
SDA = dat & 0x80;
dat=dat<<1;
SCLK = HIGH;
Delay_Time();
SCLK = LOW;
}
SDA=HIGH;
Delay_Time();
SCLK = HIGH;
Delay_Time();
ACK = SDA;
Delay_Time();
SCLK = LOW;
}

SDA = HIGH;
Delay_Time();
SCLK = HIGH;
Delay_Time();
www.jntuworld.com
www.jntuworld.com
www.jwjobs.net
Department of ECE Embedded Systems Lab

VRR0HRHRN 0LLE0E 0F EN0lNEERlN0, $HRH$HRBR0 VRR0HRHRN 0LLE0E 0F EN0lNEERlN0, $HRH$HRBR0 VRR0HRHRN 0LLE0E 0F EN0lNEERlN0, $HRH$HRBR0 VRR0HRHRN 0LLE0E 0F EN0lNEERlN0, $HRH$HRBR0
34
ACK = SDA;

Delay_Time();
SCLK = LOW;
}
unsigned char I2C_Read(void) //reading from i2c device bit by bit
{

unsigned char i,j;

j = 0;

i = SDA;

for(i=0;i<8;i++)

{

j<<=1;

SCLK = HIGH;

j |= SDA;

Delay_Time();

SCLK = LOW;

}

Delay_Time();

SDA = LOW;

Delay_Time();

SCLK = HIGH;

Delay_Time();

SCLK = LOW;

Delay_Time();

SDA = HIGH;

return j;

}

void main()

www.jntuworld.com
www.jntuworld.com
www.jwjobs.net
Department of ECE Embedded Systems Lab

VRR0HRHRN 0LLE0E 0F EN0lNEERlN0, $HRH$HRBR0 VRR0HRHRN 0LLE0E 0F EN0lNEERlN0, $HRH$HRBR0 VRR0HRHRN 0LLE0E 0F EN0lNEERlN0, $HRH$HRBR0 VRR0HRHRN 0LLE0E 0F EN0lNEERlN0, $HRH$HRBR0
35
{

unsigned int i=0xff;

I2C_Start();

I2C_Write(0x9E); //send device address

I2C_Write(0x40); //send device's control register address

I2C_Start();

I2C_Write(0x9E); // send command for read

while(1)

{

I2C_Write(i);
if((swt & 0x1f)== 0x1E)
{
i=i-1;
Delay_Time();
led = i;
}

}

}
void Delay_Time()
{
unsigned int i;
for(i=0;i<=2500;i++);
}
Observations:





Conclusions:





Results:

www.jntuworld.com
www.jntuworld.com
www.jwjobs.net
Department of ECE Embedded Systems Lab

VRR0HRHRN 0LLE0E 0F EN0lNEERlN0, $HRH$HRBR0 VRR0HRHRN 0LLE0E 0F EN0lNEERlN0, $HRH$HRBR0 VRR0HRHRN 0LLE0E 0F EN0lNEERlN0, $HRH$HRBR0 VRR0HRHRN 0LLE0E 0F EN0lNEERlN0, $HRH$HRBR0
36
Experiment No:-5
ELEVATOR CONTROLLER


Aim: To write a program to implement the operation of an elevator using the 89c51 microcontroller.
Apparatus: The embedded kit which comprises of the microcontroller and different components, a
general purpose computer, Eclipse software to write the program, Flash magic software to dump the
program into the microcontroller.
Theory: Here in the elevator implementation using the microcontroller the elevator dummy
prototype is connected to the microcontroller and then the program is written so that when a number
is given as input then the elevator will go to the number and stop. but in our program instead of an
elevator switch a rotator is used where we can set the number where the elevator has to move and the
output is observed on the led display concluding that the elevator program has been
implemented successfully.

Program:
//floor selection--thumbwheel, up,down--sw10, elevator led's are used for lift movement
#include<8051.h>
#include<stdio.h>
#include<string.h>
__xdata __at 0xffc6 char ledptr; //elevator led location
__xdata __at 0xffcc char wheel; //elevator thumb wheel location
__xdata __at 0xffc5 char swt; //elevator switch location
unsigned int k,m,j;
void delay()

{

unsigned int i,j,m;

for(m=0;m<0x04;m++)

for(i=0;i<0xff;i++)

for(j=0;j<0xff;j++);

}

void main()

www.jntuworld.com
www.jntuworld.com
www.jwjobs.net
Department of ECE Embedded Systems Lab

VRR0HRHRN 0LLE0E 0F EN0lNEERlN0, $HRH$HRBR0 VRR0HRHRN 0LLE0E 0F EN0lNEERlN0, $HRH$HRBR0 VRR0HRHRN 0LLE0E 0F EN0lNEERlN0, $HRH$HRBR0 VRR0HRHRN 0LLE0E 0F EN0lNEERlN0, $HRH$HRBR0
37




{
char floor[6] = {0x01,0x02,0x04,0x08,0x10};
char ref[6] = {0x1e,0x1d,0x1b,0x17,0x0f};

int cur = 0;
ledptr = 0x02;
while(1)
{

k = (swt & 0x1f);
if(k >0x0E && k < 0x1F)
{
if(ref[cur] < k)
{
while(ref[cur] != k)
{
cur = cur - 1;
ledptr = floor[cur];
delay();
}

}
else if(ref[cur] > k)
{
while(ref[cur] != k)
{
cur = cur + 1;
ledptr = floor[cur];
delay();
}

}
www.jntuworld.com
www.jntuworld.com
www.jwjobs.net
Department of ECE Embedded Systems Lab

VRR0HRHRN 0LLE0E 0F EN0lNEERlN0, $HRH$HRBR0 VRR0HRHRN 0LLE0E 0F EN0lNEERlN0, $HRH$HRBR0 VRR0HRHRN 0LLE0E 0F EN0lNEERlN0, $HRH$HRBR0 VRR0HRHRN 0LLE0E 0F EN0lNEERlN0, $HRH$HRBR0
38









}

}

}



Observations:





Conclusions:





Results:





























www.jntuworld.com
www.jntuworld.com
www.jwjobs.net
Department of ECE Embedded Systems Lab

VRR0HRHRN 0LLE0E 0F EN0lNEERlN0, $HRH$HRBR0 VRR0HRHRN 0LLE0E 0F EN0lNEERlN0, $HRH$HRBR0 VRR0HRHRN 0LLE0E 0F EN0lNEERlN0, $HRH$HRBR0 VRR0HRHRN 0LLE0E 0F EN0lNEERlN0, $HRH$HRBR0
39


Experiment No:-6

ENCRYPTION AND DECRYPTION OPERATIONS


Aim: To study the encryption and decryption capabilities of 89c51microcontroller.
Apparatus: The embedded kit which comprises of the microcontroller and different components, a
general purpose computer, Eclipse software to write the program, Flash magic software to dump the
program into the microcontroller.

Theory:
Here in encryption and decryption program we are trying to study the encryption and decryption
characteristics of the microcontroller. By taking a reference code word we encrypt and decrypt the
code word and display them. The whole process can be written as a program and is dumped into the
microcontroller. Hence by this study of the process the encryption and the decryption characteristics of
a microcontroller are studied.

Program:
//ENCRYPTION & DECRYPTION//
#include <8051.H>
#include<stdio.h>
#include<serial_io.h>
#include<string.h>



void serial();
void encrypt();
void tx();
void delay();
void rx();
void arr();
void arr1();
unsigned char b[5]={0x38,0x01,0x06,0x0c,0x80};
unsigned char b1[]={"VIMICRO"};
unsigned char b2[7];


www.jntuworld.com
www.jntuworld.com
www.jwjobs.net
Department of ECE Embedded Systems Lab

VRR0HRHRN 0LLE0E 0F EN0lNEERlN0, $HRH$HRBR0 VRR0HRHRN 0LLE0E 0F EN0lNEERlN0, $HRH$HRBR0 VRR0HRHRN 0LLE0E 0F EN0lNEERlN0, $HRH$HRBR0 VRR0HRHRN 0LLE0E 0F EN0lNEERlN0, $HRH$HRBR0
40

unsigned char b3[8];
int k,m,n;
unsigned char a[50];
unsigned int i,l,cnt=0;
unsigned char key;
void main()
{
serial();
while(1)
{
rx();
printf("\n \t ENTER THE PASSWORD:\t ");
arr();
if(strcmp (b1,b2)==0)
{
tx();

delay();

return;

}

else

printf("\n \r YOU ARE UNAUTHORISED PERSON ");

}

}

void serial()
{
TMOD = 0X20;
TH1 = 0XFD;

www.jntuworld.com
www.jntuworld.com
www.jwjobs.net
Department of ECE Embedded Systems Lab

VRR0HRHRN 0LLE0E 0F EN0lNEERlN0, $HRH$HRBR0 VRR0HRHRN 0LLE0E 0F EN0lNEERlN0, $HRH$HRBR0 VRR0HRHRN 0LLE0E 0F EN0lNEERlN0, $HRH$HRBR0 VRR0HRHRN 0LLE0E 0F EN0lNEERlN0, $HRH$HRBR0
41

TI = 1;

TR1 = 1;

SCON = 0X52;

//PCON = 0x80;

}



void rx()

{
printf("\n\r----------------------------------------------------------------");
printf("\n\r ENCRYPTION ");
printf("\n\r----------------------------------------------------------------\n\r");
printf("\n \t ENCRYPTED DATA: \t");



for(i=0;i<50;i++)

{
while(RI!=1);
RI=0;
a[i]=SBUF;
if(a[i]==0x0d)
break;
SBUF=SBUF+0x30;
cnt++;
}
return;
}

void tx()
{


www.jntuworld.com
www.jntuworld.com
www.jwjobs.net
Department of ECE Embedded Systems Lab

VRR0HRHRN 0LLE0E 0F EN0lNEERlN0, $HRH$HRBR0 VRR0HRHRN 0LLE0E 0F EN0lNEERlN0, $HRH$HRBR0 VRR0HRHRN 0LLE0E 0F EN0lNEERlN0, $HRH$HRBR0 VRR0HRHRN 0LLE0E 0F EN0lNEERlN0, $HRH$HRBR0
42


printf("\n\r----------------------------------------------------------------");

printf("\n\r DECRYPTION ");
printf("\n\r----------------------------------------------------------------\n");
printf("\n DECRYPTED DATA: \t");
for(i=0;i<=50;i++)

{
SBUF=SBUF-0x30;
SBUF=a[i];
while(TI!=1);
TI=0;
}
cnt=0;
return;
}

void delay()
{
unsigned int m;

for(m=0;m<0x0f;m++);

}

void arr()
{
unsigned char i;
for(i=0;i<=6;i++)
{
while(RI==0);
b2[i]=SBUF;

www.jntuworld.com
www.jntuworld.com
www.jwjobs.net
Department of ECE Embedded Systems Lab

VRR0HRHRN 0LLE0E 0F EN0lNEERlN0, $HRH$HRBR0 VRR0HRHRN 0LLE0E 0F EN0lNEERlN0, $HRH$HRBR0 VRR0HRHRN 0LLE0E 0F EN0lNEERlN0, $HRH$HRBR0 VRR0HRHRN 0LLE0E 0F EN0lNEERlN0, $HRH$HRBR0
43

SBUF=0x2a;

while(TI==0);

TI=0;

RI=0;

}

b2[i]='\0';

}



Observations:





Conclusions:





Results:



























www.jntuworld.com
www.jntuworld.com
www.jwjobs.net
Department of ECE Embedded Systems Lab

VRR0HRHRN 0LLE0E 0F EN0lNEERlN0, $HRH$HRBR0 VRR0HRHRN 0LLE0E 0F EN0lNEERlN0, $HRH$HRBR0 VRR0HRHRN 0LLE0E 0F EN0lNEERlN0, $HRH$HRBR0 VRR0HRHRN 0LLE0E 0F EN0lNEERlN0, $HRH$HRBR0
44

Experiment No:-7
LCD CONTROL


Aim: To write a program to control the LCD Display using 89c51 microcontroller.
Apparatus: The embedded kit which comprises of the microcontroller and different components, a
general purpose computer, Eclipse software to write the program, Flash magic software to dump the
program into the microcontroller.

Theory:

A liquid crystal display (LCD) is an electronically modulated optical amplification shaped into a thin, flat
display device made up of any number of color or monochrome pixels arrayed in front of a light source
(backlight) or reflector. It is often utilized in battery-powered electronic devices because it uses very small
amounts of electric power.

A comprehensive classification of the various types and electro-optical modes of LCDs is provided in the
article LCD classification.

Each pixel of an LCD typically consists of a layer of molecules aligned between two transparent
electrodes, and two polarizing filters, the axes of transmission of which are (in most of the cases)
perpendicular to each other. With no actual liquid crystal between the polarizing filters, light passing
through the first filter would be blocked by the second (crossed) polarizer.

The surface of the electrodes that are in contact with the liquid crystal material are treated so as to
align the liquid crystal molecules in a particular direction. This treatment typically consists of a thin
polymer layer that is unidirectionally rubbed using, for example, a cloth. The direction of the liquid
crystal alignment is then defined by the direction of rubbing. Electrodes are made of a transparent
conductor called Indium Tin Oxide (ITO).

Before applying an electric field, the orientation of the liquid crystal molecules is determined by the
alignment at the surfaces. In a twisted nematic device (still the most common liquid crystal device),
the surface alignment directions at the two electrodes are perpendicular to each other, and so the
molecules arrange themselves in a helical structure, or twist. Because the liquid crystal material is
birefringent, light passing through one polarizing filter is rotated by the liquid crystal helix as it passes
through the liquid crystal layer, allowing it to pass through the second polarized filter. Half of the
incident light is absorbed by the first polarizing filter, but otherwise the entire assembly is reasonably
transparent

When a voltage is applied across the electrodes, a torque acts to align the liquid crystal molecules
parallel to the electric field, distorting the helical structure (this is resisted by elastic forces since the
molecules are constrained at the surfaces). This reduces the rotation of the polarization of the incident
light, and the device appears grey. If the applied voltage is large enough, the liquid crystal molecules in
the center of the layer are almost completely untwisted and the polarization of the incident light is not
rotated as it passes through the liquid crystal layer. This light will then be mainly polarized
perpendicular to the second filter, and thus be blocked and the pixel will appear black. By controlling the
voltage applied across the liquid crystal layer in each pixel, light can be allowed to pass through in varying
amounts thus constituting different levels of gray.


www.jntuworld.com
www.jntuworld.com
www.jwjobs.net
Department of ECE Embedded Systems Lab

VRR0HRHRN 0LLE0E 0F EN0lNEERlN0, $HRH$HRBR0 VRR0HRHRN 0LLE0E 0F EN0lNEERlN0, $HRH$HRBR0 VRR0HRHRN 0LLE0E 0F EN0lNEERlN0, $HRH$HRBR0 VRR0HRHRN 0LLE0E 0F EN0lNEERlN0, $HRH$HRBR0
45



Here the microcontroller is interfaced to the LCD and the controlling characteristics of the LCD are
studied.

Program:

#include <8051.H>
__xdata __at 0xffc3 unsigned char sel174;
__xdata __at 0xffc4 unsigned char lcdsel;
unsigned char i;
void lcd_write(unsigned char *temp,int cnt);
void delay()
{

int i,j;
for(i=0;i<0xff;i++)
for(j=0;j<0xff;j++);
}
void busycheck()
{
delay();
sel174 = 0x00;
}
void main()
{
while(1)
{



busycheck();

lcdsel = 0x38; // Configure Interface length, No of display lines

busycheck();

lcdsel = 0x06; // Shift Cursor Position


www.jntuworld.com
www.jntuworld.com
www.jwjobs.net
Department of ECE Embedded Systems Lab

VRR0HRHRN 0LLE0E 0F EN0lNEERlN0, $HRH$HRBR0 VRR0HRHRN 0LLE0E 0F EN0lNEERlN0, $HRH$HRBR0 VRR0HRHRN 0LLE0E 0F EN0lNEERlN0, $HRH$HRBR0 VRR0HRHRN 0LLE0E 0F EN0lNEERlN0, $HRH$HRBR0
46



busycheck();

lcdsel = 0x01; // Clear LCD

busycheck();

lcdsel = 0x0f; // Turn On display,cursor and cursor blink

busycheck();

lcdsel = 0x80; // Starting location in first line

lcd_write("Vi Microsystems",15);

busycheck();

lcdsel = 0xC0; // Starting location in second line

lcd_write("RTOS-51 Board",13);

}

}



void lcd_write(unsigned char *temp,int cnt)

{

int i;

for(i=0;i<cnt;i++)

{

busycheck();

sel174=0x01;

lcdsel= *temp;

temp++;

}

}
www.jntuworld.com
www.jntuworld.com
www.jwjobs.net
Department of ECE Embedded Systems Lab

VRR0HRHRN 0LLE0E 0F EN0lNEERlN0, $HRH$HRBR0 VRR0HRHRN 0LLE0E 0F EN0lNEERlN0, $HRH$HRBR0 VRR0HRHRN 0LLE0E 0F EN0lNEERlN0, $HRH$HRBR0 VRR0HRHRN 0LLE0E 0F EN0lNEERlN0, $HRH$HRBR0
47
















Observations:





Conclusions:







Results:


























www.jntuworld.com
www.jntuworld.com
www.jwjobs.net
Department of ECE Embedded Systems Lab

VRR0HRHRN 0LLE0E 0F EN0lNEERlN0, $HRH$HRBR0 VRR0HRHRN 0LLE0E 0F EN0lNEERlN0, $HRH$HRBR0 VRR0HRHRN 0LLE0E 0F EN0lNEERlN0, $HRH$HRBR0 VRR0HRHRN 0LLE0E 0F EN0lNEERlN0, $HRH$HRBR0
48
Experiment No:-8
SENSOR CONTROL

Aim: To write a program to read data from the sensor and to process using 89c51 microcontroller.
Apparatus: The embedded kit which comprises of the microcontroller and different components, a
general purpose computer, Eclipse software to write the program, Flash magic software to dump the
program into the microcontroller.

Theory:

A sensor is a device that measures a physical quantity and converts it into a signal which can be read by
an observer or by an instrument. For example, a mercury thermometer converts the measured
temperature into expansion and contraction of a liquid which can be read on a calibrated glass tube. A
thermocouple converts temperature to an output voltage which can be read by a voltmeter. For
accuracy, all sensors need to be calibrated against known standards.

Sensors are used in everyday objects such as touch-sensitive elevator buttons and lamps which dim or
brighten by touching the base. There are also innumerable applications for sensors of which most
people are never aware. Applications include cars, machines, aerospace, medicine, manufacturing and
robotics.

A sensor's sensitivity indicates how much the sensor's output changes when the measured quantity
changes. For instance, if the mercury in a thermometer moves 1 cm when the temperature changes
by 1 C, the sensitivity is 1 cm/C. Sensors that measure very small changes must have very high
sensitivities.

Technological progress allows more and more sensors to be manufactured on a microscopic scale as
micro sensors using MEMS technology. In most cases, a micro sensor reaches a significantly higher
speed and sensitivity compared with macroscopic approaches. See also MEMS sensor generations.

In this program the microcontroller is interfaced to the sensor and the sensor control capabilities of
the microcontroller are studied and the the sensor detection capabilities for different materials is
tested.

Program:

#include "8051.h"
/*--------------------------------------------*/
__xdata __at 0xffc5 unsigned char ledr;
__xdata __at 0xffc3 unsigned char sel174;
__xdata __at 0xffc4 unsigned char lcdsel;



unsigned int s;

www.jntuworld.com
www.jntuworld.com
www.jwjobs.net
Department of ECE Embedded Systems Lab

VRR0HRHRN 0LLE0E 0F EN0lNEERlN0, $HRH$HRBR0 VRR0HRHRN 0LLE0E 0F EN0lNEERlN0, $HRH$HRBR0 VRR0HRHRN 0LLE0E 0F EN0lNEERlN0, $HRH$HRBR0 VRR0HRHRN 0LLE0E 0F EN0lNEERlN0, $HRH$HRBR0
49


/*--------------------------------------------*/
void delay()
{

int i,j;
for(i=0;i<0x3f;i++)
for(j=0;j<0xff;j++);
}
/*-------------------------------------------*/
void busycheck()
{

delay();
sel174 = 0x00;
}
/*--------------------------------------------*/
void lcd_write(unsigned char *temp,int cnt)
{
int i;
for(i=0;i<cnt;i++)
{
busycheck();
sel174=0x01;
lcdsel= *temp;
temp++;
}

}
/*-------------------------------------------*/
void main()
{

www.jntuworld.com
www.jntuworld.com
www.jwjobs.net
Department of ECE Embedded Systems Lab

VRR0HRHRN 0LLE0E 0F EN0lNEERlN0, $HRH$HRBR0 VRR0HRHRN 0LLE0E 0F EN0lNEERlN0, $HRH$HRBR0 VRR0HRHRN 0LLE0E 0F EN0lNEERlN0, $HRH$HRBR0 VRR0HRHRN 0LLE0E 0F EN0lNEERlN0, $HRH$HRBR0
50


busycheck();

lcdsel = 0x38; // Configure Interface length, No of display lines

busycheck();

lcdsel = 0x06; // Shift Cursor Position

busycheck();

lcdsel = 0x01; // Clear LCD

busycheck();

lcdsel = 0x0f; // Turn On display,cursor and cursor blink
busycheck();
lcdsel = 0x80;
while(1)
{

s=ledr;
s = ((s&0x20)>>0x05);
if(s==0)
{
lcd_write("No Object",9);
busycheck();

lcdsel = 0x01;

}

if(s==1)

{
lcd_write("Object Present",14);
busycheck();
lcdsel = 0x01;
}

}

}


www.jntuworld.com
www.jntuworld.com
www.jwjobs.net
Department of ECE Embedded Systems Lab

VRR0HRHRN 0LLE0E 0F EN0lNEERlN0, $HRH$HRBR0 VRR0HRHRN 0LLE0E 0F EN0lNEERlN0, $HRH$HRBR0 VRR0HRHRN 0LLE0E 0F EN0lNEERlN0, $HRH$HRBR0 VRR0HRHRN 0LLE0E 0F EN0lNEERlN0, $HRH$HRBR0
51







Observation:







Conclusions:







Results:


































www.jntuworld.com
www.jntuworld.com
www.jwjobs.net
Department of ECE Embedded Systems Lab

VRR0HRHRN 0LLE0E 0F EN0lNEERlN0, $HRH$HRBR0 VRR0HRHRN 0LLE0E 0F EN0lNEERlN0, $HRH$HRBR0 VRR0HRHRN 0LLE0E 0F EN0lNEERlN0, $HRH$HRBR0 VRR0HRHRN 0LLE0E 0F EN0lNEERlN0, $HRH$HRBR0
52



Experiment No:-9

SERIAL COMMUNICATION IMPLEMENTATION
Aim: To write a program to Send/Receive data using serial communication capabilities of a 89c51
microcontroller.
Apparatus: The embedded kit which comprises of the microcontroller and different components, a
general purpose computer, Eclipse software to write the program, Flash magic software to dump the
program into the microcontroller.

Theory:
In telecommunication and computer science, serial communication is the process of sending data one bit
at one time, sequentially, over a communication channel or computer bus. This is in contrast to parallel
communication, where several bits are sent together (on a link comprising of several wired channels in
parallel).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. At
shorter distances, serial computer buses are becoming more common because of a tipping point where
the disadvantages of parallel busses (clock skew, interconnect density) outweigh their advantage of
simplicity (no need for serializer and deserializer (SERDES)). Improved technology to ensure signal
integrity and to transmit and receive at a sufficiently high speed per lane have made serial links
competitive. The migration from PCI to PCI-Express is an example.

Serial buses

Integrated circuits are more expensive when they have more pins. To reduce the pins, many ICs use a
serial bus to transfer data when speed is not important. Some examples of such low-cost serial buses
include SPI, IC, and 1-Wire.

Serial versus parallel

The communication links across which computers-or parts of computers-talk to one another may be
either serial or parallel. A parallel link transmits several streams of data (perhaps representing
particular bits of a stream of bytes) along multiple channels (wires, printed circuit tracks, optical
fibres, etc.); a serial link transmits a single stream of data.

At first sight it would seem that a serial link must be inferior to a parallel one, because it can transmit
less data on each clock tick. However, it is often the case that serial links can be clocked considerably
faster than parallel links, and achieve a higher data rate. A number of factors allow serial to be
clocked at a greater rate:

Clock skew between different channels is not an issue (for unclocked asynchronous serial
communication links)
A serial connection requires fewer interconnecting cables (e.g. wires/fibres) and hence
occupies less space. The extra space allows for better isolation of the channel from its
surroundings
Crosstalk is less of an issue, because there are fewer conductors in proximity.

In many cases, serial is a better option because it is cheaper to implement. Many ICs have serial
interfaces, as opposed to parallel ones, so that they have fewer pins and are therefore cheaper.

www.jntuworld.com
www.jntuworld.com
www.jwjobs.net
Department of ECE Embedded Systems Lab

VRR0HRHRN 0LLE0E 0F EN0lNEERlN0, $HRH$HRBR0 VRR0HRHRN 0LLE0E 0F EN0lNEERlN0, $HRH$HRBR0 VRR0HRHRN 0LLE0E 0F EN0lNEERlN0, $HRH$HRBR0 VRR0HRHRN 0LLE0E 0F EN0lNEERlN0, $HRH$HRBR0
53


Examples of serial communication architectures

Morse code telegraphy
RS-232 (low-speed, implemented by Serial Ports)
RS-423
RS-485
Universal Serial Bus (moderate-speed, for connecting computers to peripherals)
FireWire
Ethernet
Fibre Channel (high-speed, for connecting computers to mass storage devices)
InfiniBand (very high speed, broadly comparable in scope to PCI)
MIDI control of electronic musical instruments
DMX512 control of theatrical lighting
Serial Attached SCSI
Serial ATA
SpaceWire Spacecraft communication network
PCI Express
SONET and SDH (high speed telecommunication over optical fibers)
T-1, E-1 and variants (high speed telecommunication over copper pairs)

Here the serial communication in two way format is analyzed using a microcontroller. Data is sent and
received where the process is controlled by the microcontroller

Program:

#include<8051.h>
#include<serial_IO.h>
unsigned char c;

void serial_init() // Initialize UART baud rate to 9600

{
TMOD = 0X20;
TH1 = 0XFD;

TI = 1;

TR1 = 1;

SCON = 0X52;

//PCON =0x80;

}
void main()
{



www.jntuworld.com
www.jntuworld.com
www.jwjobs.net
Department of ECE Embedded Systems Lab

VRR0HRHRN 0LLE0E 0F EN0lNEERlN0, $HRH$HRBR0 VRR0HRHRN 0LLE0E 0F EN0lNEERlN0, $HRH$HRBR0 VRR0HRHRN 0LLE0E 0F EN0lNEERlN0, $HRH$HRBR0 VRR0HRHRN 0LLE0E 0F EN0lNEERlN0, $HRH$HRBR0
54

serial_init();

while(1)

{

c = getchar();

putchar(c);

}

}



Observations:




Conclusions:





Results




























www.jntuworld.com
www.jntuworld.com
www.jwjobs.net
Department of ECE Embedded Systems Lab

VRR0HRHRN 0LLE0E 0F EN0lNEERlN0, $HRH$HRBR0 VRR0HRHRN 0LLE0E 0F EN0lNEERlN0, $HRH$HRBR0 VRR0HRHRN 0LLE0E 0F EN0lNEERlN0, $HRH$HRBR0 VRR0HRHRN 0LLE0E 0F EN0lNEERlN0, $HRH$HRBR0
55

Experiment No:-10
STEPPER MOTOR CONTROL

Aim: To write a program to control the stepper motor using 89c51 microcontroller.
Apparatus: The embedded kit which comprises of the microcontroller and different components, a
general purpose computer, Eclipse software to write the program, Flash magic software to dump the
program into the microcontroller.

Theory:

A stepper motor (or step motor) is a brushless, synchronous electric motor that can divide a full
rotation into a large number of steps. The motor's position can be controlled precisely, without any
feedback mechanism (see open loop control). Stepper motors are similar to switched reluctance
motors, which are very large stepping motors with a reduced pole count, and generally are closedloop
commutated.

Fundamentals of Operation

Stepper motors operate differently from normal DC motors, which rotate when voltage is applied to their
terminals. Stepper motors, on the other hand, effectively have multiple "toothed" electromagnets
arranged around a central gear-shaped piece of iron. The electromagnets are energized by an external
control circuit, such as a microcontroller. To make the motor shaft turn, first one electromagnet is
given power, which makes the gear's teeth magnetically attracted to the electromagnet's teeth. When
the gear's teeth are thus aligned to the first electromagnet, they are slightly offset from the next
electromagnet. So when the next electromagnet is turned on and the first is turned off, the gear
rotates slightly to align with the next one, and from there the process is being repeated. Each of those
slight rotations is called a "step." In that way, the motor can be turned to a precise angle...

Stepper motor characteristics

Stepper motors are constant-power devices (power = angular velocity x torque). As motor speed
increases, torque decreases. The torque curve may be extended by using current limiting drivers and
increasing the driving voltage.

Steppers exhibit more vibration than other motor types, as the discrete step tends to snap the rotor
from one position to another. This vibration can become very bad at some speeds and can cause the
motor to lose torque. The effect can be mitigated by accelerating quickly through the problem speed
range, physically damping the system, or using a micro-stepping driver. Motors with a greater number of
phases also exhibit smoother operation than those with fewer phases.

Open-loop versus closed-loop commutation

Steppers are generally commutated open loop, ie. the driver has no feedback on where the rotor
actually is. Stepper motor systems must thus generally be over engineered, especially if the load
inertia is high, or there is widely varying load, so that there is no possibility that the motor will lose
steps. This has often caused the system designer to consider the trade-offs between a closely sized but
expensive servomechanism system and an oversized but relatively cheap stepper.



www.jntuworld.com
www.jntuworld.com
www.jwjobs.net
Department of ECE Embedded Systems Lab

VRR0HRHRN 0LLE0E 0F EN0lNEERlN0, $HRH$HRBR0 VRR0HRHRN 0LLE0E 0F EN0lNEERlN0, $HRH$HRBR0 VRR0HRHRN 0LLE0E 0F EN0lNEERlN0, $HRH$HRBR0 VRR0HRHRN 0LLE0E 0F EN0lNEERlN0, $HRH$HRBR0
56




A new development in stepper control is to incorporate a rotor position feedback (eg. an encoder or
resolver), so that the commutation can be made optimal for torque generation according to actual
rotor position. This turns the stepper motor into a high pole count brushless servo motor, with
exceptional low speed torque and position resolution. An advance on this technique is to normally run the
motor in open loop mode, and only enter closed loop mode if the rotor position error becomes too large -
- this will allow the system to avoid hunting or oscillating, a common servo problem.

Here the stepper motor is interfaced to the microcontroller and the controlling characteristics of the
microcontroller for different modes of operation of the stepper motor for different speeds are studied.

Program

#include "8051.h"

__xdata __at 0xffc8 unsigned char stp;
const char Clock[]={0x05,0x06,0x0a,0x09};
const char CClock[]={0x05,0x09,0x0a,0x06};
void delay(unsigned int temp)
{
unsigned int i,j=1000;
for(i=0;i<temp;i++)
{
do j--;

while(j!=0);

}

}
void main()
{
unsigned int i,j;
while(1)
{
for(j=0;j<55;j++)
{
for(i=0;i<4;i++)
{
www.jntuworld.com
www.jntuworld.com
www.jwjobs.net
Department of ECE Embedded Systems Lab

VRR0HRHRN 0LLE0E 0F EN0lNEERlN0, $HRH$HRBR0 VRR0HRHRN 0LLE0E 0F EN0lNEERlN0, $HRH$HRBR0 VRR0HRHRN 0LLE0E 0F EN0lNEERlN0, $HRH$HRBR0 VRR0HRHRN 0LLE0E 0F EN0lNEERlN0, $HRH$HRBR0
57


stp = Clock[i];
delay(1);
}

}
stp = 0xff;
delay(3);
for(j=0;j<55;j++)
{
for(i=0;i<4;i++)
{
stp = CClock[i];
delay(1);
}

}

stp = 0xff;

delay(3);

}

}



Observations:





Conclusions:





Results:



www.jntuworld.com
www.jntuworld.com
www.jwjobs.net
Department of ECE Embedded Systems Lab

VRR0HRHRN 0LLE0E 0F EN0lNEERlN0, $HRH$HRBR0 VRR0HRHRN 0LLE0E 0F EN0lNEERlN0, $HRH$HRBR0 VRR0HRHRN 0LLE0E 0F EN0lNEERlN0, $HRH$HRBR0 VRR0HRHRN 0LLE0E 0F EN0lNEERlN0, $HRH$HRBR0
58

Experiment No:-11
SWITCH CONTROL



Aim: To write a program to read the input from switch using 89c51 controller.
Apparatus: The embedded kit which comprises of the microcontroller and different components, a
general purpose computer, Eclipse software to write the program, Flash magic software to dump the
program into the microcontroller.

Theory:
The switch is interfaced to the microcontroller; the program is written and dumped into the
microcontroller. The analysis is made for the switch control operations of the microcontroller. The
operation of switch is analyzed by its response in the LED blinking when the switch is pressed.

Program:

#include<8051.h>

__xdata __at (0xffc0) unsigned char ledptr; //led location
__xdata __at (0xffc1) unsigned char swtptr; // switch location
unsigned int switch_data;
void main()

{
while(1)
{
ledptr=swtptr;
}
}












www.jntuworld.com
www.jntuworld.com
www.jwjobs.net
Department of ECE Embedded Systems Lab

VRR0HRHRN 0LLE0E 0F EN0lNEERlN0, $HRH$HRBR0 VRR0HRHRN 0LLE0E 0F EN0lNEERlN0, $HRH$HRBR0 VRR0HRHRN 0LLE0E 0F EN0lNEERlN0, $HRH$HRBR0 VRR0HRHRN 0LLE0E 0F EN0lNEERlN0, $HRH$HRBR0
59






Observations:









Conclusions:







Results:
































www.jntuworld.com
www.jntuworld.com
www.jwjobs.net
Department of ECE Embedded Systems Lab

VRR0HRHRN 0LLE0E 0F EN0lNEERlN0, $HRH$HRBR0 VRR0HRHRN 0LLE0E 0F EN0lNEERlN0, $HRH$HRBR0 VRR0HRHRN 0LLE0E 0F EN0lNEERlN0, $HRH$HRBR0 VRR0HRHRN 0LLE0E 0F EN0lNEERlN0, $HRH$HRBR0
60



Experiment No:-12
Temperature Sensing
Aim: To write a program to sense the Temperature using 89c51 microcontroller.
Apparatus: The embedded kit which comprises of the microcontroller and different components, a
general purpose computer, Eclipse software to write the program, Flash magic software to dump the
program into the microcontroller.

Theory:
Here the program temperature sensing capability of a sensor is analyzed when it is controlled through a
microcontroller. Here in this experiment a program is written and it is dumped into the
microcontroller and then the temperature is observed when the whole process is controlled by the
microcontroller

Program:

#include<8051.h>

#include<stdio.h>
#include<serial_IO.h>
#define HIGH 01;
#define LOW 00;
__idata unsigned char dat;
__idata unsigned char i;
__bit __at(0x94) SCLK;
__bit __at(0x95) SDA;



bit ACK;
void I2C_Start(void);
void I2C_Stop(void);
void I2C_Write(unsigned char j);
unsigned char I2C_Read(void);

www.jntuworld.com
www.jntuworld.com
www.jwjobs.net
Department of ECE Embedded Systems Lab

VRR0HRHRN 0LLE0E 0F EN0lNEERlN0, $HRH$HRBR0 VRR0HRHRN 0LLE0E 0F EN0lNEERlN0, $HRH$HRBR0 VRR0HRHRN 0LLE0E 0F EN0lNEERlN0, $HRH$HRBR0 VRR0HRHRN 0LLE0E 0F EN0lNEERlN0, $HRH$HRBR0
61


void Delay_Time(unsigned int);

void serial() //uart baud rate set to 9600

{
TMOD = 0x20;
TH1 = 0xfd;
TL1 = 0x00;
TCON = 0x40;
SCON = 0x50;
}



void I2C_Start(void)

{

SCLK=LOW;

SDA=LOW;

Delay_Time(5000);

SCLK = HIGH;

Delay_Time(5000);

SDA=HIGH;

Delay_Time(5000);

SDA = LOW;

Delay_Time(5000);

SCLK = LOW;

}



void I2C_Stop(void)

{

SCLK = LOW;

Delay_Time(5000);



//Start I2C by creating clock by setting and clearing the port pins





























//Stop I2C operation by clearing the SCLK Pin
www.jntuworld.com
www.jntuworld.com
www.jwjobs.net
Department of ECE Embedded Systems Lab

VRR0HRHRN 0LLE0E 0F EN0lNEERlN0, $HRH$HRBR0 VRR0HRHRN 0LLE0E 0F EN0lNEERlN0, $HRH$HRBR0 VRR0HRHRN 0LLE0E 0F EN0lNEERlN0, $HRH$HRBR0 VRR0HRHRN 0LLE0E 0F EN0lNEERlN0, $HRH$HRBR0
62



SDA = HIGH;

}

void I2C_Write(unsigned char j) // shifting data bit by bit to MSB and moving through i2c
{
dat=j;

for(i=0;i<8;i++)



{
SDA = dat & 0x80;
dat=dat<<1;
SCLK = HIGH;
Delay_Time(5000);
SCLK = LOW;
}



SDA=HIGH;
Delay_Time(5000);
SCLK = HIGH;
Delay_Time(5000);
ACK = SDA;
Delay_Time(5000);
SCLK = LOW;
}

unsigned char I2C_Read(void) //reading from i2c device bit by bit
{
unsigned char i,j;

www.jntuworld.com
www.jntuworld.com
www.jwjobs.net
Department of ECE Embedded Systems Lab

VRR0HRHRN 0LLE0E 0F EN0lNEERlN0, $HRH$HRBR0 VRR0HRHRN 0LLE0E 0F EN0lNEERlN0, $HRH$HRBR0 VRR0HRHRN 0LLE0E 0F EN0lNEERlN0, $HRH$HRBR0 VRR0HRHRN 0LLE0E 0F EN0lNEERlN0, $HRH$HRBR0
63

j = 0;

i = SDA;
for(i=0;i<8;i++)
{
j<<=1;
SCLK = HIGH;
j |= SDA;
Delay_Time(4000);
SCLK = LOW;
}
Delay_Time(4000);
SDA = LOW;
Delay_Time(4000);
SCLK = HIGH;
Delay_Time(4000);
SCLK = LOW;
Delay_Time(4000);
SDA = HIGH;
return j;

}
void main()
{

int data1,q,r,d;

I2C_Start();

I2C_Write(0x9E); //send device address

I2C_Write(0x43); //send device's control register address

I2C_Start();

I2C_Write(0x9f); // send command for read



www.jntuworld.com
www.jntuworld.com
www.jwjobs.net
Department of ECE Embedded Systems Lab

VRR0HRHRN 0LLE0E 0F EN0lNEERlN0, $HRH$HRBR0 VRR0HRHRN 0LLE0E 0F EN0lNEERlN0, $HRH$HRBR0 VRR0HRHRN 0LLE0E 0F EN0lNEERlN0, $HRH$HRBR0 VRR0HRHRN 0LLE0E 0F EN0lNEERlN0, $HRH$HRBR0
64
while(1)
{
data1=I2C_Read();
d= data1 * 100;
q = d/255;
r = d%255;
serial();
SBUF=' ';
printf("\r\nTemperature\t %d.%d 'C",q,r);
Delay_Time(3000);
}

}
void Delay_Time(unsigned int dly)
{
unsigned int i;
for(i=0;i<=dly;i++);
}


Observations:





Conclusions:





Results:
www.jntuworld.com
www.jntuworld.com
www.jwjobs.net

Anda mungkin juga menyukai