0% found this document useful (0 votes)
34 views

ADC Interfacing With 8051

interfacing

Uploaded by

snehanagar.skitm
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
34 views

ADC Interfacing With 8051

interfacing

Uploaded by

snehanagar.skitm
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 54

‰ General-purpose microprocessors

MICRO-
CONTROLLERS
contains
AND ¾ No RAM
EMBEDDED ¾ No ROM
PROCESSORS ¾ No I/O ports

Microcontroller
‰ Microcontroller has
vs. General- ¾ CPU (microprocessor)
Purpose ¾ RAM
Microprocessor ¾ ROM
¾ I/O ports
¾ Timer
¾ ADC and other peripherals

Department of Computer Science and Information Engineering


HANEL National Cheng Kung University, TAIWAN 3
Data bus
MICRO- General-
purpose
CONTROLLERS Micro-
Processor I/O Serial
AND RAM ROM
Port
Timer COM
Port
EMBEDDED
PROCESSORS CPU
Address bus

Microcontroller
vs. General-
Purpose Microcontroller
Microprocessor CPU RAM ROM
(cont’)

Serial
I/O Timer COM
Port

Department of Computer Science and Information Engineering


HANEL National Cheng Kung University, TAIWAN 4
‰ General-purpose microprocessors
MICRO-
¾ Must add RAM, ROM, I/O ports, and
CONTROLLERS timers externally to make them functional
AND ¾ Make the system bulkier and much more
EMBEDDED expensive
PROCESSORS ¾ Have the advantage of versatility on the
amount of RAM, ROM, and I/O ports
Microcontroller ‰ Microcontroller
vs. General- ¾ The fixed amount of on-chip ROM, RAM,
Purpose and number of I/O ports makes them ideal
Microprocessor for many applications in which cost and
(cont’) space are critical
¾ In many applications, the space it takes,
the power it consumes, and the price per
unit are much more critical considerations
than the computing power

Department of Computer Science and Information Engineering


HANEL National Cheng Kung University, TAIWAN 5
‰ Computers transfer data in two ways:
BASICS OF
SERIAL ¾ Parallel
COMMUNICA- ƒ Often 8 or more lines (wire conductors) are
used to transfer data to a device that is only a
TION few feet away
¾ Serial
ƒ To transfer to a device located many meters
away, the serial method is used
ƒ The data is sent one bit at a time

Serial Transfer Parallel Transfer


D0

Sender Receiver Sender Receiver

D7

Department of Computer Science and Information Engineering


HANEL National Cheng Kung University 2
‰ At the transmitting end, the byte of
BASICS OF data must be converted to serial bits
SERIAL using parallel-in-serial-out shift register
COMMUNICA-
TION ‰ At the receiving end, there is a serial-
(cont’) in-parallel-out shift register to receive
the serial data and pack them into byte
‰ When the distance is short, the digital
signal can be transferred as it is on a
simple wire and requires no modulation
‰ If data is to be transferred on the
telephone line, it must be converted
from 0s and 1s to audio tones
¾ This conversion is performed by a device
called a modem, “Modulator/demodulator”
Department of Computer Science and Information Engineering
HANEL National Cheng Kung University 3
‰ Serial data communication uses two
BASICS OF methods
SERIAL
¾ Synchronous method transfers a block of
COMMUNICA- data at a time
TION
(cont’)
¾ Asynchronous method transfers a single
byte at a time
‰ It is possible to write software to use
either of these methods, but the
programs can be tedious and long
¾ There are special IC chips made by many
manufacturers for serial communications
ƒ UART (universal asynchronous Receiver-
transmitter)
ƒ USART (universal synchronous-asynchronous
Receiver-transmitter)

Department of Computer Science and Information Engineering


HANEL National Cheng Kung University 4
‰ If data can be transmitted and received,
BASICS OF it is a duplex transmission
SERIAL ¾ If data transmitted one way a time, it is
COMMUNICA- referred to as half duplex
TION ¾ If data can go both ways at a time, it is full
duplex
Half- and Full- ‰ This is contrast to simplex transmission
Duplex
Transmission Simplex Transmitter Receiver

Transmitter Receiver
Half Duplex
Receiver Transmitter

Transmitter Receiver
Full Duplex
Receiver Transmitter

Department of Computer Science and Information Engineering


HANEL National Cheng Kung University 5
‰ A protocol is a set of rules agreed by
BASICS OF both the sender and receiver on
SERIAL ¾ How the data is packed
COMMUNICA- ¾ How many bits constitute a character
TION ¾ When the data begins and ends
‰ Asynchronous serial data
Start and Stop communication is widely used for
Bits character-oriented transmissions
¾ Each character is placed in between start
and stop bits, this is called framing
¾ Block-oriented data transfers use the
synchronous method
‰ The start bit is always one bit, but the
stop bit can be one or two bits

Department of Computer Science and Information Engineering


HANEL National Cheng Kung University 6
‰ The start bit is always a 0 (low) and the
BASICS OF stop bit(s) is 1 (high)
SERIAL
COMMUNICA- ASCII character “A” (8-bit binary 0100 0001)
TION

Start and Stop


Start Mark
Bits Space Stop 0 1 0 0 0 0 0 1 Bit
Bit
(cont’)
D7 D0

Goes out last Goes out first


The 0 (low) is
referred to as space The transmission begins with a
start bit followed by D0, the
LSB, then the rest of the bits When there is no
until MSB (D7), and finally, transfer, the signal
the one stop bit indicating the is 1 (high), which is
end of the character referred to as mark

Department of Computer Science and Information Engineering


HANEL National Cheng Kung University 7
‰ Due to the extended ASCII characters,
BASICS OF 8-bit ASCII data is common
SERIAL ¾ In older systems, ASCII characters were 7-
COMMUNICA- bit
TION ‰ In modern PCs the use of one stop bit
is standard
Start and Stop ¾ In older systems, due to the slowness of
Bits the receiving mechanical device, two stop
(cont’) bits were used to give the device sufficient
time to organize itself before transmission
of the next byte

Department of Computer Science and Information Engineering


HANEL National Cheng Kung University 8
‰ Assuming that we are transferring a
BASICS OF text file of ASCII characters using 1
SERIAL stop bit, we have a total of 10 bits for
COMMUNICA- each character
TION ¾ This gives 25% overhead, i.e. each 8-bit
character with an extra 2 bits
Start and Stop ‰ In some systems in order to maintain
Bits data integrity, the parity bit of the
(cont’) character byte is included in the data
frame
¾ UART chips allow programming of the
parity bit for odd-, even-, and no-parity
options

