7.1 Introduction to UART Terminologies
The ATmega328 Microcontroller has a ‘Communication Port’ known as Universal Synchronous Asynchronous Receiver Transmitter (USART), which is used to exchange data with Personal Computer (PC) and other Microcontroller (MCU). The port operates in two modes: synchronous and asynchronous. In this book, we will deal with the studies of the asynchronous part of the USART port; hence, we will address it as an asynchronous receiver transmitter (UART) port. It is an asynchronous port; because, there is no timing relationship between the transmitter and receiver on data transmit/receive issue; it is a serial port; because, data transfer takes place bit-by-bit and one-after-another. It is a universal port; because of what?
(1) Serial Communication Protocol: Protocol refers to a set of rules which two or more parties have agreed to follow for a certain period of time. Serial Communication Protocol is a set of rules that regulate the definitions of various operational parameters of the serial data communication system. For example: It is a protocol that the data transmit/receive between ATmega328 and PC will occur on Asynchronous Serial Mode at 4800 Bd, 10-bit Frame Length, No-parity, and 1-Stop Bit.
(2) Asynchronous Serial Mode (AS): This mode defines that:
(a) There would be absolutely no timing relationship (means asynchronous) between the transmitter
and receiver as to who is transmitting (receiving) at what times.
(b) The basic data item is the 8-bit code for an ASCII character which could be a member of the English Language alphabet (A – Z, a – z, 0 – 9, and Punctuation Marks) or Non-printable Control Characters.
(c) The data transmission/reception will happen bit-by-bit with LS-bit first (Fig-7.2).
(d) At idle state (no transmission mode), the transmission line (TX Line) will remain at LH-state (Fig-7.2).
(e) At the beginning of data transmission, TX line will drop to LL-state for 1-bit period to alert the receiver (RX Line) for accepting the forth coming data bits (Fig-7.2).
(f) After the transmission of 8-bit data (the ASCII code), the TX line is pulled up to LH-state (Fig-7.2) for 1-bit period indicating the end-of-transmission. If parity bit is added, the receiver will be collecting 9-data bits instead of 8.
(3) Baud Rate (Bd): In communication theory, Baud Rate (Bd) refers to quantitative measure of information being transmitted/received by a carrier. A carrier is said to be conveying information when the modulating signal (the information) brings changes in its amplitude, frequency or phase. Every change in the carrier is an information bit (the baud). In asynchronous serial communication, there is no carrier. The bits being carried out over the TX-line are all information bits. So, the Baud Rate is equal to the Bit Rate.
There are cases where Baud Rate is different from Bit rate. For example: The Bell 212A type modem uses 1200 Hz sine wave carrier for transmission. It uses the so called ‘dibit encoding’, where ‘2 consecutive bits’ in the data stream is treated together. In this scheme, the value of these two bits determines the amount of phase shift to be occurred in the carrier. The relationship is:
dibit value phase shift
00 00
01 900
11 1800
10 2700
Now, assume that the bit pattern 00 11 01 01 11 01 would be transmitted using the dibit encoding scheme. The relationship between the values of the dibits and the phase shifts of the carrier is depicted below in Fig-7.1. The value of the 1st dibit is 00, so there is no phase shift of the carrier. The value of the 2nd dibit is 11, so the phase shift of the carrier is 1800 and it has occurred at the elapse of 1800 from point B. In a similar way, we have indicated the phase shift points for the remaining dibits of the data stream.
Figure-7.1: Waveforms for simple phase-shift modulation
Now, we are in a position to explain the difference between the Bit Rate and the Baud Rate. At 1200 Hz carrier frequency, one cycle period is required for the shifting of 1-bit data into the phase-shift keying modulator. In the example of Fig-7.1, we have 12-bit data; we need 12 clock cycles to shift them into the modulator. So, the Bit Rate: 1200 bits/sec.
Now, let us look at the carrier; we observe that there are only 6 changes in the carrier. The 12-bit data have brought only 6 changes in phases of the carrier. The information content is 6 Baud. The Baud Rate is half of the Bit Rate and it is: 600 Bd.
(4) Graphical Representation of the Asynchronous Data Frame (TTL Logic)
Figure-7.2: Waveforms for asynchronous data frame for character A (TTL Logic)
(a) Assume Bd = 4800; Even-parity (number of 1s in the data field is even).
(b) Frame Length : 11 (1-Start Bit, 8-Data bit, 1-parity bit, and 1-Stop bit)
(c) Bit Rate = Baud Rate = 4800. Bit Period = 1/4800 = 208 µs.
(5) Graphical Representation of the Asynchronous Data Frame (RS232 Logic)
The raw TTL signal of Fig-7.2 can travel over 10ft to 15ft without much appreciable distortion and after that it becomes heavily distorted. The receiver fails to detect the incoming signal and the information is lost. In an effort to allow the serial data traveling over a distance of 100ft or more without any modulation or amplification and without suffering appreciable distortion, the Electronic Industries Association introduced the RS232 scheme in 1960. In this scheme, TTL signal is transformed into RS232 logic (Fig-7.3) and vice versa with suitable logic converters like MAX232. The TTL Logic and its counterpart RS232 Logic states are shown below:
TTL Logic RS232 Logic
LL = 0V LL = 3V to 10V (under loading)
LH = 5V LH = -3V to -10V (under loading)
Figure-7.3: Asynchronous serial data format in TTL RS232
L71.doc (832 KB)