Presentation is loading. Please wait.

Presentation is loading. Please wait.

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

Similar presentations


Presentation on theme: "CE-2810 Dr. Mark L. Hornick 1 Serial Communications Sending and receiving data between devices."— Presentation transcript:

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

2 CE-2810 Dr. 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 Using only one wire pair Conversely, in parallel communication, multiple bits are transmitted simultaneously using multiple wires

3 CS-280 Dr. Mark L. Hornick 3 The physical transmission of serial data takes many forms (e.g. different speeds and voltages) USB (Universal Serial Bus) Firewire Ethernet RS-232 RS-422 RS-485

4

5 CS-280 Dr. Mark L. Hornick 5 Atmel Atmega32 USART : Universal Synchronous/Asynchronous Receiver/Transmitter The USART is a subsystem of the chip that can be enabled/disabled and controlled via special-purpose I/O registers

6 CE-2810 Dr. Mark L. Hornick 6 Serial data is received/sent using RXD and TXD pins, which overlap PortD pins PD0 and PD1 The microcontroller does not have enough pins for all functions, so some pins server multiple purposes, depending on what function you enable Enabling the USART receiver disables PD0 function Enabling the USART transmitter disables PD1 function RXD/PD0 pin is used to receive serial data TXD/PD1 pin is used to transmit serial data

7 On the ATMEGA 32 board, RXD, TXD, and GND are generally accessed via the “UART” terminal Embedded Systems II, Copyright 20107 G V T R

8 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-2810 Dr. Mark L. Hornick 8 The USART subsystem of the Atmega32 supports both modes, but we’ll only use the asynchronous mode.

9 Asynchronous transmission of a byte of data Each byte of data is surrounded by “framing” bits, inserted by the USART CS-280 Dr. Mark L. Hornick 9 5,6,7,8, or 9 data bits Parity bit can be disabled (no parity bit) 1 or 2 stop bits LSB MSB

10 The Parity bit is an error checking mechanism used to detect data corruption CS-280 Dr. Mark L. Hornick 10 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)

11 TTL signal transmission of the letter ‘K’ (ASCII 0x4B=01001011) with 8 data bits, 1 start bit, 1 stop bit, and no parity bit – 10 bits total CS-280 Dr. Mark L. Hornick 11 5v 0v Idle Start 1 1 0 1 0 0 1 0 Stop time All time increments are equal

12 RS-232 signal transmission of the letter ‘K’ (ASCII 0x4B=01001011) with 8 data bits, 1 start bit, 1 stop bit, and no parity bit – 10 bits total CS-280 Dr. Mark L. Hornick 12

13 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 10-12 bits to transmit, depending on configuration The Atmega32 USART can be configured to operate between 2400 and 1M baud CS-280 Dr. Mark L. Hornick 13


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

Similar presentations


Ads by Google