Department of Computer Science and Information Engineering


HANEL National Cheng Kung University 9
‰ The rate of data transfer in serial data
BASICS OF communication is stated in bps (bits per
SERIAL second)
COMMUNICA- ‰ Another widely used terminology for
TION bps is baud rate
¾ It is modem terminology and is defined as
Data Transfer the number of signal changes per second
Rate ¾ In modems, there are occasions when a
single change of signal transfers several
bits of data
‰ As far as the conductor wire is
concerned, the baud rate and bps are
the same, and we use the terms
interchangeably

Department of Computer Science and Information Engineering


HANEL National Cheng Kung University 10
‰ The data transfer rate of given
BASICS OF computer system depends on
SERIAL communication ports incorporated into
COMMUNICA- that system
TION ¾ IBM PC/XT could transfer data at the rate
of 100 to 9600 bps
Data Transfer ¾ Pentium-based PCs transfer data at rates as
Rate high as 56K bps
(cont’) ¾ In asynchronous serial data communication,
the baud rate is limited to 100K bps

Department of Computer Science and Information Engineering


HANEL National Cheng Kung University 11
‰ An interfacing standard RS232 was set
BASICS OF by the Electronics Industries Association
SERIAL (EIA) in 1960
COMMUNICA- ‰ The standard was set long before the
TION advent of the TTL logic family, its input
and output voltage levels are not TTL
RS232 compatible
Standards ¾ In RS232, a 1 is represented by -3 ~ -25 V,
while a 0 bit is +3 ~ +25 V, making -3 to
+3 undefined

Department of Computer Science and Information Engineering


HANEL National Cheng Kung University 12
RS232 DB-25 Pins
Pin Description Pin Description
BASICS OF 1 Protective ground 14 Secondary transmitted data

SERIAL 2 Transmitted data (TxD) 15 Transmitted signal element timing


3 Received data (RxD) 16 Secondary receive data
COMMUNICA- 4 Request to send (-RTS) 17 Receive signal element timing
TION 5 Clear to send (-CTS) 18 Unassigned
6 Data set ready (-DSR) 19 Secondary receive data
7 Signal ground (GND) 20 Data terminal ready (-DTR)
RS232 8 Data carrier detect (-DCD) 21 Signal quality detector
Standards 9/10 Reserved for data testing 22 Ring indicator (RI)

(cont’) 11 Unassigned 23 Data signal rate select


12 Secondary data carrier detect 24 Transmit signal element timing
13 Secondary clear to send 25 Unassigned

RS232 Connector DB-25

Department of Computer Science and Information Engineering


HANEL National Cheng Kung University 13
‰ Since not all pins are used in PC cables,
BASICS OF IBM introduced the DB-9 version of the
SERIAL serial I/O standard
COMMUNICA-
TION RS232 Connector DB-9 RS232 DB-9 Pins
Pin Description
RS232 1 Data carrier detect (-DCD)

Standards 2 Received data (RxD)


3 Transmitted data (TxD)
(cont’)
4 Data terminal ready (DTR)
5 Signal ground (GND)
6 Data set ready (-DSR)
7 Request to send (-RTS)
8 Clear to send (-CTS)
9 Ring indicator (RI)

Department of Computer Science and Information Engineering


HANEL National Cheng Kung University 14
‰ Current terminology classifies data
BASICS OF communication equipment as
SERIAL ¾ DTE (data terminal equipment) refers to
COMMUNICA- terminal and computers that send and
TION receive data
¾ DCE (data communication equipment)
Data refers to communication equipment, such
as modems
Communication
Classification
‰ The simplest connection between a PC
and microcontroller requires a minimum
of three pins, TxD, RxD, and ground
Null modem connection
DTE DTE
TxD TxD
RxD RxD

ground
Department of Computer Science and Information Engineering
HANEL National Cheng Kung University 15
‰ DTR (data terminal ready)
BASICS OF ¾ When terminal is turned on, it sends out
SERIAL signal DTR to indicate that it is ready for
COMMUNICA- communication
TION ‰ DSR (data set ready)
¾ When DCE is turned on and has gone
RS232 Pins through the self-test, it assert DSR to
indicate that it is ready to communicate
‰ RTS (request to send)
¾ When the DTE device has byte to transmit,
it assert RTS to signal the modem that it
has a byte of data to transmit
‰ CTS (clear to send)
¾ When the modem has room for storing the
data it is to receive, it sends out signal CTS
to DTE to indicate that it can receive the
data now
Department of Computer Science and Information Engineering
HANEL National Cheng Kung University 16
‰ DCD (data carrier detect)
BASICS OF ¾ The modem asserts signal DCD to inform
SERIAL the DTE that a valid carrier has been
COMMUNICA- detected and that contact between it and
TION the other modem is established
‰ RI (ring indicator)
RS232 Pins ¾ An output from the modem and an input to
(cont’) a PC indicates that the telephone is ringing
¾ It goes on and off in synchronous with the
ringing sound

Department of Computer Science and Information Engineering


HANEL National Cheng Kung University 17
‰ A line driver such as the MAX232 chip is
8051 required to convert RS232 voltage
CONNECTION levels to TTL levels, and vice versa
TO RS232 ‰ 8051 has two pins that are used
specifically for transferring and
receiving data serially
¾ These two pins are called TxD and RxD and
are part of the port 3 group (P3.0 and P3.1)
¾ These pins are TTL compatible; therefore,
they require a line driver to make them
RS232 compatible

Department of Computer Science and Information Engineering


HANEL National Cheng Kung University 18
‰ We need a line driver (voltage
8051 converter) to convert the R232’s signals
CONNECTION to TTL voltage levels that will be
TO RS232 acceptable to 8051’s TxD and RxD pins

MAX232 Vcc
C3
+
MAX232 requires
16 2 four capacitors
+
1 MAX232
C1
3 6 8051
4 C4
+
C2
+
MAX232
5 P3.1 11 11
TxD 14 2 5

T1in T1out
11 14
13 3
R1out R1in P3.0 10 12
12 13
RxD
T2in T2out
10 7
R2out R2int
DB-9
9 8

TTL side RS232 side


MAX232 has two
15
sets of line drivers

Department of Computer Science and Information Engineering


