Serial Communications

14
CE-2810 Dr. Mark L. Hornick 1 Serial Communications Sending and receiving data between devices

description

Serial Communications. Sending and receiving data between devices. Serial Communications describes a general way in which two devices can send or receive data from one another. To send or receive data, bits have to be moved around - PowerPoint PPT Presentation

Transcript of Serial Communications

Page 1: Serial Communications

CE-2810Dr. Mark L. Hornick

1

Serial Communications

Sending and receiving data between devices

Page 2: Serial Communications

CE-2810Dr. Mark L. Hornick

2

Serial Communications describes a general way in which two devices can send or receive data from one another

To send or receive data, bits have to be moved around

The term Serial indicates that the data bits are transmitted sequentially, one bit at a time

Conversely, in parallel communication, multiple bits are transmitted simultaneously

Page 3: Serial Communications

CS-280Dr. Mark L. Hornick

3

The physical signaling of serial data takes many forms USB (Universal Serial Bus) Firewire Bluetooth IR Ethernet RS-232 RS-422 RS-485 WiFi

Page 4: Serial Communications

CS-280Dr. Mark L. Hornick

4

Atmel Atmega32USART Subsystem

Page 5: Serial Communications

CE-2810Dr. Mark L. Hornick

5

USART overlaps PortD pins RXD pin is used to receive serial

data Enabling the USART receiver

overrides PD0 function

TXD pin is used to transmit serial data Enabling the USART transmitter

overrides PD1 function

Page 6: Serial Communications

RS-232 on the SunRom board

The SunRom board includes a RS-232 converter chip that converts the low-level signals of TXD/RXD to RS-232 voltages TXD/RXD: 0 to +5v RS-232: -15 to +15v

The converter chipinterfaces theAtmega32 to the 15-pin D-shell connector

CE-2810Dr. Mark L. Hornick

6

Page 7: Serial Communications

TTL vs RS-232 voltage levels

TTL (transistor logic) signals v < 2 = logical 0 v > 3 = logical 1 2 < v < 3 = undefined

RS-232 signals -15 < v < -3 = logical 1 +3 < v < +15 = logical 0 -3 < v < +3 = undefined

CS-280Dr. Mark L. Hornick

7

Note that logic values appear to be inverted if RS-232 signals are viewed on an oscilloscope

Page 8: Serial Communications

Only 3 lines on the 15-pin connector are used for RS-232; Tx(2), Rx(3), and Ground(5)

CS-280Dr. Mark L. Hornick

8

Page 9: Serial Communications

Connection between two communicating serial devices

The Tx (transmit) line of one device is connected to the Rx (receive) line of the second device

CS-280Dr. Mark L. Hornick

9

Tx Tx

RxRx

Page 10: Serial Communications

Asynchronous vs Synchronous In synchronous communications, the two

communicating devices must keep their respective clock signals synchronized Even when no data is being sent, the two devices

continuously exchange “sync” characters

In asynchronous communications, the two devices maintain their own clocks Nothing is transmitted when there is nothing to send

But a “handshake” has to be established whenever data needs to be transmitted – extra overhead

CE-2810Dr. Mark L. Hornick

10

The USART subsystem of the Atmega32 supports bothmodes, but we’ll only use the asynchronous mode.

Page 11: Serial Communications

Asynchronous transmission of a byte of data

Each byte of data is surrounded by “framing” bits, inserted by the USART

CS-280Dr. Mark L. Hornick

11

5,6,7,8, or 9 data bitsParity bit can be disabled (no parity bit)

1 or 2 stop bits

LSB MSB

Page 12: Serial Communications

The Parity bit is an error checking mechanism used to detect data corruption

CS-280Dr. Mark L. Hornick

12

The Parity is computed first on the transmitting end, and included as the Parity bit in the frame. The Parity is then recomputed on the receiving end, and the result is compared to the Parity bit value. If the Parity calculation on the receiving end does not match, the receiver knows data corruption occurred.

This allows errors to be DETECTED, but does not provide a means of CORRECTION.

Equal to 1 if the number of non-zero data bits is odd,(#data bits + parity bit = even number of bits)

Equal to 1 if the number of non-zero data bits is even,(#data bits + parity bit = odd number of bits)

Page 13: Serial Communications

RS-232 signal transmission of the letter ‘K’ (ASCII 0x4C)

CS-280Dr. Mark L. Hornick

13

Page 14: Serial Communications

Speed metrics

The speed of serial transmission is usually measured in bits-per-second

This is called the baud rate Because of the overhead bits used in each

frame, 2400 baud is NOT the same as 300 characters per second Since each character takes >8 bits to transmit

The Atmega32 USART can be configured to operate between 2400 and 1M baud

CS-280Dr. Mark L. Hornick

14