Académique Documents
Professionnel Documents
Culture Documents
Serial Communication
Virendra Singh
Associate Professor
Computer Architecture and Dependable Systems Lab
Department of Electrical Engineering
Indian Institute of Technology Bombay
http://www.ee.iitb.ac.in/~viren/
E-mail: viren@ee.iitb.ac.in
EE-309: Microprocessors
Lecture
15
(20
Aug
2014)
CADSL
8051
Pin
Diagram
P1.0
P1.1
P1.2
P1.3
P1.4
P1.5
P1.6
P1.7
RST
(RXD)P3.0
(TXD)P3.1
(INT0)P3.2
(INT1)P3.3
(T0)P3.4
(T1)P3.5
(WR)P3.6
(RD)P3.7
XTAL2
XTAL1
GND
20 Aug 2014
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
EE-309@IITB
8051
(8031)
(8751)
(8951)
40
39
38
37
36
35
34
33
32
31
30
29
28
27
26
25
24
23
22
21
Vcc
P0.0(AD0
)P0.1(AD1)
P0.2(AD2
)P0.3(AD3)
P0.4(AD4)
P0.5(AD5)
P0.6(AD6)
P0.7(AD7)
EA/VPP
ALE/PROG
PSEN
P2.7(A15)
P2.6(A14
)P2.5(A13
)P2.4(A12
)P2.3(A11)
P2.2(A10)
P2.1(A9)
P2.0(A8)
CADSL
Serial
Communication
20 Aug 2014
EE-309@IITB
CADSL
RS232 Standard
RS232
is
an
interfacing
standard
which
is
set
by
the
Electronics
Industries
AssociaCon
(EIA)
in
1960.
RS232
is
the
most
widely
used
serial
I/O
interfacing
standard.
RS232A
(1963),
RS232B
(1965)
and
RS232C
(1969),
now
is
RS232E
EE-309@IITB
CADSL
EE-309@IITB
RS 232 Voltage
25V
logic 0
3V
-3V
undefined
logic 1
-25V
5
CADSL
MAX232
MAX232
IC
chips
are
commonly
referred
to
as
line
drivers.
RS232
PC
COM 1 port
TTL voltage
level
20 Aug 2014
8051
MAX232
RS232 voltage
level
EE-309@IITB
UART
TTL voltage
level
CADSL
13
14
25
20 Aug 2014
Pin
1
2
3
4
5
6
7
8
9/10
11
12
13
Descrip+on
ProtecCve
ground
TransmiWed
data
(TxD)
Received
data
(RxD)
Request
to
send
(RTS)
Clear
to
send
(CTS)
Data
set
ready
(DSR)
Signal
ground
(GND)
Data
carrier
detect
(DCD)
Reserved
for
data
tesCng
Unassigned
Secondary
data
carrier
detect
Secondary
clear
to
send
EE-309@IITB
CADSL
13
14
25
20 Aug 2014
Pin
14
15
16
Descrip+on
Secondary
transmiWed
data
Transmit
signal
element
Cming
Secondary
received
data
17
18
19
20
21
22
23
24
25
EE-309@IITB
CADSL
20 Aug 2014
Pin
Descrip+on
CADSL
EE-309@IITB
10
CADSL
Communication Flow
PC (DTE)
modem (DCE)
Telephone
is
ringing
ConnecCon
between
two
modems
is
set
PC
is
ready
modem
is
ready
PC
wants
to
sent
data
modem
is
ready
to
receive
transmit
data
RI
DCD
DTR
DSR
RTS
CTS
TxD, RxD
20 Aug 2014
EE-309@IITB
11
CADSL
DCE view
DTE
DCE
DCE
TxD
RxD
RxD
TxD
PC GND
Com1
Telephone
Line
GND
modem
20 Aug 2014
DTE
RxD
TxD
TxD
RxD
GND
modem
EE-309@IITB
GND
PC Com1
12
CADSL
DTE view
DTE view
RS232
PC
COM 1 port
20 Aug 2014
8051
MAX232
EE-309@IITB
UART
13
CADSL
DTE
DTE
DTE
TxD
TxD
TxD
TxD
RxD
RxD
RxD
RxD
ground
PC
Com1
20 Aug 2014
8051based
board
PC
Com1
EE-309@IITB
ground
14
PC
Com1
CADSL
20 Aug 2014
EE-309@IITB
15
CADSL
MAX232
MAX232
chip
converts
from
RS232
voltage
levels
to
TTL
voltage
levels,
and
vice
versa.
MAX232
uses
a
+5V
power
source
which
is
the
same
as
the
source
voltage
for
the
8051.
8051
MAX232
P3.1
TxD
11
11
P3.0
RxD
10
12
14
2 7
13
3
DB-25
20 Aug 2014
EE-309@IITB
16
CADSL
MAX 232
MAX232
has
two
sets
of
line
drivers.
MAX232
requires
four
capacitors
ranging
from
1
to
22
mF.
The
most
widely
used
value
for
these
capacitors
is
22mF.
20 Aug 2014
EE-309@IITB
17
CADSL
Inside MAX232
Vcc
+
C1
+
C2
11
12
10
9
TTL side
20 Aug 2014
1
3
4
C3
16
MAX232
6
C4
+
5
T1IN
T1OUT
R1IN
R1OUT
T2IN
T2OUT
R2IN
R2OUT
15
EE-309@IITB
14
13
7
8
RS232 side
18
CADSL
11
P3.0
RxD
10
11
12
14
13
DB-25
TTL-compatible
20 Aug 2014
RS232-compatible
EE-309@IITB
19
CADSL
Inside MAX233
Vcc
13
11
14
MAX233
12
17
2
3
1
20
TTL side
20 Aug 2014
15
16
10
T1IN
T1OUT
R1IN
R1OUT
T2IN
T2OUT
R2IN
R2OUT
EE-309@IITB
5
4
18
19
RS232 side
20
CADSL
11
10
TTL-compatible
20 Aug 2014
DB-25
RS232-compatible
EE-309@IITB
21
CADSL
PC Baud Rates
PC
supports
several
baud
rates.
You
can
use
neWerm,
terminal.exe,
sWy,
pWy
to
send/receive
data.
Hyperterminal
supports
baud
rates
much
higher
than
the
ones
list
in
the
Table.
110
bps
150
300
600
1200
2400
4800
9600
(default)
19200
Note:
Baud
rates
supported
by
486/PenCum
IBM
PC
BIOS.
20 Aug 2014
EE-309@IITB
22
CADSL
Machine cycle
frequency
12
20 Aug 2014
921.6 kHz
32
By UART
EE-309@IITB
28800 Hz
To timer 1
To set the
Baud rate
23
Timer 1
CADSL
kHz
Timer
1
has
921.6
kHz/
32
=
28,800
Hz
as
source.
TH1=FDH
means
that
UART
sends
a
bit
every
3
Cmer
source.
Baud
rate
=
28,800/3=
9,600
Hz
20 Aug 2014
EE-309@IITB
24
CADSL
20 Aug 2014
EE-309@IITB
TH1
(Hex)
FD
FA
F4
E8
25
CADSL
20 Aug 2014
EE-309@IITB
26
CADSL
SBUF Register
Serial
data
register:
SBUF
MOV
SBUF,
#A
;put
char
A
to
transmit
MOV
SBUF,
A
;send
data
from
A
MOV
A,
SUBF
;copy
received
data
to
A
An
8-bit
register
Set
the
usage
mode
for
two
Cmers
For
a
byte
of
data
to
be
transferred
via
the
TxD
line,
it
must
be
placed
in
the
SBUF.
SBUF
holds
the
byte
of
data
when
it
is
received
by
the
8051;s
RxD
line.
Not
bit-addressable
20 Aug 2014
EE-309@IITB
27
CADSL
SCON Register
Serial
control
register:
SCON
SM0,
SM1
Serial
port
mode
specier
REN
(Receive
enable)
set/cleared
by
somware
to
enable/disable
recepCon.
TI
Transmit
interrupt
ag.
RI
Receive
interrupt
ag.
SM2
=
TB8
=
TB8
=0
(not
widely
used)
(MSB)
(LSB)
TI
RI
* SCON is bit-addressable.
20 Aug 2014
EE-309@IITB
28
CADSL
20 Aug 2014
EE-309@IITB
Baud
Rate
Fosc./12
Variable
by
+mer1
Fosc./64
or
Fosc./32
Variable
29
CADSL
SM2
SM2
enables
the
mulCprocessor
communicaCon
for
mode
2
&
3.
We
make
it
0
since
we
are
not
using
the
8051
in
a
mulCprocessor
environment.
SM2=0
:
Single
processor
environment
SM2=1
:
mulCprocessor
environment
20 Aug 2014
EE-309@IITB
30
CADSL
REN=0
The
receiver
is
disabled.
The
8051
can
not
receive
data.
CLR
SCON.4
20 Aug 2014
EE-309@IITB
31
CADSL
20 Aug 2014
EE-309@IITB
32
CADSL
20 Aug 2014
EE-309@IITB
33
CADSL
20 Aug 2014
EE-309@IITB
34
CADSL
RI (Receive Interrupt)
Receive
interrupt
ag.
Set
by
hardware
in
mode
1.
Must
be
cleared
by
somware.
When
the
8051
receives
data
serially
via
RxD,
it
gets
rid
of
the
start
and
stop
bits
and
place
the
byte
in
the
SBUF
register.
Then
8051
raises
RI
to
indicate
that
a
byte.
RI
is
raised
at
the
beginning
of
the
stop
bit.
20 Aug 2014
EE-309@IITB
35
CADSL
TI
RI
SM0 SCON.7
SM1 SCON.6
SM2 SCON.5
REN
SCON.4
TB8
SCON.3
RB8
SCON.2
TI
SCON.1
RI
SCON.0
EE-309@IITB
36
CADSL
20 Aug 2014
UART
EE-309@IITB
TxD
37
CADSL
EE-309@IITB
38
CADSL
MOV TH1,#FDH
EE-309@IITB
39
CADSL
20 Aug 2014
EE-309@IITB
40
CADSL
EE-309@IITB
41
CADSL
EE-309@IITB
42
CADSL
20 Aug 2014
EE-309@IITB
43
CADSL
bit by bit
UART
SBUF
RI
20 Aug 2014
EE-309@IITB
44
CADSL
EE-309@IITB
45
CADSL
MOV TH1,#FDH
EE-309@IITB
46
CADSL
7. Clear RI ag.
RI=0
receive data
CLR RI
EE-309@IITB
47
CADSL
EE-309@IITB
48
CADSL
Thank You
20 Aug 2014
EE-309@IITB
49
CADSL