HANEL National Cheng Kung University 19
‰ To save board space, some designers
8051 use MAX233 chip from Maxim
CONNECTION ¾ MAX233 performs the same job as MAX232
TO RS232 but eliminates the need for capacitors
¾ Notice that MAX233 and MAX232 are not
MAX233 pin compatible
Vcc
13
7

14 MAX233 11

12
15
8051
16
17 MAX233
10 P3.1 11 2
TxD 5 2 5

T1in T1out
2 5
4 3
R1out R1in P3.0 10 3
3 4
RxD
T2in T2out
1 18
R2out R2int
DB-9
20 19

TTL side 6 9 RS232 side

Department of Computer Science and Information Engineering


HANEL National Cheng Kung University 20
‰ To allow data transfer between the PC
SERIAL and an 8051 system without any error,
COMMUNICA- we must make sure that the baud rate
TION of 8051 system matches the baud rate
PROGRAMMING of the PC’s COM port
‰ Hyperterminal function supports baud
rates much higher than listed below
PC Baud Rates
110
150
300
600
1200
2400
4800
9600
19200 Baud rates supported by
486/Pentium IBM PC BIOS
Department of Computer Science and Information Engineering
HANEL National Cheng Kung University 21
With XTAL = 11.0592 MHz, find the TH1 value needed to have the
following baud rates. (a) 9600 (b) 2400 (c) 1200
SERIAL Solution:
COMMUNICA- The machine cycle frequency of 8051 = 11.0592 / 12 = 921.6 kHz,
TION and 921.6 kHz / 32 = 28,800 Hz is frequency by UART to timer 1 to
set baud rate.
PROGRAMMING (a) 28,800 / 3 = 9600 where -3 = FD (hex) is loaded into TH1
(cont’) (b) 28,800 / 12 = 2400 where -12 = F4 (hex) is loaded into TH1
(c) 28,800 / 24 = 1200 where -24 = E8 (hex) is loaded into TH1
Notice that dividing 1/12 of the crystal frequency by 32 is the default
value upon activation of the 8051 RESET pin.
11.0592 MHz

Machine cycle freq 28800 Hz


XTAL ÷ 32
÷ 12
oscillator 921.6 kHz By UART To timer 1
To set the
Baud rate
Baud Rate TH1 (Decimal) TH1 (Hex)
9600 -3 FD
TF is set to 1 every 12 4800 -6 FA
ticks, so it functions as 2400 -12 F4
a frequency divider 1200 -24 E8

Department of Computer Science and Information Engineering


HANEL National Cheng Kung University 22
‰ SBUF is an 8-bit register used solely for
SERIAL serial communication
COMMUNICA- ¾ For a byte data to be transferred via the
TION TxD line, it must be placed in the SBUF
PROGRAMMING register
ƒ The moment a byte is written into SBUF, it is
framed with the start and stop bits and
SBUF Register transferred serially via the TxD line
¾ SBUF holds the byte of data when it is
received by 8051 RxD line
ƒ When the bits are received serially via RxD, the
8051 deframes it by eliminating the stop and
start bits, making a byte out of the data received,
and then placing it in SBUF

MOV SBUF,#’D’ ;load SBUF=44h, ASCII for ‘D’


MOV SBUF,A ;copy accumulator into SBUF
MOV A,SBUF ;copy SBUF into accumulator

Department of Computer Science and Information Engineering


HANEL National Cheng Kung University 23
‰ SCON is an 8-bit register used to
SERIAL program the start bit, stop bit, and data
COMMUNICA- bits of data framing, among other
TION things
PROGRAMMING
SM0 SM1 SM2 REN TB8 RB8 TI RI
SCON Register
SM0 SCON.7 Serial port mode specifier
SM1 SCON.6 Serial port mode specifier
SM2 SCON.5 Used for multiprocessor communication
REN SCON.4 Set/cleared by software to enable/disable reception
TB8 SCON.3 Not widely used
RB8 SCON.2 Not widely used
TI SCON.1 Transmit interrupt flag. Set by HW at the
begin of the stop bit mode 1. And cleared by SW
RI SCON.0 Receive interrupt flag. Set by HW at the
begin of the stop bit mode 1. And cleared by SW

Note: Make SM2, TB8, and RB8 =0

Department of Computer Science and Information Engineering


HANEL National Cheng Kung University 24
‰ SM0, SM1
SERIAL
COMMUNICA- ¾ They determine the framing of data by
TION specifying the number of bits per character,
PROGRAMMING and the start and stop bits
SM0 SM1
0 0 Serial Mode 0
SCON Register Serial Mode 1, 8-bit data,
0 1
(cont’) 1 stop bit, 1 start bit
1 0 Serial Mode 2
Only mode 1 is
1 1 Serial Mode 3
of interest to us
‰ SM2
¾ This enables the multiprocessing capability
of the 8051

Department of Computer Science and Information Engineering


HANEL National Cheng Kung University 25
‰ REN (receive enable)
¾ It is a bit-adressable register
SERIAL ƒ When it is high, it allows 8051 to receive data on
COMMUNICA- RxD pin
TION ƒ If low, the receiver is disable
PROGRAMMING ‰ TI (transmit interrupt)
¾ When 8051 finishes the transfer of 8-bit
SCON Register character
(cont’) ƒ It raises TI flag to indicate that it is ready to
transfer another byte
ƒ TI bit is raised at the beginning of the stop bit
‰ RI (receive interrupt)
¾ When 8051 receives data serially via RxD, it
gets rid of the start and stop bits and
places the byte in SBUF register
ƒ It raises the RI flag bit to indicate that a byte
has been received and should be picked up
before it is lost
ƒ RI is raised halfway through the stop bit
Department of Computer Science and Information Engineering
HANEL National Cheng Kung University 26
‰ In programming the 8051 to transfer
character bytes serially
SERIAL
1. TMOD register is loaded with the value
COMMUNICA- 20H, indicating the use of timer 1 in mode
TION 2 (8-bit auto-reload) to set baud rate
PROGRAMMING 2. The TH1 is loaded with one of the values
to set baud rate for serial data transfer
Programming 3. The SCON register is loaded with the value
Serial Data 50H, indicating serial mode 1, where an 8-
bit data is framed with start and stop bits
Transmitting
4. TR1 is set to 1 to start timer 1
5. TI is cleared by CLR TI instruction
6. The character byte to be transferred
serially is written into SBUF register
7. The TI flag bit is monitored with the use of
instruction JNB TI,xx to see if the
character has been transferred completely
8. To transfer the next byte, go to step 5
Department of Computer Science and Information Engineering
HANEL National Cheng Kung University 27
Write a program for the 8051 to transfer letter “A” serially at 4800
SERIAL baud, continuously.
COMMUNICA-
TION Solution:
MOV TMOD,#20H ;timer 1,mode 2(auto reload)
PROGRAMMING MOV TH1,#-6 ;4800 baud rate
MOV SCON,#50H ;8-bit, 1 stop, REN enabled
SETB TR1 ;start timer 1
Programming AGAIN: MOV SBUF,#”A” ;letter “A” to transfer
Serial Data HERE: JNB
CLR
TI,HERE
TI
;wait for the last bit
;clear TI for next char
Transmitting SJMP AGAIN ;keep sending A
(cont’)

