Parallel IO data sent over a group of parallel wires. Serial IO data sent one bit at a time, over a single wire.
Typically, a clock is used for synchronization. A clock may or may not be used for synchronization
D[15:0] D
CPU #1 clk CPU #2 CPU #1 clk CPU #2
Question: Assuming one bit is sent each rising clock edge, how
A 16-bit data channel is shown above. If data is transferred fast does the clock have to be achieve 600 MB/s?
each rising clock edge, and clock rate is 300 MHz, then the
data transfer rate (bandwidth) in bytes/sec is: 600 MByte/s = 600 MBytes/s * 8 bits/1Byte = 4800Mb/s
2 Bytes/clock period = 2 /(1/300e06)s Clock period = 1/4800e06
= 2 * 300e06/s = 600e06/s Clock Frequence = 1/clock period = 4800e06 = 4.8e09 = 4.8GHz
= 600 MB/s (MB = MBytes)
V 0.2 1 V 0.2 2
uni-directional
Tx Rx Tx ia + ib
Tx
1
Synchronous Serial IO Asynchronous Serial IO
Synchronous Serial IO Channel CPU #2 Asynchronous Serial IO Channel CPU #2
CPU #1 CPU #1
Internal clock frequencies match to Internal clock frequencies match to
within a tolerance value. Can be out of within a tolerance value. Can be out of
phase phase
Synchronous serial IO either
(a) sends the clock as a separate wire Asynchronous Serial I/O does not transmit the clock on a
OR
(b) receiver (CPU #2) extracts clock from data stream or uses a Phase- separate wire nor does it guarantee a particular transition
Locked-Loop (PLL) and changes in the data stream to synchronize internal densisty (ie., the data line could remain in the same state,
clock (phase alignment) to data stream. either 1 or 0 for the duration of the transmission after
For PLL synchronization, the data line must be guaranteed to have a the initial state change indicating start of transmission).
minimum number of state changes (0 1 or 1 0) within a particular time
Asynchronous Serial I/O is used in older standards, is easy
interval (transition density).
to implement, but is slower than synchronous serial
Synchronous serial IO can achieve high speeds; all new high speed serial standards.
standards are synchronous.
V 0.2 7 V 0.2 8
Example Parity
data values
A parity bit is an extra bit added to a data frame to detect a
1 1 0 0 1 1 0 1 0 1 0 1 1 1 single bit error
A single bit error is when one bit of the frame was received
incorrectly (read as 0 when should have been 1, or vice-versa).
Not guaranteed to detect multi-bit errors
Odd parity parity bit value makes the total number of 1
ST start bit 56h = V ASCII Character * - stop bit a mark
bits in the frame odd
P even parity bit For 7-bit data value 0x56 (1010110),
When Receiver sees a Start Bit (high to low transition): odd parity bit = 1
Even parity parity bit value makes the total number of 1
1) Local Timer Starts
2) Each bit sampled at midpoint in time ( % clock tolerance)
bits in the frame even
3) Maximum tolerance is of 1 bit time interval over 10 intervals For 7-bit data value 0x56 (1010110),
even parity bit = 0
= ()/10 = 5%
slide by Prof. Mitch Thornton
V 0.2 11 V 0.2 12
2
Receiver Sampling Baud Rate vs Bits Per Second
one bit time next bit Baud rate is the rate at which signaling events are sent
Bits per second (bps) is the number of bits transferred per
second (any type of bits, data or overhead bits)
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 0 1 2 3 4 If only a 1 or 0 is sent for each signaling event, then
sample here baud rate = bps
However, could use a signaling protocol that transfers
Receiver clock; period usually either 64x or 16x bit time (above is 16x).
multiple bits per signaling event
At start bit, internal 4-bit counter set to 0. Sample at mid-point of bit time (counter i.e., use 4 different voltage levels, send two bits of data per
value 7 or 8, some receivers sample at 7,8 and 9 and only accept bit if all values signaling event (00 = -15v, 01= -5v, 10=+5v, 11 = 5v).
are the same do this for glitch rejection). In this case, bit rate will be double the baud rate
Receiver/Transmitter clocks not perfectly matched. Our tolerance is bit time The effective data rate is the rate at which data is
(50%) spread over entire frame. Assuming a 10 bit frame, maximum mismatch transferred, minus the overhead bits (ie. start and stop bits).
between Rx/Tx clocks is 50%/10 = 5%,
V 0.2 13 V 0.2 14
3
PIC16F873 USART USART Registers
USART Universal Synchronous Asynchronous Receiver RCREG holds a received character; read this to
Transmitter get character
Hardware module in PIC that implements both synchronous TXREG write to this register to send a character
and asynchronous serial IO. We will use asynchronous mode. RCSTA contains status bits for received
Frees the processor from having to implement software delay character
loops; receive/transmit done by USART while processor can SPBRG and TXSTA control baud rate
do other tasks. 16F873 TXSTA status bits also select between async/sync IO,
USART enable TX transmission
Will always use 8-bit, RC6/TX PIR1 register contains status bits
TXREG
no parity for PIC serial TXIF (transmit interrupt flag), 1 if TXREG is empty
RC7/RX
IO. RCREG RCIF (receive interrupt flag), 1 if RCREG is full
V 0.2 19 V 0.2 20
Transmit Hardware
RCIF, TXIF Bits TXREG is double-buffered. If TSR is empty, after write to
TXREG, then TXREG transferred to TSR and TREG empty
again (TXIF = 1). Do not have to wait for last character to
be sent before writing new character.
4
Baud Rate Control Baud Rate Examples
The baud rate is controlled by the 8-bit value in the SBPRG
register and the BRGH bit (bit 2 in TXSTA register). Desired baud rate of 9600, Fosc = 14.7456 MHz
Baud_Rate = Fosc/ [K*(SBPRG+1)] What is SBPRG value for high speed mode?
or SBPRG = (14.7456e06/[16*9600] ) 1
= 95
SBPRG = (Fosc/[K*Baud_Rate] ) 1
V 0.2 25 V 0.2 26
5
What is EIA-RS232? MAXIM
An interface standard originally used to connect 232/232A
PCs to modems RS232
A modem is a device used to send digital data over
phone lines driver/receiver
The standard defines voltage levels, cable length,
connector pinouts, etc
There are other signals in the standard beside TX, Converts RS232 voltage
RX, Gnd levels to digital levels and
vice-versa
The other signals are used for modem control (Data
Carrier Detect, Ring Indicator, etc) and flow control External capacitors used
(flow control signals are used to determine if a device is with internal charge pump
ready to accept data or not) circuit to produce +/- 10V
We will not cover the other signals in the RS232 from 5V supply
standard
V 0.2 31 V 0.2 32