Вы находитесь на странице: 1из 17

Serial Communication

Serial Communications
Transmission modes
Serial communications means that information is transmitted from source to destination over a single pathway Bit serial transmission:

Synchronization problem at: bit, word, frame level Signal transitions occur according to a transmitter clock Two modes of operation: asynchronous synchronous

Serial Communications
Transmission modes

Two basic transmission modes: asynchronous: transmitter and receiver clocks are independent synchronous: transmitter and receiver are synchronized

Serial Communications
Asynchronous transmission
Data word (octet) is encapsulated between: start bit

stop bits(s) Receiver resynchronizes again at a start of each new word (or character) received

Serial Communications
Asynchronous transmission
Transmission parameters:

transmission rate (9600bps, 19200bps, etc.) defines bit length in time


number of stop bits (1, 1.5, 2) word length (usually 8 bits)

Serial Communications
Asynchronous transmission
Error control: parity In an N bit word: count number of 1s on the first N-1 positions Insert 1 or 0 in the Nth position to get:

even (even parity - E) odd (odd parity - O) number of 1s


Parity rather not used these days (parity none - N)

Serial Communications
Asynchronous transmission
Convention: Parameters of an asynchronous transmission are often presented in the following form:

Sbps xAz
where:

S is a connection speed (19200, 38400bps,.) bps: bits per second x is a number of bits in a word (usually 8) A is parity (usually none: N) z is a number of stopbits
;-)

38400bps 8N1 is a good bet

Serial Communications
Synchronous transmission
Transmitter and receiver clocks synchronized DTE accepts a clock signal generated by DCE Clock signal transmitted either: over a separate line ( RS232 lines)

or encoded into the data (Manchester, differential Manchester encoding) to allow a single line for both data and clock No start, stop bits, but still frame synchronization words are needed

Serial Communications
Asynchronous:

Comparison of transmission modes


suitable for data transmitted at random intervals (e.g. keyboard to computer) large overhead (20% or more) rather low data rates (up to 115.2 kbps, practically 38.4 kbps) simplicity and availability: UART and RS232 are present in any PC used in the great majority of dial-up connections low overhead (long frames) high rates less prone to errors

Synchronous:

Start and stop bits

Data communication classification

SFRs relating to timers


SBUF : Serial Buffer Register Data moved to SBUF is Transmitted serially Serial data Rx-ed is stored by 8051 in SBUF SCON : Serial Control Register Program the mode

Serial Communication
SCON

Mode Selection

Setting the Baud rate


Timer 1is the timing controller for serial port in 8051 Clock for the Timer1 in the UART is XTAL /12 /32 = 28,800Hz (for XTAL = 11.0592MHz)

Set SMOD bit (PCON.7) to program 8051 to use 1/16 multiplier XTAL / 12 / 16 = 56,700Hz Effectively doubles the baud rate PCON Register: SMO D ---GF1 GF0 PD IDL

Timer1 has to be programmed in Mode 2, 8bit auto reload mode Load TH1 with the required value

Setting the Baud rate


TH values (XTAL = 11.0592MHz) Baud Rate: 9600 = 28800/3 -> TH1 = -3 = 0xFD Baud Rate: 4800 = 28800/6 -> TH1 = -6 = 0xFA Baud Rate: 2400 = 28800/12 -> TH1 = -12 = 0xF4 Baud Rate: 1200 = 28800/24 -> TH1 = -24 = 0xE8

If SMOD (PCON.7) is set then the same values for TH1 will give 19200 etc

Вам также может понравиться