Department of Computer Science and Information Engineering


HANEL National Cheng Kung University 28
Write a program for the 8051 to transfer “YES” serially at 9600
SERIAL baud, 8-bit data, 1 stop bit, do this continuously
COMMUNICA-
TION Solution:
MOV TMOD,#20H ;timer 1,mode 2(auto reload)
PROGRAMMING MOV TH1,#-3 ;9600 baud rate
MOV SCON,#50H ;8-bit, 1 stop, REN enabled
SETB TR1 ;start timer 1
Programming AGAIN: MOV A,#”Y” ;transfer “Y”
Serial Data ACALL TRANS
MOV A,#”E” ;transfer “E”
Transmitting ACALL TRANS
(cont’) MOV A,#”S” ;transfer “S”
ACALL TRANS
SJMP AGAIN ;keep doing it
;serial data transfer subroutine
TRANS: MOV SBUF,A ;load SBUF
HERE: JNB TI,HERE ;wait for the last bit
CLR TI ;get ready for next byte
RET

Department of Computer Science and Information Engineering


HANEL National Cheng Kung University 29
‰ The steps that 8051 goes through in
SERIAL transmitting a character via TxD
COMMUNICA- 1. The byte character to be transmitted is
TION written into the SBUF register
PROGRAMMING 2. The start bit is transferred
3. The 8-bit character is transferred on bit at
a time
Importance of 4. The stop bit is transferred
TI Flag ƒ It is during the transfer of the stop bit that
8051 raises the TI flag, indicating that the last
character was transmitted
5. By monitoring the TI flag, we make sure
that we are not overloading the SBUF
ƒ If we write another byte into the SBUF before
TI is raised, the untransmitted portion of the
previous byte will be lost
6. After SBUF is loaded with a new byte, the
TI flag bit must be forced to 0 by CLR TI
in order for this new byte to be transferred
Department of Computer Science and Information Engineering
HANEL National Cheng Kung University 30
‰ By checking the TI flag bit, we know
SERIAL whether or not the 8051 is ready to
COMMUNICA-
transfer another byte
TION
¾ It must be noted that TI flag bit is raised by
PROGRAMMING
8051 itself when it finishes data transfer
¾ It must be cleared by the programmer with
Importance of instruction CLR TI
TI Flag
(cont’) ¾ If we write a byte into SBUF before the TI
flag bit is raised, we risk the loss of a
portion of the byte being transferred
‰ The TI bit can be checked by
¾ The instruction JNB TI,xx
¾ Using an interrupt

Department of Computer Science and Information Engineering


HANEL National Cheng Kung University 31
‰ In programming the 8051 to receive
SERIAL character bytes serially
COMMUNICA- 1. TMOD register is loaded with the value
TION 20H, indicating the use of timer 1 in mode
PROGRAMMING 2 (8-bit auto-reload) to set baud rate
2. TH1 is loaded to set baud rate
Programming 3. The SCON register is loaded with the value
50H, indicating serial mode 1, where an 8-
Serial Data bit data is framed with start and stop bits
Receiving 4. TR1 is set to 1 to start timer 1
5. RI is cleared by CLR RI instruction
6. The RI flag bit is monitored with the use of
instruction JNB RI,xx to see if an entire
character has been received yet
7. When RI is raised, SBUF has the byte, its
contents are moved into a safe place
8. To receive the next character, go to step 5
Department of Computer Science and Information Engineering
HANEL National Cheng Kung University 32
Write a program for the 8051 to receive bytes of data serially, and
SERIAL put them in P1, set the baud rate at 4800, 8-bit data, and 1 stop bit
COMMUNICA-
TION Solution:
MOV TMOD,#20H ;timer 1,mode 2(auto reload)
PROGRAMMING MOV TH1,#-6 ;4800 baud rate
MOV SCON,#50H ;8-bit, 1 stop, REN enabled
SETB TR1 ;start timer 1
Programming HERE: JNB RI,HERE ;wait for char to come in
Serial Data MOV
MOV
A,SBUF
P1,A
;saving incoming byte in A
;send to port 1
Receiving CLR RI ;get ready to receive next
(cont’) ;byte
SJMP HERE ;keep getting data

Department of Computer Science and Information Engineering


HANEL National Cheng Kung University 33
Example 10-5
Assume that the 8051 serial port is connected to the COM port of
SERIAL IBM PC, and on the PC, we are using the terminal.exe program to
COMMUNICA- send and receive data serially. P1 and P2 of the 8051 are connected
to LEDs and switches, respectively. Write an 8051 program to (a)
TION send to PC the message “We Are Ready”, (b) receive any data send
PROGRAMMING by PC and put it on LEDs connected to P1, and (c) get data on
switches connected to P2 and send it to PC serially. The program
should perform part (a) once, but parts (b) and (c) continuously, use
Programming 4800 baud rate.
Serial Data
Receiving Solution:
ORG 0
(cont’) MOV P2,#0FFH ;make P2 an input port
MOV TMOD,#20H ;timer 1, mode 2
MOV TH1,#0FAH ;4800 baud rate
MOV SCON,#50H ;8-bit, 1 stop, REN enabled
SETB TR1 ;start timer 1
MOV DPTR,#MYDATA ;load pointer for message
H_1: CLR A
MOV A,@A+DPTR ;get the character
...

Department of Computer Science and Information Engineering


HANEL National Cheng Kung University 34
Example 10-5 (cont’)

SERIAL JZ B_1 ;if last character get out


