0 ratings0% found this document useful (0 votes) 127 views50 pages8051 Microcontroller
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content,
claim it here.
Available Formats
Download as PDF or read online on Scribd
CHAPTER 1
THE 8051
MICROCONTROLLERS
OBJECTIVES
Upon completion of this chapter, you will be able to:
>> Compare and contrast microprocessors and microcontrollers
> Describe the advantages of microcontrollers for some applications
>> Explain the concept of embedded systems
> Discuss criteria to consider in choosing a microcontroller
> Explain the variations of speed, packaging, memory, and
cost per unit and how these affect choosing a microcontroller
>> Compare and contrast the various members of the 8051 family
> Compare 8051 microcontrollers offered by various manufacturersxussion of the role and importance of micro,
1.1 we also discuss criteria to consider in
choosing a microcontroller, as well as the use of microcontrollers in the embed.
ded market. Section 1.2 covers various members of the 8051 family such as the
8052 and 8031, and their features. In addition, we discuss various versions of the
8051 such as the 8751, AT89C51, and DS5000.
This chapter begins with a disc
controllers in everyday life. In Section
SECTION 1.1: MICROCONTROLLERS AND EMBEDDED
PROCESSORS
In this section we discuss the need for microcontrollers and contrast them
with general-purpose microprocessors such as the Pentium and other x86 micro-
processors. We also look at the role of microcontrollers in the embedded market,
In addition, we provide some criteria on how to choose a microcontroller.
Microcontroller versus general-purpose microprocessor
What is the difference between a microprocessor and microcontroller? By
microprocessor is meant the general-purpose microprocessors such as Intel’s x86
family (8086, 80286, 80386, 80486, and the Pentium) or Motorola’s 680x0 fami-
ly (68000, 68010, 68020, 68030, 68040, etc.). These microprocessors contain no
RAM, no ROM, and no I/O ports on the chip itself. For this reason, they are com-
monly referred to as general-purpose microprocessors.
Data bus
CPU CPU | RAM] ROM
General- Serial
Purpose | | RAM|}ROM|| 1/0 | |Timer| | COM
Micro- Port Port VO | Timer | Serial
processor COM
Port
‘Address bus
(a) General-Purpose Microprocessor System (b) Microcontroller
Figure 1-1. Microprocessor System Contrasted With Microcontroller System
__A system designer using a general-purpose microy e
Pentium or the 68040 mus add RAM, ROM, UO ports, and tine cxoraly to
make them functional. Although the addition of extemal RAM, ROM, and V/O
Ports makes these systems bulkier and much more expensive, they have the advan-
tage of versatility such that the designer can decide on the amount of RAM, ROM,
and /O ports needed to fit the task at hand. This is not the case with mierocon.
trollers. A microcontroller has a CPU (a microprocessor) in addition to a fixed
am of RAM, ROM, I/O ports, and a timer all on a single chip. In other words,
Processor, the RAM, ROM, I/O ports, and timer are all embedded together on
one chip; therefore, the designer cannot add any external memory, I/O, or timer toHo
Applian
Intercom
Telephones
Security systems
Garage door openers
Answering machines
Fax machines
Home computers
TVs
Cable TV tuner
VR
Cameorder
Remote controls
Video games
Cellular phones
Musical instruments
Sewing machines
Lighting control
Paging
Camera
Pinball machines
Toys
Exercise equipment
Office
lephones,
Computers
Security systems
Fax machine
Microwave
Copier
Laser printer
Color printer
Paging
Auto
Trip computer
Engine control
Air bag
ABS
Instrumentation
Security system
Transmission control
Entertainment
Climate control
Cellular phone
Keyless entry
Table 1-1; Some
Embedded Products
Wy applications, for example a TV remote control,
there is no need for the computing power of a 486 or even an 8086
microprocessor. In many applications, the space it takes, the
power it consumes, and the price per unit are much more critical
considerations than the computing power. These applications
most ofien require some 1/O operations to read signals and turn on
and off certain bits. For this reason some call these processors
IBP, “itty-bitty processors” (see “Good Things in Small Packages
Are Generating Big Product Opportunities” by Rick Grehan,
BYTE magazine, September 1994; www.byte.com, for an excel-
lent discussion of microcontrollers).
I is interesting to note that some microcontroller manu-
facturers have gone as far as integrating an ADC (analog-to-digi
tal converter) and other peripherals into the microcontroller.
Microcontrollers for embedded systems
In the literature discussing microprocessors, we often see
the term embedded system. Microprocessors and microcontrollers
are widely used in embedded system products, An embedded
product uses a microprocessor (or microcontroller) to do one task
and one task only. A printer is an example of embedded system
since the processor inside it performs one task only; namely, get-
ting the data and printing it. Contrast this with a Pentium-based
PC (or any x86 IBM-compatible PC). A PC can be used for any
number of applications such as word processor, print-server, bank
teller terminal, video game player, network server, or internet ter-
minal. Software for a variety of applications can be loaded and
run. Of course the reason a PC can perform myriad tasks is that it
has RAM memory and an operating system that loads the appli-
cation software into RAM and lets the CPU run it. In an embed-
ded system, there is only one application software that is typical-
ly burned into ROM. An x86 PC contains or is connected to var-
ious embedded products such as the keyboard, printer, modem,
disk controller, sound card, CD-ROM driver, mouse, and so on.
Each one of these peripherals has a microcontroller inside it that
performs only one task. For example, inside every mouse there is,
a microcontroller to perform the task of finding the mouse posi-
tion and sending it to the PC. Table 1-1 lists some embedded
products.
X86 PC embedded applications
Although microcontrollers are the preferred choice for
many embedded systems, there are times that a microcontroller is
inadequate for the task. For this reason, in recent years many
manufacturers of general-purpose microprocessors such as Intel,
Motorola, AMD (Advanced Micro Devices, Inc.), and Cyrix
(now a division of National Semiconductor, Inc.) have targeted
SS
CHAPTER 1: THE 8051 MICROCONTROLLERS 25h end of the embedded market. While Intel, AMD,
and Cyrix push their x86 processors for both the embedded and desk-top PC mar.
kets, Motorola is determined to keep the 68000 family alive by targeting it main
ly for the high end of embedded systems now that Apple no longer uses the 680x0
in their Macintosh. In the early 1990s Apple computer began using Power PC
microprocessors (604, 603, 620, etc.) in place of the 680x0 for the Macintosh, The
Power PC microprocessor is a joint venture between IBM and Motorola, and is
targeted for the high end of the embedded market as well as the PC market. It must
be noted that when a company targets a general-purpose microprocessor for the
embedded market it optimizes the processor used for embedded systems. For this
reason these processors are often called high-end embedded processors. Very often
the terms embedded processor and microcontroller are used interchangeably.
One of the most critical needs of an embedded system is to decrease power
consumption and space. This can be achieved by integrating more functions into
the CPU chip. All the embedded processors based on the x86 and 680x0 have low
power consumption in addition to some forms of I/O, COM port, and ROM all on
a single chip. In high-performance embedded processors, the trend is to integrate
more and more functions on the CPU chip and let the designer decide which fea-
tures he/she wants to use. This trend is invading PC system design as well,
Normally, in designing the PC motherboard we need a CPU plus a chip-set con-
taining /O, a cache controller, a flash ROM containing BIOS, and finally a sec-
ondary cache memory. New designs are emerging in industry. For example, Cyrix
has announced that it is working on a chip that contains the entire PC, except for
DRAM. In other words, we are about to see an entire computer on a chip.
Currently, because of MS-DOS and Windows standardization many
embedded systems are using x86 PCs. In many cases using x86 PCs for the high-
end embedded applications not only saves money but also shortens development
time since there is a vast library of software already written for the DOS and
Windows platforms. The fact that Windows is a widely used and well understood
platform means that developing a Windows-based embedded product reduces the
cost and shortens the development time considerably.
their microprocessor for the hig!
Choosing a microcontroller
There are four major 8-bit microcontrollers. They are: Motorola’s 6811,
Intel’s 8051, Zilog’s Z8, and PIC 16X from Microchip Technology. Each of the
above microcontrollers has a unique instruction set and register set; therefore, they
are not compatible with each other. Programs written for one will not run on the
others. There are also 16-bit and 32-bit microcontrollers made by various chip
makers, With all these different microcontrollers, what eriteria do designers con-
sider in choosing one? Three criteria in choosing microcontrollers are as follows:
(1) meeting the computing needs of the task at hand efficiently and cost effective-
'y, (2) availability of software development tools such as compilers, assemblers,
and debuggers, and (3) wide availability and reliable sources of the microcon.
troller. Next we elaborate further on each of the above criteria
oS
26Criteria for choo:
ig a microcontroller
1. The first and foremost criterion in choosing a microcontroller is that it must
‘meet the task at hand efficiently and cost effectively. In analyzing the needs of
a microcontroller-based project, we must first see whether an 8-bit, 16-bit, or
32-bit microcontroller can best handle the computing needs of the task most
effectively. Among other considerations in this category are:
(a) Speed. What is the highest speed that the microcontroller supports?
(b) Packaging. Does it come in 40-pin DIP (dual inline package) or a QFP
(quad flat package), or some other packaging format? This is important in
terms of space, assembling, and prototyping the end product.
(c) Power consumption. This is especially critical for battery-powered prod-
ucts.
(d) The amount of RAM and ROM on chip.
(e) The number of 1/0 pins and the timer on the chip,
(1) How easy it is to upgrade to higher-performance or lower power-con-
sumption versions.
(g) Cost per unit. This is important in terms of the final cost of the product in
which a microcontroller is used. For example, there are microcontrollers
that cost $0 cents per unit when purchased 100,000 units at a time.
2. The second criterion in choosing a microcontroller is how easy it is to devel-
op products around it. Key considerations include the availability of an assem-
bler, debugger, a code-efficient C language compiler, emulator, technical sup-
port, and both in-house and outside expertise. In many cases, third-party vei
dor (that is, a supplier other than the chip manufacturer) support for the chi
as good as, if not better than, support from the chip manufacturer.
3. The third criterion in choosing a microcontroller is its ready availability in
needed quantities both now and in the future. For some designers this is even
more important than the first two criteria. Currently, of the leading 8-bit micro-
controllers, the 8051 family has the largest number of diversified (multiple
source) suppliers. By supplier is meant a producer besides the originator of the
Table 1-2: Some Companies Producing a Member of —_™icrocontroller. In the case
Leaisiaaeie of the 8051, which was orig-
—e wns inated by Intel, several com-
Compan: Web Site panies also currently pro-
Intel wwwaintel.com/design/mesS!___ duce (or have produced in
Atmel___wwwaatmel.com_ the past) the 8051. These
Philips/Signetics __www.semiconductors.philips.com companies include: Intel,
Siemens wow.sei.siemens.com Aunel, Philips/Signetics,
Dallas Semiconductor_www.dalsemi.com
AMD, Siemens, Matra, and
Dallas Semiconductor.
It should be noted that Motorola, Zilog, and Microchip ‘Technology have
all dedicated massive resources to ensure wide and timely availability of their
product since their product is stable, mature, and single sourced. In recent years
they also have begun to sell the ASIC library cell of the microcontroller.
ee
CHAPTER 1: THE 8051 MICROCONTROLLERS 27Review Questions
1. True or false. Microcontrollers are normally less expensive than microproces-
so
2. When comparing a system board based on a
pose microprocessor, which one is cheaper? ;
‘A microcontroller normally has which of the following devices on-chip?
(a) RAM (b) ROM (V0 (4) all of the above
4. A general-purpose microprocessor normally needs which of the following
devices to be attached to it?
(a) RAM (b) ROM () V0 (d) all of the above
5. An embedded system is also called a dedicated system. Why?
What does the term embedded system mean?
Why does having multiple sources of a given product matter?
microcontroller and a general-pur-
ae
SECTION 1.2: OVERVIEW OF THE 8051 FAMILY
In this section we first look at the various members of the 8051 family of
microcontrollers and their internal features. Plus we see who are the different man-
ufacturers of the 8051 and what kind of products they offer.
A brief history of the 8051
In 1981, Intel Corporation introduced an 8-bit microcontroller called the
8051. This microcontroller had 128 bytes of RAM, 4K bytes of on-chip ROM, two
timers, one serial port, and four ports (each 8-bits wide) all on a single chip. At the
time it was also referred to as a “system on a chip.” The 8051 is an 8-bit proces-
sor, meaning that the CPU can work on only 8 bits of data at a time. Data larger
than 8 bits has to be broken into 8-bit pieces to be processed by the CPU. The
8051 has a total of four 1/0 ports, each 8 bits wide. See Figure 1-2. Although the
8051 can have a maximum of 64K bytes of on-chip ROM, many manufacturers
have put only 4K bytes on the chip. This will be discussed in more detail later.
The 8051 became widely popular after Intel allowed other manufacturers
to make and market any flavor of the 8051 they please with the condition that they
remain code-compatible with the 8051. This has led to many versions of the 8051
with different speeds and amounts of on-chip ROM marketed by more than half a
dozen manufacturers. Next we review some of them. It is important to note that
although there are different flavors of the 8051 in terms " 8051
of speed and amount of on-chip ROM, they are all com. 2&2 Features ofthe
patible with the original 8051 as far as the instructions are Feature juantity
concerned. This means that if you write your program for ROM. aK bytes
one, it will run on any one of them regardless of the man. RAM anaes 125
ufacturer, STE ii
i 32
8051 microcontroller ae
Serial port i
The 8051 is the original member of the 8051 fam- !terTupt sources _6_—
ily Intel refers to it as MCS-51, Table 1-3 shows the maine” ROM amount indices 0”?
features of the 805 Program spaceEXTERNAL
INTERRUPTS
ON-CHIP Q
Vey, ROM 2
INTERRUPT |< for ETC. a
CONTROL |< program ‘ON-CHIP TIMER 0 |< q
code BAM TIMER 1 |< } fe
+ “ 5
cpu
aan
BUS 40 SERIAL,
osc CONTROL PORTS PORT
ttt i
rls eT y
PO P1 P2 P3 TXD RXD
——
ADDRESSIDATA
Figure 1-2. Inside the 8051 Microcontroller Block Diagram
Other members of the 8051 family
‘There are two other members in the 8051 family of microcontrollers. They
are the 8052 and the 8031
8052 microcontroller
The 8052 is another member of the 8051 family. The 8052 has all the stan-
dard features of the 8051 in addition to an extra 128 bytes of RAM and an extra
timer. In other words, the 8052 has 256 bytes of RAM and 3 timers. It also has 8K
bytes of on-chip program ROM instead of 4K bytes. See Table 1-4,
‘Table 1-4: Comparison of 8051 Family Members
8051 8052 8031
Feature
ROM (on-chip program space in bytes) 4K. 8K OK
RAM (bytes 128 256 128
Timers 2 3 2
VO pins 32 32 32
Serial port 1 1 1
Interrupt sources 6 8 6
‘As can be seen from Table 1-4, the 8051 is a subset of the 8052; therefore,
all programs written for the 8051 will run on the 8052, but the reverse is not true
$$
CHAPTER I: THE 8051 MICROCONTROLLERS. 298031 microcontroller ‘ 8031 chip. This chip is often
Another member of the 8051 family is the § eS ROM To aT
referred to as a ROM-less 8051 since it has OK by Pea must contain the pro-
chip you must add external ROM to it. This external ROM Mast Sanh pio:
aya tha the 8031 will fetch and execute rai and ecient eta
5 rogram to C ie
ae ea Sree ROM containing the program NaI sae
be as large as 64K bytes. In the process of adding cua lei ee
lose two ports. That leaves only 2 ports (of the 4 ports) for er mene oi
this problem, you can add external 1/0 to the 8031. ine ey
memory and /O ports such as the 8255 chip is discussed in Chapt re
also various speed versions of the 8031 available from different companies.
Various 8051 microcontrollers : /
Although the 8051 is the most popular member of the 8051 family, you will
not see “8051” in the part number. This is because the 8051 is available in differ-
ent memory types, such as UV-EPROM, flash, and NV-RAM, all of which have
different part numbers. A discussion of the various types of ROM will be given in
Chapter 14. The UV-EPROM version of the 8051 is the 8751. The flash ROM ver-
sion is marketed by many companies including Atmel Corp. The Atmel Flash
8051 is called ATS9C51. The NV-RAM version of the 8051 made by Dallas
Semiconductor is called DS5000. There is also the OTP (one-time programmable)
version of the 8051 made by various manufacturers. Next we discuss briefly each
of the above chips and describe applications where they are used.
8751 microcontroller
This 8751 chip has only 4K bytes of on-chip UV-EPROM. To use this chip
for development requires access to a PROM burner, as well as a UV-EPROM eras-
er to erase the contents of UV-EPROM inside the 8751 chip before you can pro-
gram it again, Due to the fact that the on-chip ROM for the 8751 is UV-EPROM,
it takes around 20 minutes to erase the 8751 before it can be programmed again,
This has led many manufacturers to introduce flash and NV-RAM versions of the
8051 as we will discuss next. There are also various speed versions of the 8751
available from different companies,
AT89C51 from Atmel Corporation
This popular 8051 chip has on-chip ROM in the form of flash memory.
This is ideal for fast development since flash memory ean be erased in seconds
compared to the twenty minutes or more needed for the 8751. For this reason the
AT89CS1 is used in place of the 8751 to eliminate the wailing time needed te erase
the chip and thereby speed up the development time. To use the AT89CS1 to devel-
©P a microcontroller-based system requires a ROM burner that supports flash
memory; however, a ROM eraser is not needed. “Notice that fa Meh eeaocy you
must tase the entre contents of ROM in order to program it get r
of flash is done by the PROM burner itself and this ig why a separate
This erasing
eraser is notTable 1-5: Versions of 8051 From Atmel (All ROM Flash
Part Number ROM __RAM __1/O pins
Ti i
ATS9CS1 aK 128 32 — “ at
ATSOLVS1 4k 128 32 2 6 3V. 40
AT89C10S1_—_ 1K 64 15 1 3 3V. 20
AT89C2051 2K 128 1s 2. 6 3V 20
AT89C52 8K 128 32. 3: 8 bv. 40
ATS89LV52 8K 128 32 2 8 3V 40
Note: “C” in the part number indicates CMOS.
There are various speed and packaging versions of the above products. See
Table 1-6. For example, notice AT89C51-12PC where “C” before the 51 is for
CMOS, which has a low power consumption, “12” indicates 12 MHz, “P” is for
plastic DIP package, and “C” is for commercial (vs. “M” for military). Often, the
AT89C51-12PC is ideal for many student projects.
Table 1-6: Various Speeds of 8051 From Atmel
Part Number Speed Pins Packaging Use
AT89C51-12PC 12 MHz __40 DIP plastic commer
AT89C51-16PC 16 MHz 40 DIP plastic commercial
AT89C51-20PC 20 MHz 40 DIP plastic commercial
DS5000 from Dallas Semiconductor
Another popular version of the 8051 is the DSS000 chip from Dallas
Semiconductor. The on-chip ROM for the DS5000 is in the form of NV-RAM.
‘The read/write capability of NV-RAM allows the program to be loaded into the
on-chip ROM while it is in the system. This can be done even via the serial port
of an IBM PC. This in-system program loading of DS5000 via a PC serial port
makes it an ideal home development system. Another advantage of NV-RAM is
the ability to change the ROM contents one byte at a time. Contrast this with UV-
EPROM and flash memory in which the entire ROM must be erased before it is
programmed again.
‘Table 1-7: Versions of 8051 From Dallas Semiconductor's Soft Microcontroller
Part Number ROM RAM VO pins Timers Interrupts Vcc _ Packaging
DS5000-8 8K 128 32, zs 6 3V 40.
DS5000-32 32K. 128 32, 2 6 SM 40
DSS000T-8 8K 128 32 2 6 SV. 40
Dss000T-8 32K. 128 32 2 6 SV. 40,
Notes: All ROM are NV-RAM.
“7” means it has a real-time clock.
Notice that the real-time clock (RTC) is different from the timer. The real-
time clock generates and keeps the time of day (hr-min-sec) and date (yr-mon-day)
‘even when the power is off.
———— SSS
CHAPTER 1: THE 8051 MICROCONTROLLERS 31ackaging versions of the DSS000 as shown
e various speed and packaging ¥
in table te For earls 'D$5000-8-8 has 8K NV-RAM and a pes of SM,
Often iis D$5000-8-12 (or DSS000T-8-12) is jdeal for many student projects,
Table 1-8: Versions of 8051 From, Dallas Semiconductor
Part Number. NV-RAM Speed
DS5000-8-8 8K 8 MHz
DS5000-8-12 8K 12 MHz
8 MHz
D$5000-32-8 K 2
DSSO00T-32-8 321 8 MHz (with RTC
5 32K 12 MHz
ae aah RG) aa
8K 12 MHz ___(with RTC
OTP version of the 8051
There are also OTP (one-time-programmable) versions of the 8051 avail-
able from different sources. Flash and NV-RAM versions are typically used for
product development. When a product is designed and absolutely finalized, the
OTP version of the 8051 is used for mass production since it is much cheaper in
terms of price per unit.
8051 family from Philips
Another major producer of the 8051 family is Philips Corporation, Indeed,
they have one of the largest selections of 8051 microcontrollers. Many of their
products include features such as A-to-D converters, D-to-A converters, extended
/O, and both OTP and flash.
Review Questions
1. Name three features of the 8051.
2. What is the major difference between the 8051 Si ?
3. Give the size of RAM in each of the faNGag are
(a) 8051 (b) 8052) 8031 ‘
4. Give the size of the on-chip ROM in
(a) 8051 (b) 8052 (c) 8031 ach ofthe
5. The 8051 is a(n) -bit micro
ee processor.
6 aaa einer between the 8751, the AT9CS1 and the DS5000.
i tional features j in the D
Li adi res introduced in the DSSOOOT that are not present in the
8. True or false. The ATS9CS1-12PC chi
9. The AT89CS1-12PC chip can cae oes
10. The DSS000-32 has aa
following.
DIP package.
imum frequency of MHz.
—K bytes of on-chip ean: for programs.
tienes tn. NEA rtaseSUMMARY
This chapter discussed the role and importance of microcontrollers in
everyday life. Microprocessors and microcontrollers were contrasted and com-
pared. We discussed the use of microcontrollers in the embedded market. We also
discussed criteria to consider in choosing a microcontroller such as speed, memo-
ing, and cost per unit. The second section of this chapter described
various family members of the 8051, such as the 8052 and 8031, and their features,
In addition, we discussed various-versions of the 8051 such as the AT89CS1 and
DSS000, which are marketed by suppliers other than Intel.
PROBLEMS
SECTION 1.1: MICROCONTROLLERS AND EMBEDDED PROCESSORS.
1, True or False. A general-purpose microprocessor has on-chip ROM.
2. True or False. A microcontroller has on-chip ROM
3. True or False. A microcontroller has on-chip I/O ports.
4, True or False. A microcontroller has a fixed amount of RAM on the chip.
5. What components are normally put together with the microcontroller into a
singie chip?
6. Intel's Pentium chips used in Windows PCs need external and
chips to store data and code.
7. List three embedded products attached to a PC.
Why would someone want to use an x86 as an embedded processor?
9. Give the name and the manufacturer of some of the most widely used 8-bit
microcontrollers.
10, In Question 9, which one has the most manufacture sources?
11, In a battery-based embedded product, what is the most important factor in
choosing a microcontroller?
12. In an embedded controller with on-chip ROM, why does the size of the ROM
matter?
13. In choosing a microcontroller, how important is it to have a multiple source for
that chip?
14, What does the term "third-party support” mean?
15. If a microcontroller architecture has both 8-bit and 16-bit versions, which of
the following statements is true.
(a) The 8-bit software will run on the 16-bit system.
(b) The 16-bit software will run on the 8-bit system.
SECTION 1.2: OVERVIEW OF THE 8051 FAMILY
16. The 8751 has bytes of on-chip ROM.
17, The AT89CS1 has bytes of on-chip RAM.
18. The 8051 has __ on-chip timer(s).
CHAPTER 1: THE 8051 MICROCONTROLLERS 319. The 8052 has __bytes of on-chip RAM.
20. The ROMless version of the a oa =
21. The 8051 family has ___ pins for 1/0. ;
22. The 8051 family has circuitry to support serial ports.
23. The 8751 on-chip ROM is of type
24, The AT8951 on-chip ROM is of type
5. The DS5000 on-chip ROM is of type ‘
6. Give the speed and package type for the following chips:
(a) AT89C51-16PC__(b) DS5000-8-12 :
27. In Question 26, give the amount and type of on-chip ROM. — ;
28. Of the 8051 family, which version is the most cost effective if you are using a
million of them in an embedded product?
29, What is the difference between the 8031 and 8051?
30. Of the 8051 microcontrollers, which one is the best for a home development
environment? (You do not have access to a ROM burner).
as the part number.
ANSWERS TO REVIEW QUESTIONS
SECTION 1.1: MICROCONTROLLERS AND EMBEDDED PROCESSORS
1 True 2. A microcontroller based system 3.(@) 4.)
5. It is dedicated since itis dedicated to doing one type of job.
6. Embedded system means the processor is embedded into that application,
7. Having multiple sources for a given part means you are not hostage to one supplier. More
importantly competition among suppliers brings about lower cost for that product.
SECTION 1.2: OVERVIEW OF THE 8051 FAMILY
1, 128 bytes of RAM, 4K bytes of on-chip ROM, four 8-bit I/O ports
2. The 8052 has everything that the 8051 has, plus an extra timer, and the on-chip ROM is 8K
bytes instead of 4K bytes. The RAM in the 8052 is 256 bytes instead of 128 bytes.
Both the 8051 and the 8031 have 128 bytes of RAM and the 8052 has 256 bytes.
Siac (b) 8K bytes (©) 0K bytes
‘The difference is the type of on-chip ROM. In the 8751
T itis UV-EPROM; i
is flash; and in the DSS000 it is NV-RAM. AesagaaATES
7. DSSO0OT has a real-time clock (RTC).
8. True
9
1
2CHAPTER 12
REAL-WORLD
INTERFACING I:
LCD, ADC, AND SENSORS
OBJECTIVES
Upon completion of this chapter, you will be able to:
List reasons that LCDs are gaining wide-spread use, replacing LEDs
Describe the functions of the pins of a typical LCD
List instruction command codes for programming an LCD
Interface an LCD to the 8051
Program an LCD by sending data or commands to it from the 8051
Interface ADC (analog-to-digital converter) chips to the 8051
Interface temperature sensors to the 8051
Explain the process of data acquisition using ADC chips
Describe factors to consider in selecting an ADC chip
Describe the function of the pins of a typical ADC chip
Explain the function of precision IC temperature sensors
Describe signal conditioning and its role in data acquisitiona
This chapter explores some real-world applications of the 8051. We
explain how to interface the 8051 to devices such as an LCD, ADC, and sensors,
In Section 12.1, we show LCD interfacing with the 8051. In Section 12.2, we
describe analog-to-digital converter (ADC) connection with sensors and the 8051
SECTION 12.1: INTERFACING AN LCD TO THE 8051
This section describes the op
program and interface an LCD to an 8051
LCD operation
ation modes of LCDs, then describes how to
In recent years the LCD is finding widespread use replacing LEDs (seven
The declining prices of LCDs.
The ability to display numbers, charact
LEDs, which are limited to
‘gment LEDs or other multisegment LEDs). This is due to the following reasons:
and graphics. This is in contrast to
imbers and a few characters,
3. Incorporation of a refreshing controller into the LCD, thereby relieving the
CPU of the task of refreshing the LCD. In contrast, the LED must be refreshed
by the CPU (or in some other way) to keep displaying the data.
4. Ease of pri
LCD pin descriptions
The LCD discussed in this section ha
gramming for characters and graphics.
s 14 pins. The function of each pin is
given in Table 12-1. Figure 12-1 shows the pin positions for various LCDs,
Veo Vgs, and Veg
While Vec and Veg provide +5V and
ground, respectively, Vx is used for control-
ling LCD contrast
RS, register select
There are two very important registers
inside the LCD. The RS pin is used for their
selection as follows. If RS = 0, the instruction
command code register is selected, allowing the
user to send a command such as clear display,
cursor at home, ete. If RS = | the data register
is selected, allowing the user to send data to be
displayed on the LCD,
RW, read/write
R/W input allows the user to write infor-
mation to the LCD or read information from it,
WW = 1 when reading; R/W = 0 when wting
E, enable
The enable pin is used
latch information presented to its data Pins.
236
by the LCD to
Table 12-1, Pin Descriptions for LCD
in_Symbol_VO Description
1a eG round
2 Veco = +5V power supply
3° Veg = Power supply
to control contrast
“ RSL RS=0 to select
command register,
RS=1 to select
data register _-
5 RW I RIW=0 for write,
RAW=1 for read,
6 E10 Enable
1__DBO VO The 8-bit data bus
8
9
DBI_V/O The 8-bit data bus
DB2 VO The 8-bit data bus
10 DB3 VO The 8-bit data bus
12 “WO The 8-bit data bs
ier O_The 8-bit data bu
The 8-bit data busWhen data is supplied to data
in order for the LCD to latch in 1
, a high-to-low pulse
he data present at the
must be applied to this pin
data pins. This pulse must
be a minimum of 450 ns wi
DO-D7
The &-bit data pins, DO - D7, are used to send information to the LCD or
read the contents of the LCD's internal register
To display letters and numbers, we send
az, and numbers 0 - 910 these pins while mak
There are also instruc-
tion command codes that can
be sent to the LCD to clear the
display or force the cursor to
the home position or blink the
cursor. Table 12-2 lists the
instruction command codes.
We also use RS = 0 to
eck the busy flag bit to see if
the LCD is ready to receive
information. The busy flag is
D7 and can be read when R/W
= 1 and RS = 0, as follows: if
RW = 1, RS = 0, When D7
1 (busy flag = 1), the LCD is
busy taking care of internal
operations and will not accept
any new information. When
D7 = 0, the LCD is ready to
receive new information. Nore:
Itis recommended to check the
busy flag before writing any
data to the LCD.
ASCII codes for the letters A - Z,
ing RS = |
Table 12-2: LCD Command Codes
‘ode
ommand We CD Tears
Hex) Register
2 Return home.
4 Decrement cursor (shift cursor to left)
6 Increment cursor (shift cursor to right)
5 Shift display right
- Shift display left
8 Display off, cursor off
A Display off, cursor on
c Display on, cursor off
Ez Display on, cursor blinking
g Display on, cursor 1
10 Shift cursor position to left
14 Shift cursor position to right
18 Shift the entire display to the left
ects display to the left
1C___Shifi the entire display to the right
80 Force cursor to beginning of Ist line
CO___Force cursor to beginning of 2nd line
38 2 lines and 5x7 matrix
‘Note* This table is extracted from Table 12-4
i
2 4
DODD0D000000
°
°
DO 14 DMC16106B 21
miele ae
DMCI6II7 DMC 16240
DMCI6128 DMC20218
DMC16129 DMC --
Beeig eta3 DMC40218
DMC20434
"eT. Pin Positions Tor Various LCDs from Optex
i
PTE,
a
R 12: REAL-WORLD INTERFACING Ind data to LCDs with a time delay
Sending commands a a eetenteny
Je 12-2 to the LCD, make pin
ff the commands from Tabl d
=0, ae RS ~|_ Then send a high-to-low pulse to the E pin to enable
the internal latch of the LCD. This is shown in the code ct eee
;calls a time delay before sending next da es
P1.0-P1.7 are connected to LCD data pins DO
P2.0 is connected to RS pin of LCD
P2.1 is connected to R/W pin of LCD
P2.2 is connected to B pin of LCD
‘ORG
Mov A,#38H ;init. LCD 2 lines, 5x7 matrix
ACALL COMNWRT ;eall command subroutine
ACALL DELAY give LCD some time
Mov A, #0EH ;display on, cursor on
ACALL — COMNWRT ;call command subroutine
ACALL DELAY ;give LCD some time
Mov B, #01 yelear LCD
ACALL — COMNWRT ;call command subroutine
ACALL DELAY give LCD some time
Mov A, #06 ishift cursor right
ACALL COMNWRT #eall command subroutine
ACALL DELAY give LCD some time
MoV A, #848 ycursor at line 1,pos. 4
ACALL — COMNWRT call command subroutine
ACALL DELAY igive LCD some time
Mov A, EIN! idisplay letter N
ACALL DATAWRT jeall display subroutine
eed oe ae LCD some time
#08 idisplay letter 0
ACALL —_DATAWRT #call display subroutine
AGAIN: SJMP AGAIN stay here
COMNWRT: #send command to LCD
He Pie #copy reg A to portl
am a #RS=0 for command
ate ai #R/W=0 for write
CLR 22am
RET
DATAWRT:The above code showed
how to send commands to the LCD
without checking the busy flag
Notice that we must put a long
delay in between issuing data or
commands to the LCD. However, a
much better way is to monitor the
busy flag before issuing a command
or data to the LCD. This is shown
below.
to write to LCD
H-to-L pulse
tch in
is LCD ready?
issue data
RS=1 for data
7R/W=0 to write to LeD
;E=1 for H-to-L pulse
7E=0, latch in
_ SarreR 12: REAL-WORLD INTERFACING Ijmake P1.7 input port
SETB 7R/W=1 read command reg
;read command and check busy flag
BACK:CLR ;E=1 for H-to-L pulse
}E+0 H-to-L pulse
BACK ;stay until busy flag=0
Notice in the above program that the busy flag is D7 of the command reg-
ister. To read the command register we make R/W = 1, RS = 0, and a H-to-L pulse
for the E pin will provide us the command register. After reading the command
register, if bit D7 (the busy flag) is high, the LCD is busy and no information
(command or data) should be issued to it. Only when D7 = 0 can we send data or
commands to the LCD. Notice in this method that there are no time delays used
since we are checking the busy flag before issuing commands or data to the LCD.
LCD data sheet
In the LCD, one can put data at any location, The following shows address
locations and how they are accessed.
RS R/W DB7 DB6 DBS DB4 DB3 DB2 DBI DBO
0 0 1 4A Ad A ee A
where AAAAAAA = 0000000 to 0100111 for line 1 and AAAAAAA =
1000000 to 1100111 for line 2. See Table 12-3.
Table 12-3: LCD Addressing
2 = DB7_DB6_DBS_DB4_ DB3_DB2 DBI DBO
Line 1 (min, 1
aa
‘The upper address range can go
ter-wide LCD while for the 20- ct
imal
which corresponds to locatieRe ae Soa
40 x 2 LcD
Note: All data is in hex,
Figure 12-3 Cursor Addresses for Some LCDs
‘own = Enable pulse width= 450 ns (minimum)
'osw = Data set up time = 195 ns (minimum)
‘yy = Data hold time = 10 ns (minimum)
{as = Set up time prior to E (going high) for both RS and R/W = 140 ns (minimum)
‘ait ~ Hold time after E has come down for both RS and R/W = 10 ns (minimum)
Figure 12-4; LCD Timing
Review Questions
1. The RS pin is an (input, output) pin for th es
E pin is an_____(input, output) pin for the LCD. ;
3. ae ie an a (H-to-L, L-to-H) pulse to latch in information
at the data pins of the LCD. ; ‘
4. Forthe LCD to recognize information at the data pins as data, RS must be set
to igh, low). Fret citiett
5, Crete ” aesfoling 1 il tbat, lak Cnt
ee
R 12: REAL-WORLD INTERFACING IExecution
Time
Inst (Max
Clear Display 0 0 0 ¢ 00 0 Clears entire display and sets DD Tene
RAM address 0 in address counter
Return Home 0 00.0 00 0 Sets DD RAM address 0 as address 1.64 ms
counter. Also returns display being
shifted to original position. DD RAM
contents remain unchanged.
Tniry Mode 0 0 0 0 0 D1 17S Sels cursor move direction and specifies —40ys
Set shift of display. These operations are
performed during data write and read.
Display On/ TOC Tp eB Sets On/Off entire display (D), ys
Of Control cursor On/OfT (C), and blink of cursor
position character (B).
Cansor oF D000 WL~ ~ Moves cursor and shifts display with- 40s
Display Shift out changing DD RAM contents.
Function Set 0 0 0 1 bb NF ~~ Setsinterface data length (DL), num-_ 40js
ber of display lines (L) and character
font (F
Set (GRAM 000 nae Sets CG RAM address. CG RAM data 40)s
is sent and received after this setting.
Set DD RAM 0 ADD Sets DD RAM address. DD RAM data_40)s
Address is sent and received after this setting.
Read Busy D1 B aC Reads Busy flag (BF) indicating inter- 40 )s
Flag & Address nal operation is being performed and
reads address counter contents.
WriteData 0 write pata Writes data into DD or CG RAM. 40s
CG or DD RAM
Read Data 11 Read Data_—_—-Reads data from DD or CG RAM. 408
°G or DD RAM
ores
1, Execution times are maximum times when fe
2 Eeution ime changes when frequency charges Bx Whe For soa 270 ke 40 ps «250 /270°37 8
DD RAM Display data RAM
CGRAM Character generator RAM.
Sanaa
1M address, eae
AC Address.
WD=1 freemen PF DB ans CS RA address,
f Accompanies display shift Decrement
sic=1 Display shift; Sea) a Nk
‘Shift to the right;
Sits, DLO: bits RL=0 Sin
Hine, N= 0:1 tine c 5
FE 5x 10 dots, F=0; 5 x 7 dots eel 6
bs {ntemal operation; BF = 0 Can epiSECTION 12.2: 8051 INTERFACING TO ADC, SENSORS
This section will explore interfacing ADC (analog-to-digital converter)
chips and temperature sensors to the 8051 First, we describe ADC chips, then
show how to interface an ADC to the 8051. Then we examine the characteristics
of the LM35 temperature sensor and show how to interface it to the 8051
ADC devices
Analog-to-digital converters are among the most widely used devices for
data acquisition. Digital computers use binary (discrete) values, but in the physi-
cal world everything is analog (continuous), Temperature, pressure (wind or liq-
uid), humidity, and velocity are a few examples of physical quantities that we deal
with every day. A physical quantity is converted to electrical (voltage, current) sig-
nals using a device called a transducer. Transducers are also referred to as sensors.
Although there are sensors for temperature, velocity, pressure, light, and many
other natural quantities, they produce an output that is voltage (or current).
Therefore, we need an analog-to-digital converter to translate the analog signals to
digital numbers so that the microcontroller can read them, A widely used ADC
chip is the ADC804.
ADC804 chip
The ADC804 IC is an analog-to-digital converter in the family of the
ADC800 series from National Semiconductor. Itis also available from many other
manufacturers. It works with +5 volts and has a resolution of 8 bits. In addition to
resolution, conversion time is another major factor in judging an ADC. Conversion
time is defined as the time it takes the ADC to convert the analog input to a digi-
tal (binary) number. In the ADC804, the conversion time varies depending on the
clocking signals applied to the CLK R and CLK IN pins, but it cannot be faster
than 110 us. The ADC804 pin descriptions follow.
cs
Chip select is an active low input used to activate the ADC804 chip. To
access the ADC804, this pin must be low.
RD (read)
This is an input signal and is active low. The ADC converts the analog
input to its binary equivalent and holds it in an internal register. RD is used to get
the converted data out of the ADC804 chip. When CS = 0, if a high-to-low pulse
is applied to the RD pin, the 8-bit digital output shows up at the DO - D7 data pins.
The RD pin is also referred to as output enable.
WR (write; a better name might be “start conversion")
This is an active low input used to inform the ADC804 to start the con-
Version process. If CS = 0 when WR makes @ low-to-high transition, the ADC804,
Starts converting the analog input value of Vin to an 8-bit digital number. The
amount of time it takes to convert varies depending on the CLK IN and CLK R
Values explained below. When the data conversion is complete, the INTR pin is
Orced low by the ADC804.
243
q
eo rren 12: REAL-WORLD INTERFACING 1CLK IN and CLK R
CLK IN js an input pin connected to an external clock source when an
external clock is used for timing. However, the 804 has an internal clock genera-
tor. To use the internal clock generator (also called self-clocking) of the ADC804,
the CLK IN and CLK R pins are connected to a capacitor and a resistor, as shown
in Figure 12-5. In that case the clock frequency is determined by the equation:
1
f —
L1RC
Typical values are R = 10K ohms and C = 150 pF. Substituting in the
above equation, we get f= 606 kHz. In that case, the conversion time is 110 us.
ADC0804
INTR (interrupt; a better name might be “end of
This is an output pin and is acti is
the conversion is finished it goes law paige Gai
ready to be picked up. Afier INTR
low pulse to the RD pin to get
Vig (4) 20 Vig (-) .Vref?
Pin 9 is an input voltage used fi Ferenc sc
nu comeh te ae sag fe Ul Seen
volts (the same as the Voe pin), However, there are many: applications where the
analog input applied to Vin needs to be other than the 0 to #8 V range. Vier? &S
used to implement analog input voltages other than 0 — $V. For example, if the
analog input range needs to be 0 to 4 Volts, V ce? is eonnectedt to 2 volts. Table 12
5 shows the Via range for various Vice? inputs
Table 12-5: Vig¢2 Relation to Vi, Range
Vref? WY) Vin (Y) Step Size (MV)
Tor connected Tos TACT IO IT
wd Toss so.
Qws 20 = 1
Dw256 230056 = 10
De? 3380-78
Owl L2s0 = 2.00
Notes: Vee = 5 V
* When not connected (open), Vie? is measured at 2.5 vos fe Vg = SV
Step Size (resolution) is the smallest change that can be dlscenedt BY an ADC
D0-D7
DO - D7 (where D7 is the MSB, DO the LSB) are the digital data output
pins. These are tri-state buflered and the converted data is accesses! only when CS
= 0 and RD is forved low, To calculate the output voltage, use the following. fans
mula.
analog input voltage,
2.V
where Dou: = digital data output (in decimal), V
and step size (resolution) is the smallest change, which is (
S-bit ADC.
Analog ground and digital ground
These are the input pins providing the ground for both the analog signal
and the digital signal, Analog ground is connected to the ground of the analog Vy
While digital ground is connected to the ground of the Vig pins The reason that we
x < to isolate the analog V\y signal fom transient voltages
caused by digital switching of the output DO ~ D7, Such isolation contributes to the
accuracy of the digital data output, In out discussion, both are connected t the
same ground: however, in the real world of data acquisition the analog anc digital
Srounds are handled separately
sac hand Ses at he ng ES eT
lowed for data conversion by the ADCSO chip.
280 for an
have two ground pins|. Make CS = 0 and send a low-to-high pulse to pin WR to start i eons
2. Keep monitoring the INTR pin, If INTR is low, the conversion is in
‘Wwe can go to the next step. If INTR is hi
keep polling until it goes low.
3. After the INTR has become low, we make CS = 0 and send ols oi ad
to the RD pin to get the data out of the ADC804 IC chip. The 1s
Process is shown in Figure 12-6.
cs.
Wr.
00-7 Data out
INTR’
ag Start conversion End conversion
RD.
Note: CS is set to low for both RD and WR pulses.
Read it
Figure 12-6, Read and Write
Testing
One can test the ADC804 using the
jing for ADCBO4
the ADC804
cuit shown in Figure 12-5. This
Setup is called free running test mode and is recommended by the manufacturer
Figure |
input Vip (
the di
grounded ai
to National
momentaril.
Figure 12-7. 8051 Connection to ADCBO4 wi
5 shows a potentiometer used to apply a 0-to-5 V analog voltage to the
*) of the 804 ADC. The binary outputs are monitored on the LEDs of
al trainer. It must be noted that in free running test mode the CS input is
ind the WR input is connected to the INTR output. However, according
| Semiconductor's” databook "the WR and INTR node should be
» forced to low following a power-up cycle to guarantee operation."
8051
P25
P26
P1.0
«eaeExamine the ADC804 connection to the 8051 in Figure 12-7. Write a program to
monitor the INTR pin and bring an analog input into register A. Then call a
hex-to-ASCII conversion and data display subroutines. Do this continuously.
Solution:
+P2.6 = WR (start conversion needs to L-to-H pulse)
7P2.7 When low, end-of-conversion)
P2.5 = RD (a H-to-L will read the data from ADC chip)
P1,0 - Pl.? = DO - D7 of the ADC804
MOV P1,#0FFH ;make Pl = input.
BACK: CLR P2.6 7WR=0
SETB P2.6 iWR=1 L-to-H to start conversion.
HERE: JB P2.7,HERE ;wait for end of conversion
CLR P2.5 jconversion finished,enable RD
MOV A; Pl jread the data
ACALL CONVERSION yhex-to-ASCII conversion
ACALL DATA_DISPLAY ;display the data
SETB P2.5 ymake RD=1 for next round
SJMP BACK
Note: For a hex-to-ASCII conversion subroutine, see Chapter 7.
sv
8051 ADC804 9
=r ie ee
CLK RJ
| 2 cen
XTAL2. P1.0}—<—|po
Vin(+)}
Vin(-)}
[| Acno
[| vret2
P1.7;}—<—|07 GND)
INTR —
cs
TALS74
Figure 12-8. 8051 ‘Connection to ADC804 with Clock from XTAL2 of the 8051
In Figure 12-8, notice that the clock in for the ADC804 is coming from the
crystal of the microcontroller. Since this frequency is too high, we use two D flip-
flops (74L$74) to divide the frequency by 4. A D flip-flop divides the frequency
by 2 if we connect its Q to the D input. For a higher frequency, use more flip-flops.
ee
CHAPTER 12: REAL-WORLD INTERFACING I 247Interfacing a temperature sensor to the 8051
Transducers convert physical dal 41. 49.6, Thermistor Resistance
such as temperature, light intensity, 0, erature
and speed to electrical signals. Depending,
on the transducer, the output produced is ‘Temperature (C)__Tf(K ohms)
29.490
in the form of voltage, current, resistance, 9
or capacitance. For example, temperature 25 10.000
is converted to electrical signals using a 50 3.893
transducer called a thermistor. A thermis- 75 1,700
tor responds to temperature change by 700 0.817
but its response is From William Kleitz, Digital Electronics
changing resistan
not linear, as seen in Table 12-6.
‘Table 12-7, LM34 Temperature Sensor Series Selection Guide
Part ‘Temperature Range Accuracy Output
Scale
UM344, 50 F to 7300, +2.0 F 10 mViF,
LM34 =50 F to $300 F 43.0 F 10 mV/F
LM34CA___—40 F to #230 F 2.0F 10 mV/F
LM34C ~40 F to +230 F 43.0F 10 mV/F
LM34D F to +212 F +4.0F 10 mV/F
‘Note: Temperature range is in degrees Fahrenheit.
Table 12-8. LM35 Temperature Sensor Series Selection Guide
Part ‘Temperature Range Accuracy Output Scale
10 mV/F
C10 +150C 10 mV/F.
=40 Cto +110 C 10 mV/F
3 40 Cto H10.C 10 mV/F_
LM35D 0C to +100 C 10 mV/F
‘Note: Temperature range is in degrees Celsius
The complexity ass
devices has led many manu
Simple and widely used linear temperature sensors i
series from National Semiconductor Comp. They are oe Ng aS
re precision i ea
sors whose output voltage is linearly provoriai eel Aa ari sen-Signal conditioning and interfacing the LM35 to the 8051
* a scnY condhlecing is a widely used term in
transducers produce a Rie aie
Uutput in the form of voltage,
current, charge, capacitance, and resistance. However,
we need to convert these signals to voltage in order to
send input to an A-to-D converter, This conversion
(modification) is commonly called signal condition-
ing. Signal conditioning can be a current-to-voltage
conversion or a signal amplification, For example, the
thermistor changes resistance with temperature. The
change of resistance must be translated into voltages in
order to be of any use to an ADC. Look at the case of
connecting an LM35 to an ADC804. Since the
ADC804 has 8-bit resolution with a maximum of 256
(28) steps and the LM35 (or LM34) produces 10 mV
for every degree of temperature change, we can condi-
tion Vin of the ADC804 to produce a Voy, of 2560 mV
(2.56V) for full-scale output. Therefore, in order to
produce the full-scale Vou
aaa
Analog world
(temperature,
pressure, etc.)
t
Transducer
t
Signal
conditioning
t
‘ADC
i
Microcontroller
Figure 12-9, Getting Data
From the Analog World
! Vout of the ADC804
of 2.56 V for the ADCS04, Zable 12-9. Temperature v. Vout of the
we need to set Vre/2 = Temp. (C)__Vin (mV) _Vout (D7- D0)
1.28. This makes Voy of 9 0 a “
the ADC804 correspond 1 a “ft a
directly to the temperature 2 7 RCo
as monitored by the LM35. = oo emi
See Table 12-9. Vjg/2 valk 3 on a
ues are given in Table 12-5.
sv
8051 ADC804 ;
P25}—[RD__ Vee] M36 or
L [RO
xR p28 WR CLKR M34
CLK IN
XTAL2 P10} —+—]D0 28%
+] ‘Vin(+)|
Vin(-)
ae | Vreti2 &
P1.7}—<—]27 GND gin] 8
P2.7| Rn’ SS Set to
Leas fe PAT IINTR’ oc)
a
‘onnection to ADC804 and Temperature Sensor
249Figure 12-10 shows connection of a temperature sensor t0 the Apa
Notice that we use the LM336-2.5 zener diode to fix the voltage across the 10K
pot at 2.5 volts. The use of the LM336-2.5 should overcome any fluctuations in the
Power supply.
ADC808/809 chip with 8 analog channels
Another useful chip is the ADC808/809 from National Semiconductor. See
Figure 12-11. While the ADC804 has only one analog input, this chip has 8 of
them. The ADC808/809 chip allows us to monitor up to 8 different transducers
using only a single chip. Notice that the ADC808/809 has an 8-bit data output just
like the ADC804. The 8 analog input channels are multiplexed and selected
according to Table 12-10 using three address pins, A, B, and C.
INO —»[ GND Clock vee |» 00
= —
= =| anceosieos = E>
=| E>
IN7 3] = pv
—+|Wret(+) mae
—>|Vref(-) OE
SC ALEC BA
Pot tT tase
Figure 12-11, ADC808/809
Table 12-10: ADC808 Analog Channel Selection
Selected Analog Channel
2 G B A
INO 0 0 0
INI 0 0 1
IN2 0 1 0
INS, 0 1 1
IN4 1 0 0
INS, 1 0 1
ING 1 i 0
INT H T T
In the ADC808/809, V,.(+) and Vye(-) set the. reference voltage. If V,<;(-)
= Gnd and V,.(+) = 5 V, the step size is 5 V/256 = 19.53 mV. Therefore, to get a
activate ALE to latch in the address. $C i i a.
conversion, and OE is for output enable
gramming this chip,Steps to program the ADC808/809
The following are the steps to get data from analog input of ADC808/809
into the microcontroller,
1. Select an analog channel by providing bits to A, B, and C addresses according
to Table 12-10
2. Activate the ALE (address latch enable) pin. It needs an L-to-H pulse to latch
in the address,
3. Activate SC (start conversion) by an H-to-L pulse to initiate conversion.
4. Monitor EOC (end of conversion) to see whether conversion is finished. H-to-
| output indicates that the data is converted and is ready to be picked up.
5. Activate OE (output enable) to read data out of the ADC chip. An H-to-L pulse
to the OE pin will bring digital data out of the chip.
Notice in the ADC808/809 that there is no self-clocking and the clock must
be provided from an extemal source to the CLK pin, Although the speed of con-
version depends on the frequency of the clock connected to CLK pin, it cannot be
faster than 100 ms.
Review Questions
1, In the ADC804, the INTR signal is an (input, output).
2. To begin conversion, send a(n) pulse to pin J
3. Which pin of the ADC804 indicates end-of-conversion?
4. True o false. The transducer must be connected to signal conditioning circuit-
ry before it is sent to the ADC.
5. The LM35 provides mV for each degree of (Fahrenheit,
Celsius) temperature.
6. Both the ADC804 and ADC808 are _-bit converters.
7. Indicate the direction (out, in) for each of the following pins of the
ADC808/809,
(a) A,B,C (b) SC (c) EOC
SUMMARY
This chapter showed how to interface real-world devices such as LCDs,
ADC chips, and sensors, to the 8051. First, we described the operation modes of
LCDs, then described how to program the LCD by sending data or commands to
it via its interface to the 8051.
Next we explored ADC chips and temperature sensors. Gi
data from
the analog world to a digital device is called signal conditioning. Itis an essential
feature of data acquisition systems.
251