Professional Documents
Culture Documents
1
RS-232 RS-232 Signaling
• Standard for serial transfer of characters
across copper wire
• Produced by EIA
• Full name is RS-232-C
• RS-232 defines serial, asynchronous
communication
– Serial - bits are encoded and transmitted one at a
time (as opposed to parallel transmission)
– Asynchronous - characters can be sent at any
time and bits are not individually synchronized
• There is also a differential (twisted pair)
version of RS-232 intended to operate over
longer distances (RS-422)
Logical 1 (Mark)
between -3 v and -15 v. (nominally -12 V)
2
RS-232 Signaling RS-232 Signaling
3
A Logical View of the Previous
RS-232 Signaling
Followed by
Diagram
one or more stop
bits. Line will
stay in mark state Stop bit(s)
until start of next
character LSB MSB
transmission
1 0 0 0 0 0 1
Note: The
QwikFlash
Board uses
a simple two
line (plus GND)
RS-232
connection—
i.e. no RTS/CTS
flow control
4
RS-232 Bit-level Synchronization RS-232 Bit-level Synchronization
Low-speed: Low-speed:
Note: Rx sampling
High speed; clock runs at 16x
baud rate
5
Using the PIC UART Using the PIC UART
• Once the UART is configured, it does all • Once the UART is configured, it does all
the work the work
– To transmit a byte, simply write it to the – To transmit a byte, simply write it to the
UART’s TXREG UART’s TXREG
– To receive a byte, simply read it from the – To receive a byte, simply read it from the
UART’s RXREG UART’s RXREG
The transmitter interrupt flag (TXIF) is cleared The receiver interrupt Flag (RXIF) is set when an incoming
by a write to TXREG and set when transmission data byte is available in the RXREG. Automatically
of the byte is complete cleared when the data is read from the RXREG
6
The UART Clock Generator The UART Clock Generator
Baud Rate:
fosc/(SPBRG+1)16
Eight bit counter, clocked at fosc Eight bit counter, clocked at fosc or
fosc/(SPBRG+1) fosc/(SPBRG+1)
fosc/(SPBRG+1)64
7
Setting the Baud Rate Achievable Baud rates (BRGH=1)
BRGH=1 BRGH=0
(High rate) (Low Rate)
Baud Rate =