COMMUNICA- ACALL SEND
INC DPTR
;otherwise call transfer
;next one
TION SJMP H_1 ;stay in loop
PROGRAMMING B_1: MOV a,P2
ACALL SEND
;read data on P2
;transfer it serially
ACALL RECV ;get the serial data
Programming MOV P1,A
SJMP B_1
;display it on LEDs
;stay in loop indefinitely
Serial Data ;----serial data transfer. ACC has the data------
Receiving SEND: MOV SBUF,A ;load the data
H_2: JNB TI,H_2 ;stay here until last bit
(cont’) ;gone
CLR TI ;get ready for next char
RET ;return to caller
;----Receive data serially in ACC----------------
RECV: JNB RI,RECV ;wait here for char
MOV A,SBUF ;save it in ACC
CLR RI ;get ready for next char
RET ;return to caller
...

Department of Computer Science and Information Engineering


HANEL National Cheng Kung University 35
Example 10-5 (cont’)
SERIAL
COMMUNICA- ;-----The message---------------
TION
MYDATA: DB “We Are Ready”,0
END
PROGRAMMING
8051
LED
Programming To PC TxD
P1

Serial Data
Receiving COM Port RxD
P2 SW
(cont’)

Department of Computer Science and Information Engineering


HANEL National Cheng Kung University 36
‰ In receiving bit via its RxD pin, 8051
SERIAL goes through the following steps
COMMUNICA-
1. It receives the start bit
TION
ƒ Indicating that the next bit is the first bit of the
PROGRAMMING character byte it is about to receive
2. The 8-bit character is received one bit at
Importance of time
RI Flag 3. The stop bit is received
ƒ When receiving the stop bit 8051 makes RI = 1,
indicating that an entire character byte has
been received and must be picked up before it
gets overwritten by an incoming character

Department of Computer Science and Information Engineering


HANEL National Cheng Kung University 37
(cont’)
SERIAL 4. By checking the RI flag bit when it is
COMMUNICA- raised, we know that a character has been
TION received and is sitting in the SBUF register
PROGRAMMING ƒ We copy the SBUF contents to a safe place in
some other register or memory before it is lost

Importance of 5. After the SBUF contents are copied into a


safe place, the RI flag bit must be forced
RI Flag to 0 by CLR RI in order to allow the next
(cont’)
received character byte to be placed in
SBUF
ƒ Failure to do this causes loss of the received
character

Department of Computer Science and Information Engineering


HANEL National Cheng Kung University 38
‰ By checking the RI flag bit, we know
SERIAL whether or not the 8051 received a
COMMUNICA- character byte
TION ¾ If we failed to copy SBUF into a safe place,
PROGRAMMING we risk the loss of the received byte
¾ It must be noted that RI flag bit is raised by
Importance of 8051 when it finish receive data
RI Flag ¾ It must be cleared by the programmer with
(cont’)
instruction CLR RI
¾ If we copy SBUF into a safe place before
the RI flag bit is raised, we risk copying
garbage
‰ The RI bit can be checked by
¾ The instruction JNB RI,xx
¾ Using an interrupt

Department of Computer Science and Information Engineering


HANEL National Cheng Kung University 39
‰ There are two ways to increase the
SERIAL
COMMUNICA- baud rate of data transfer The system
crystal is fixed
TION ¾ To use a higher frequency crystal
PROGRAMMING ¾ To change a bit in the PCON register
‰ PCON register is an 8-bit register
Doubling Baud
Rate ¾ When 8051 is powered up, SMOD is zero
¾ We can set it to high by software and
thereby double the baud rate
SMOD -- -- -- GF1 GF0 PD IDL

It is not a bit- MOV A,PCON ;place a copy of PCON in ACC


addressable SETB ACC.7 ;make D7=1
MOV PCON,A ;changing any other bits
register

Department of Computer Science and Information Engineering


HANEL National Cheng Kung University 40
SERIAL 11.0592 MHz SMOD = 1 57600 Hz
÷ 16
COMMUNICA- XTAL
Machine cycle freq To timer
1 To set
TION oscillator
÷ 12
921.6 kHz 28800 Hz the Baud
÷ 32 rate
PROGRAMMING SMOD = 0

Doubling Baud Baud Rate comparison for SMOD=0 and SMOD=1


Rate
TH1 (Decimal) (Hex) SMOD=0 SMOD=1
(cont’)
-3 FD 9600 19200
-6 FA 4800 9600
-12 F4 2400 4800
-24 E8 1200 2400

Department of Computer Science and Information Engineering


HANEL National Cheng Kung University 41
Example 10-6
SERIAL Assume that XTAL = 11.0592 MHz for the following program,
COMMUNICA- state (a) what this program does, (b) compute the frequency used
by timer 1 to set the baud rate, and (c) find the baud rate of the data
TION transfer.
PROGRAMMING
MOV A,PCON ;A=PCON
MOV ACC.7 ;make D7=1
Doubling Baud MOV PCON,A ;SMOD=1, double baud rate
Rate MOV TMOD,#20H
;with same XTAL freq.
;timer 1, mode 2
(cont’) MOV TH1,-3 ;19200 (57600/3 =19200)
MOV SCON,#50H ;8-bit data, 1 stop bit, RI
;enabled
SETB TR1 ;start timer 1
MOV A,#”B” ;transfer letter B
A_1: CLR TI ;make sure TI=0
MOV SBUF,A ;transfer it
H_1: JNB TI,H_1 ;stay here until the last
;bit is gone
SJMP A_1 ;keep sending “B” again

Department of Computer Science and Information Engineering


HANEL National Cheng Kung University 42
Example 10-6 (cont’)

SERIAL Solution:
COMMUNICA- (a) This program transfers ASCII letter B (01000010
binary) continuously
TION (b) With XTAL = 11.0592 MHz and SMOD = 1 in the
PROGRAMMING above program, we have:

11.0592 / 12 = 921.6 kHz machine cycle frequency.


Doubling Baud 921.6 / 16 = 57,600 Hz frequency used by timer 1
to set the baud rate.
Rate 57600 / 3 = 19,200, the baud rate.
(cont’)
Find the TH1 value (in both decimal and hex ) to set the baud rate
to each of the following. (a) 9600 (b) 4800 if SMOD=1. Assume
that XTAL 11.0592 MHz

Solution:
With XTAL = 11.0592 and SMOD = 1, we have timer frequency =
57,600 Hz.
(a) 57600 / 9600 = 6; so TH1 = -6 or TH1 = FAH
(b) 57600 / 4800 = 12; so TH1 = -12 or TH1 = F4H

