Presentation is loading. Please wait.

Presentation is loading. Please wait.

Asynchronous Serial Communications

Similar presentations


Presentation on theme: "Asynchronous Serial Communications"— Presentation transcript:

1 Asynchronous Serial Communications
Asynchronous serial data transmission sends each datum as a separate frame Line goes to logic 0 for one period to signal the start of the frame (START) The datum bits are then transmitted one bit at a time least significant first Line goes to logic 1 for one period to signal the end of the frame (STOP) Line then idles at logic 1 until the next START pulse For example, transmitting the letter ‘E’ (h’45’ or b’ ’) LS bit 1 MS bit START STOP Idle Idle 15-Nov-18 EEE305 Microcontroller Key Points

2 EEE305 Microcontroller Key Points
Concepts Baud rate is a measure of information flow rate. In simple systems this is the same as bit rate. Baud rate is conventionally 110, 300, 600, 1200, 2400, 4800 …. Bit period is 1/(Baud rate); e.g. 1/600 = 1.666ms. With a single Start and Stop bit there are ten bits in a frame. Thus at 600 baud, 60 characters per second are send at maximum. The receiver is set to the same nominal rate as the transmitter to avoid having to transmit the clock signal via a separate channel. The clocks can differ by no more than ±½ (±50%) of a bit period in the ten bits to avoid loss of synchronization; that is ±5% A Simplex channel can only transmit in one direction. A half Duplex channel can transmit in either direction but not simultaneously. full Duplex channel can transmit simultaneously in both directions. 15-Nov-18 EEE305 Microcontroller Key Points

3 EEE305 Microcontroller Key Points
Normal logic voltages not suitable for transmission distances above around 30cm. Signalling techniques are used to modify the two signals to give longer ranges and suit the transmission channel (e.g. tones are used for telephone and wireless links). RS-232 is one of the most common of these signal standards. Two bipolar voltage levels are used; with the positive voltage representing logic 0 and the negative voltage logic 1. At the transmitter levels of typically ±12V with respect to ground. The receiver can sense voltages down to ±3V with respect to ground. Used for distances up to 15m at low speed Rather poor noise immunity, especially if there is any difference in the ground voltages between transmitter and receiver. Not designed for network use, which needs multiple transmitters and receivers sharing the one line. 15-Nov-18 EEE305 Microcontroller Key Points

4 EEE305 Microcontroller Key Points
15-Nov-18 EEE305 Microcontroller Key Points

5 EEE305 Microcontroller Key Points
RS485 uses two conductors (instead of relying on the ground connections at remote points), usually twisted together. This is known as differential signalling as opposed to single-ended signalling where voltages are measured with respect to ground. Transmitter uses ±5V (when idling B wire is more positive than A wire) across the conductors to signal either logic level. Receiver can detect differences across the wires down to ±200mV Good noise immunity, as any externally induced noise will effect both conductors equally and the receiver is only interested in differences. Long distances at high speed are possible. Each transmitter has an enable input, so more than one driver can be connected to the link, provided that only one is enabled at any time. Multiple receivers can be connected to the link, giving with the above a network (LAN) capability. 15-Nov-18 EEE305 Microcontroller Key Points

6 EEE305 Microcontroller Key Points
15-Nov-18 EEE305 Microcontroller Key Points

7 EEE305 Microcontroller Key Points
Handshaking or flow control is the protocol used by the transmitter to determine if the receiver is ready to accept a character. For an asynchronous link there are basically two different techniques: Hardware: Where there is a separate connection between transmitter and receiver, often labelled /CTS (Clear To Send) and /RTS (Ready To Send) – where the signals are active logic 0. When ready to TX, transmitter (Master) activates its /RTS line. Master then checks the /CTS line from receiver (Slave). If not active goto 1. Transmit the character. If another character to send THEN GO TO 2 ELSE deactivate /RTS Advantages; fast, reliable and simple. Disadvantages; Needs two extra wires or channels. 15-Nov-18 EEE305 Microcontroller Key Points

8 EEE305 Microcontroller Key Points
15-Nov-18 EEE305 Microcontroller Key Points

9 EEE305 Microcontroller Key Points
Software: Where special reserved characters are sent to the Master by the Slave indicating the latter’s readiness to accept more information. These characters are usually named XON (code b’ ’ or h’11’) and XOFF (code b’ ’ or h’13’). Basically the Master keeps transmitting until and if the Slave sends back an XOFF character. It doesn’t start up again until an XON character is received. Master sends a character. Has the Slave sent an XOFF character? If not then GO TO 1 unless transmission is over. ELSE keep listening until an XON character is received in which case GO TO 1. Advantage: Doesn’t need two dedicated handshake channels. Disadvantages: Needs a Duplex link, not as reliable as a hardware scheme as can lock up of an XON or XOFF character is lost due to noise. 15-Nov-18 EEE305 Microcontroller Key Points

10 EEE305 Microcontroller Key Points
15-Nov-18 EEE305 Microcontroller Key Points

11 EEE305 Microcontroller Key Points
How to generate asynchronous protocol signals. In software using bit twiddling; e.g. to code a subroutine to transmit a single character (putchar) at 4800 baud: Output a low on a port pin for one baud delay (1/4800 = 208µs) to give the Start bit. DO eight times: Shift datum right and set pin high or low according to the state of the bit that pops out into the Carry flag. Wait one baud delay. Output a high on the port pin for one baud delay to give the Stop bit. A receive (getchar) subroutine is similar but waits for the line connected to a port pin to go low and then uses a ½ baud delay to find the middle point of the Start bit. The signal is then sampled eight times at baud delay intervals. 15-Nov-18 EEE305 Microcontroller Key Points

12 EEE305 Microcontroller Key Points
In hardware using shift registers and logic circuitry. A dedicated circuit to do this is called a Universal Asynchonous Receiver/ Transmitter (UART). A Basic UART will have the following properties: Baud-rate generator (sometimes an external BRG needs to be used) to generate shifting pulses at the appropriate clock rate to suit the baud rate. Transmit Shift and Buffer registers to hold the datum being shifted out with a Start and Stop bit appended. Transmit Buffer Empty flag to say when the Transmit Buffer register is empty and so can be updated. Receive Shift and Buffer registers. Receive Buffer Full flag to say when a new character has been shifted in and dumped into the Buffer ready for collection. 15-Nov-18 EEE305 Microcontroller Key Points

13 EEE305 Microcontroller Key Points
15-Nov-18 EEE305 Microcontroller Key Points

14 EEE305 Microcontroller Key Points
To transmit a character: Software checks the TBUF flag. If active try again until Buffer is empty. Copy code into the Transmit Data Buffer Register. When the actual Transmit Data Register is empty, this datum will be automatically transferred from the Buffer and the TBUF flag reset. The datum is shifted out LSB first from the TX pin after which a Start bit is sent and a Stop bit is appended at the end. To receive a character: Software checks the RBUF flag to check if the Receive Data Buffer Register is full. If not active, try again. Copy the new datum into an internal register. This will automatically deactivate the RBUF flag. When another Start pulse is sensed at the RX pin, it is shifted in, the Start and Stop bits stripped and the datum copied into the Buffer and RBUF activated. 15-Nov-18 EEE305 Microcontroller Key Points

15 EEE305 Microcontroller Key Points
15-Nov-18 EEE305 Microcontroller Key Points


Download ppt "Asynchronous Serial Communications"

Similar presentations


Ads by Google