User`s guide

UART via RS-232
communication
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 dierent 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
U4
MAX3232
5
9
4
8
3
7
2
6
1
1
5
9
6
CN37
RS232
C28
100nF
C30
100nF
C29
100nF
C31
100nF
E8
10uF
VCC-MCU
RX-232
TX-232
1 2 3 4 5 6 7 8
O
N
SW1
R32
100K
RS232
CONNECTOR
RX-FTDI
RX-232
RX
1 2 3 4 5 6 7 8
O
N
SW2
TX-FTDI
TX-232
TX
RB1
RB4
RB2
RC7
RA3
RB5
RC5
RD7
RB2
RB1
RB5
RC6
RA2
RB7
RC4
RD6
VCC-MCU
VCC-MCU
J3
J4
DATA BUS
Figure 6-1: RS-232 connection schematic
Enabling RS-232
In order to enable RS-232
communication, you must set J3
and J4 jumpers in the RS-232
position, and enable desired RX
and TX lines via SW1 and SW2
DIP switches. For example, if you
want to enable RS-232 connection
on UART1 module of the default
PIC18F45K22 chip, you should
enable SW1.1 (RC7) and SW2.1
(RC6) lines.
page 16