Department of Computer Science and Information Engineering


HANEL National Cheng Kung University 43
Example 10-8
SERIAL Find the baud rate if TH1 = -2, SMOD = 1, and XTAL = 11.0592
COMMUNICA- MHz. Is this baud rate supported by IBM compatible PCs?

TION Solution:
PROGRAMMING With XTAL = 11.0592 and SMOD = 1, we have timer frequency =
57,600 Hz. The baud rate is 57,600/2 = 28,800. This baud rate is
not supported by the BIOS of the PCs; however, the PC can be
Doubling Baud programmed to do data transfer at such a speed. Also,
Rate HyperTerminal in Windows supports this and other baud rates.
(cont’)

Department of Computer Science and Information Engineering


HANEL National Cheng Kung University 44
Example 10-10
Write a program to send the message “The Earth is but One
SERIAL Country” to serial port. Assume a SW is connected to pin P1.2.
COMMUNICA- Monitor its status and set the baud rate as follows:
SW = 0, 4800 baud rate
TION SW = 1, 9600 baud rate
PROGRAMMING Assume XTAL = 11.0592 MHz, 8-bit data, and 1 stop bit.

Solution:
Doubling Baud SW BIT P1.2
Rate MAIN:
ORG 0H ;starting position

(cont’) MOV TMOD,#20H


MOV TH1,#-6 ;4800 baud rate (default)
MOV SCON,#50H
SETB TR1
SETB SW ;make SW an input
S1: JNB SW,SLOWSP ;check SW status
MOV A,PCON ;read PCON
SETB ACC.7 ;set SMOD high for 9600
MOV PCON,A ;write PCON
SJMP OVER ;send message
.....

Department of Computer Science and Information Engineering


HANEL National Cheng Kung University 45
.....
SERIAL
COMMUNICA- SLOWSP:
MOV A,PCON ;read PCON
TION SETB ACC.7 ;set SMOD low for 4800
MOV PCON,A ;write PCON
PROGRAMMING OVER: MOV DPTR,#MESS1 ;load address to message
FN: CLR A
MOVC A,@A+DPTR ;read value
Doubling Baud JZ S1 ;check for end of line
ACALL SENDCOM ;send value to serial port
Rate INC DPTR ;move to next value
(cont’) SJMP FN ;repeat
;------------
SENDCOM:
MOV SBUF,A ;place value in buffer
HERE: JNB TI,HERE ;wait until transmitted
CLR TI ;clear
RET ;return

;------------
MESS1: DB “The Earth is but One Country”,0
END

Department of Computer Science and Information Engineering


HANEL National Cheng Kung University 46
LCD Timing
‰ One can put data at any location in the
INTERFACING INTERFACING
LCD TO 8051
LCD and the following shows address LCD TO 8051
tDSW = Data set up time
= 195 ns (minimum)
locations and how they are accessed Data
LCD Data RS R/W DB7 DB6 DB5 DB4 DB3 DB2 DB1 DB0 LCD Data tH = Data hold time
Sheet Sheet
tH = 10 ns (minimum)
0 0 1 A A A A A A A E tDSW

(cont’)
R/W tAS tPWH tAH

¾ AAAAAAA=000_0000 to 010_0111 for line1


RS
¾ AAAAAAA=100_0000 to 110_0111 for line2 tAH = Hold time after E has
The upper address
come down for both RS and
range can go as LCD Addressing for the LCDs of 40×2 size
R/W = 10 ns (minimum)
high as 0100111
DB7 DB6 DB5 DB4 DB3 DB2 DB1 DB0
for the 40- tPWH = Enable pulse width
character-wide Line1 (min) 1 0 0 0 0 0 0 0 = 450 ns (minimum)
LCD, which Line1 (max) 1 0 1 0 0 1 1 1
tAS = Set up time prior to E
corresponds to Line2 (min) 1 1 0 0 0 0 0 0 (going high) for both RS and
locations 0 to 39 Line2 (max) 1 1 1 0 0 1 1 1 R/W = 140 ns (minimum)

Department of Computer Science and Information Engineering Department of Computer Science and Information Engineering
HANEL National Cheng Kung University 9
HANEL National Cheng Kung University 10

‰ ADCs (analog-to-digital converters) are ‰ ADC804 IC is an analog-to-digital


INTERFACING INTERFACING
TO ADC AND
among the most widely used devices TO ADC AND
converter
SENSORS for data acquisition SENSORS ¾ It works with +5 volts and has a resolution
¾ A physical quantity, like temperature, of 8 bits
ADC Devices pressure, humidity, and velocity, etc., is ADC804 Chip ¾ Conversion time is another major factor in
converted to electrical (voltage, current) judging an ADC
signals using a device called a transducer, ƒ Conversion time is defined as the time it takes
or sensor the ADC to convert the analog input to a digital
(binary) number
‰ We need an analog-to-digital converter ƒ In ADC804 conversion time varies depending on
to translate the analog signals to digital the clocking signals applied to CLK R and CLK IN
numbers, so microcontroller can read pins, but it cannot be faster than 110 µs

them

Department of Computer Science and Information Engineering Department of Computer Science and Information Engineering
HANEL National Cheng Kung University 11
HANEL National Cheng Kung University 12

3
+5V power supply

CLK IN and CLK R


or a reference
voltage when ‰
INTERFACING Differential analog
+5V INTERFACING
CLK IN is an input pin connected to an
Vref/2 input is open
¾
TO ADC AND inputs where Vin 20 (not connected) TO ADC AND
SENSORS
= Vin (+) – Vin (-) 10k
POT
6 Vin(+)
VCC
D0 18
SENSORS external clock source
Vin (-) is connected 7 D1 17
To use the internal clock generator
Vin(-)
8 D2 16 ¾
to ground and Vin A GND 15
9 D3
ADC804 Chip (+) is used as the
19
Vref /2
D4 14
13
To LEDs
ADC804 Chip (also called self-clocking), CLK IN and
analog input to be CLK R D5
(cont’) converted 10k D6
D7
12
11 (cont’) CLK R pins are connected to a capacitor
150 pF
4 CLK in 3
and a resistor, and the clock frequency
CS is an active low WR
INTR 5
+5V is determined by
1
input used to activate 1 CS normally
ADC804 2 RD open 20
f =
1.1 RC
VCC
10 D GND START 6 Vin(+) D0 18
7 D1 17
Vin(-)
ƒ Typical values are R = 10K ohms and C =
8 16
A GND D2
“output enable” 9 Vref /2 D3
15
14
a high-to-low RD pulse is
“end of conversion” “start conversion”
19
CLK R
D4
D5 13
12
150 pF
D6
used to get the 8-bit
ƒ We get f = 606 kHz and the conversion time
D7 11
When the conversion is When WR makes a low-to-
converted data out of 4
is 110 µs
high transition, ADC804 CLK in 3
finished, it goes low to signal WR
ADC804 starts converting the analog INTR 5
the CPU that the converted 1 CS
2 RD
data is ready to be picked up input value of Vin to an 8- 10 D GND
bit digital number

