Easy
PIC
for dsPIC30
®
v7
page 16
UART via RS-232
communica
tion
The
UART (universal asynchronous
receiver/transmitter) is one of the most
common ways of exchanging data between
the MCU and peripheral components. It is
a serial protocol with separate transmit and
receive lines, and can be used for full-duplex
communication. Both sides must be initialized with
the same baud rate, otherwise the data will not be
received correctly.
RS-232 serial communication is performed through a
9-pin SUB-D connector and the microcontroller UART
module. In order to enable this communication, it
is necessary to establish a connection between
RX and TX lines on SUB-D connector and the
same pins on the target microcontroller using
DIP switches. Since RS-232 communication
voltage levels are different than
microcontroller logic levels, it is
necessary to use a RS-232
Transceiver circuit, such as
MAX3232 as shown
on Figure 6-1.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
C1+
V+
C1-
C2+
C2-
V-
T2OUT
R2IN
T1IN
T2IN
VCC
GND
T1OUT
R1IN
R1OUT
R2OUT
U5
MAX3232
5
9
4
8
3
7
2
6
1
1
5
9
6
CN12
DB-9
C17
100nF
C18
100nF
C25
100nF
C24
100nF
E4
10uF
VCC-BRD
VCC-BRD
R20
100K
VCC-BRD
R
S
-2
3
2
C
O
N
N
E
C
TO
R
1 2 3 4 5 6 7 8
O
N
SW8
RC14
RF2 RF4 RF7 RE
6
R
B5
J20
R
X-
FTD
I
RX
-23
2
R
X
1 2 3 4 5 6 7 8
O
N
SW9
RC13
RF3 RF5 RF8 RE
7
R
B4
J21
TX
-F
TD
I
TX-23
2
TX
DATA BUS
Figure 6-1:
RS-232
connection
schematics
Enabling RS-232
In order to enable RS-232
communication, you must set J20
and J21 jumpers in the RS-232
position, and enable desired RX
and TX lines via SW8 and SW9
DIP switches. For example, if you
want to enable RS-232 connection
on UART1 module of the default
dsPIC30F4013 chip, you should
enable SW8.1 (RF2) and SW9.1
(RF3) lines.