Department of Computer Science and Information Engineering Department of Computer Science and Information Engineering
HANEL National Cheng Kung University 13
HANEL National Cheng Kung University 14

‰ Vref/2 ‰ D0-D7
INTERFACING INTERFACING
TO ADC AND ¾ It is used for the reference voltage TO ADC AND ¾ The digital data output pins
ƒ If this pin is open (not connected), the analog These are tri-state buffered
SENSORS SENSORS ¾
input voltage is in the range of 0 to 5 volts (the
ƒ The converted data is accessed only when CS =
same as the Vcc pin)
ADC804 Chip ADC804 Chip 0 and RD is forced low
ƒ If the analog input range needs to be 0 to 4
(cont’) volts, Vref/2 is connected to 2 volts (cont’) ¾ To calculate the output voltage, use the
following formula
Vref/2 Relation to Vin Range
V in
D out =
+5V +5V
Vref/2(v) Vin(V) Step Size ( mV)
6 Vin(+)
20
VCC
18 Not connected* 0 to 5 5/256=19.53 6 Vin(+)
20
VCC
D0 18
step size
D0
7 D1 17 7 D1 17
Vin(-)
2.0 0 to 4 4/255=15.62 Vin(-)
8
9
A GND
Vref /2
D2
D3
16
15
8
9
A GND
Vref /2
D2
D3
16
15 ƒ Dout = digital data output (in decimal),
14 1.5 0 to 3 3/256=11.71 D4 14
ƒ Vin = analog voltage, and
19 D4 19
13 13
CLK R D5
12
CLK R D5 12
D6
11 1.28 0 to 2.56 2.56/256=10 D6 11
ƒ step size (resolution) is the smallest change
D7 D7
4 CLK in
WR
3 1.0 0 to 2 2/256=7.81 4 CLK in
WR
3

INTR 5 INTR 5
1 CS 0.5 0 to 1 1/256=3.90 1 CS
2 RD 2 RD
10 10
D GND Step size is the smallest change can be discerned by an ADC D GND

Department of Computer Science and Information Engineering Department of Computer Science and Information Engineering
HANEL National Cheng Kung University 15
HANEL National Cheng Kung University 16

4
‰ The following steps must be followed
‰ Analog ground and digital ground
INTERFACING INTERFACING for data conversion by the ADC804 chip
¾ Analog ground is connected to the ground
TO ADC AND TO ADC AND ¾ Make CS = 0 and send a low-to-high pulse
of the analog Vin to pin WR to start conversion
SENSORS SENSORS
¾ Digital ground is connected to the ground ¾ Keep monitoring the INTR pin
of the Vcc pin ƒ If INTR is low, the conversion is finished
ADC804 Chip ADC804 Chip ƒ If the INTR is high, keep polling until it goes low
(cont’) ‰ To isolate the analog Vin signal from (cont’) ¾ After the INTR has become low, we make
transient voltages caused by digital CS = 0 and send a high-to-low pulse to the
+5V switching of the output D0 – D7 RD pin to get the data out of the ADC804
6 Vin(+)
20
VCC
18
¾ This contributes to the accuracy of the CS

digital data output


D0
7 D1 17
Vin(-)
8 16
A GND D2 15
9 D3
Vref /2
D4 14 WR
19 13
CLK R D5
12
D6
D7 11 D0-D7 Data out
End conversion
4 CLK in
WR
3 INTR
1 INTR 5 Start conversion
CS
2 RD RD
10
D GND
CS is set to low for both Read it
RD and WR pulses
Department of Computer Science and Information Engineering Department of Computer Science and Information Engineering
HANEL National Cheng Kung University 17
HANEL National Cheng Kung University 18

The binary outputs are


ADC804 Free Running Test Mode Examine the ADC804 connection to the 8051 in Figure 12-7. Write a program to
monitored on the LED monitor the INTR pin and bring an analog input into register A. Then call a
INTERFACING +5V of the digital trainer INTERFACING hex-to ACSII conversion and data display subroutines. Do this continuously.
TO ADC AND 10k
20
VCC
TO ADC AND ;p2.6=WR (start conversion needs to L-to-H pulse)
SENSORS SENSORS
6 Vin(+) 18 ;p2.7 When low, end-of-conversion)
POT D0
7 Vin(-) D1 17
16 ;p2.5=RD (a H-to-L will read the data from ADC chip)
8 A GND D2
9 D3 15 ;p1.0 – P1.7= D0 - D7 of the ADC804
Vref /2 To LEDs
Testing 19
CLK R
D4
D5
14
13 Testing ;
MOV P1,#0FFH ;make P1 = input
ADC804 ADC804
D6 12
10k 11 BACK: CLR P2.6 ;WR = 0
150 pF D7
4 CLK in 3
(cont’) SETB P2.6 ;WR = 1 L-to-H to start conversion
WR HERE: JB P2.7,HERE ;wait for end of conversion
1 CS INTR 5 normally CLR P2.5 ;conversion finished, enable RD
2 RD open MOV A,P1 ;read the data
10 D GND START ACALL CONVERSION ;hex-to-ASCII conversion
ACALL DATA_DISPLAY;display the data
SETB p2.5 ;make RD=1 for next round
The CS input is SJMP BACK
a potentiometer used to
grounded and the
apply a 0-to-5 V analog
WR input is
voltage to input Vin (+)
connected to the
of the 804 ADC
INTR output

Department of Computer Science and Information Engineering Department of Computer Science and Information Engineering
HANEL National Cheng Kung University 19
HANEL National Cheng Kung University 20

5
INTERFACING 8051 Connection to ADC804 with Self-Clocking INTERFACING 8051 Connection to ADC804 with Clock from XTAL2 of 8051
TO ADC AND TO ADC AND
SENSORS 8051 ADC804 5V
SENSORS 8051 ADC804 5V

P2.5 RD VCC VCC


10k 150 pF XTAL1 P2.5 RD
Testing P2.6 WR CLK R ADC804 Clock P2.6 WR
CLK in
CLK in
ADC804 from 8051
XTAL2 CLK R
P1.0 D0 10k P1.0 D0 10k
D1 Vin (+) Vin (+)
(cont’) D2
POT
XTAL2
D1
D2
POT
D3 Vin (-) Vin (-)
D Q D3
D4 Vref /2 D4 Vref /2
D5 D5
D6 CS D6 CS
P1.7 D7 Q P1.7 D7
D GND GND
P2.7 INTR A GND P2.7 INTR A GND

D Q

The frequency of crystal is too


Q
high, we use two D flip-flops
74LS74 to divide the frequency by 4

Department of Computer Science and Information Engineering Department of Computer Science and Information Engineering
HANEL National Cheng Kung University 21
HANEL National Cheng Kung University 22

‰ A thermistor responds to temperature ‰ The sensors of the LM34/LM35 series


INTERFACING change by changing resistance, but its INTERFACING are precision integrated-circuit
TO ADC AND TO ADC AND temperature sensors whose output
response is not linear
SENSORS SENSORS
‰ The complexity associated with writing voltage is linearly proportional to the
software for such nonlinear devices has Fahrenheit/Celsius temperature
Interfacing LM34 and LM35
Temperature led many manufacturers to market the Temperature ¾ The LM34/LM35 requires no external
linear temperature sensor calibration since it is inherently calibrated
Sensor Sensors
¾ It outputs 10 mV for each degree of
Temperature (C) Tf (K ohms) Fahrenheit/Celsius temperature
0 29.490
25 10.000
50 3.893
75 1.700
100 0.817
From William Kleitz, digital Electronics

Department of Computer Science and Information Engineering Department of Computer Science and Information Engineering
HANEL National Cheng Kung University 23
HANEL National Cheng Kung University 24

6
‰ Signal conditioning is a widely used
INTERFACING term in the world of data acquisition INTERFACING Getting Data From the Analog World
TO ADC AND TO ADC AND
¾ It is the conversion of the signals (voltage, Analog world (temperature,
SENSORS current, charge, capacitance, and SENSORS pressure, etc. )
resistance) produced by transducers to
Signal voltage, which is sent to the input of an A- Signal
Transducer
Conditioning to-D converter Conditioning
and ‰ Signal conditioning can be a current-to- and
Interfacing voltage conversion or a signal Interfacing Signal conditioning
LM35 LM35
amplification (cont’)
¾ The thermistor changes resistance with ADC
temperature, while the change of
resistance must be translated into voltage
in order to be of any use to an ADC Microcontroller

Department of Computer Science and Information Engineering Department of Computer Science and Information Engineering
HANEL National Cheng Kung University 25
HANEL National Cheng Kung University 26

Example:

INTERFACING Look at the case of connecting an LM35 to an ADC804. Since the INTERFACING 8051 Connection to ADC804 and Temperature Sensor
ADC804 has 8-bit resolution with a maximum of 256 steps and the
TO ADC AND LM35 (or LM34) produces 10 mV for every degree of temperature
TO ADC AND 8051 ADC804 5V
SENSORS change, we can condition Vin of the ADC804 to produce a Vout of SENSORS VCC
2560 mV full-scale output. Therefore, in order to produce the full- XTAL1 P2.5 RD
CLK in
scale Vout of 2.56 V for the ADC804, We need to set Vref/2 = 1.28. WR
Signal Signal
P2.6 LM35 or
XTAL2 CLK R LM34
This makes Vout of the ADC804 correspond directly to the P1.0
Conditioning Conditioning
D0
temperature as monitored by the LM35. D1 Vin (+) 2.5k

and and
D2
D3 Vin (-)
D Q
Interfacing Interfacing
Temperature vs. Vout of the ADC804 D4 A GND
D5 10k

LM336
D6 Vref /2
LM35 Temp. (C) Vin (mV) Vout (D7 – D0) LM35 Q P1.7 D7
CS
Set to 1.28 V
(cont’) 0 0 0000 0000 (cont’) P2.7 INTR GND
1 10 0000 0001 Q
D
2 20 0000 0010
3 30 0000 0011 Q Notice that we use the LM336-2.5 zener diode to
fix the voltage across the 10K pot at 2.5 volts.
10 100 0000 1010
74LS74 The use of the LM336-2.5 should overcome any
30 300 0001 1110 fluctuations in the power supply
Department of Computer Science and Information Engineering Department of Computer Science and Information Engineering
HANEL National Cheng Kung University 27
HANEL National Cheng Kung University 28

7
‰ ADC808 has 8 analog inputs
INTERFACING INTERFACING
TO ADC AND ¾ It allows us to monitor up to 8 different TO ADC AND
SENSORS transducers using only a single chip SENSORS
ADC808/809

¾ The chip has 8-bit data output just like the


IN0 D0
ADC808/809 ADC804 ADC808/809
GND Clock Vcc

Chip ¾ The 8 analog input channels are Chip


multiplexed and selected according to table (cont’)
IN7
ADC808/809
below using three address pins, A, B, and C
D7

Vref(+) EOC
ADC808 Analog Channel Selection
Vref(-) OE
Selected Analog Channel C B A SC ALE C B A
IN0 0 0 0
(LSB)
IN1 0 0 1
IN2 0 1 0
IN3 0 1 1
IN4 1 0 0
IN5 1 0 1
IN6 Science and Information
Department of Computer 1 1 Engineering
0 Department of Computer Science and Information Engineering
HANEL National Cheng KungIN7
University 1 1 1 29
HANEL National Cheng Kung University 30

1. Select an analog channel by providing


INTERFACING bits to A, B, and C addresses
TO ADC AND
SENSORS 2. Activate the ALE pin
¾ It needs an L-to-H pulse to latch in the
Steps to address
Program 3. Activate SC (start conversion ) by an
ADC808/809 H-to-L pulse to initiate conversion
4. Monitor EOC (end of conversion) to
see whether conversion is finished
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

Department of Computer Science and Information Engineering


HANEL National Cheng Kung University 31

You might also like