Download presentation
Presentation is loading. Please wait.
Published byMonica Phelps Modified over 9 years ago
1
Harrison Jones Alexis Noel William Allen SERIAL COMMUNICATION INTERFACE (SCI)
2
Alexis Noel Types of data transmission Parallel & Serial Serial Communication Synchronous & Asynchronous Harrison Jones Baud & Bit Rates Asynchronous Serial Transmission Start, Data, Stop, Parity Bits Noise William Allen Registers Examples of data transmission INTRODUCTION & OUTLINE
3
SERIAL COMMUNICATION Serial = one after the other Serial Communication = sending one bit at a time over a channel Byte b0b0 b1b1 b2b2 b3b3 b4b4 b5b5 b6b6 b7b7 b0b0 b1b1 b2b2 b3b3 b4b4 b5b5 b6b6 b7b7 b0b0 b1b1 b2b2 b3b3 b4b4 b5b5 b6b6 b7b7 Serial Communication
4
PARALLEL COMMUNICATION Parallel Communication = several bits sent at a time on several parallel channels b0b0 Parallel Communication b1b1 b2b2 b3b3 b4b4 b5b5 b6b6 b7b7 b0b0 b1b1 b2b2 b3b3 b4b4 b5b5 b6b6 b7b7 Byte b0b0 b1b1 b2b2 b3b3 b4b4 b5b5 b6b6 b7b7
5
WHICH OF THESE DOES NOT SEND DATA IN A SERIAL STREAM? Ethernet USB Serial Port Fiber Optic Cable HDMI Parallel Port
6
WHICH TYPE SHOULD I USE?
7
PARALLEL COMMUNICATION ISSUES Issues with parallel communication: Inter-symbol interference (ISI) and noise cause corruption over long distances Wires have small amounts of capacitance and mutual inductance Bandwidth of parallel wires is much lower than bandwidth of serial wires Parallel communication is faster than serial for short distances
8
SERIAL COMMUNICATION FOR LONG DISTANCES Why serial connection is better for long distances: Differential signals are used to increase power Double the signal to noise ratio (SNR) Reach higher bitrate without noise USB 2.0 is capable of 480Mbits/sec! (At this rate, it would take only 46.5 seconds to transfer a 2.19GB BluRay movie over from a hard drive) Differential Signal Fun Fact: Longest ever deep sea Fiber-Optic cable will run through thawing artic between UK and Japan (that’s 9,693 miles of cable!)
9
SYNCHRONOUS VS. ASYNCHRONOUS COMMUNICATION Synchronous Serial Transmission Asynchronous Serial Transmission Stream of data is encoded in chunks Various bytes at the beginning of the data provide an embedded clock The data stream can also be synchronized by an external clock Data transmitted one character at a time Each character contains its own clock Start bits and stop bits Resynchronizes with each character
10
SYNCHRONOUS COMMUNICATION Synchronous Serial Transmission Advantages Amount of transmission information restricted to few characters for each block Not prone to distortion Can be used at higher speeds Disadvantages If error were to occur, whole block of data is lost (100+characters) User cannot transmit characters instantaneously Requires storage Synchronous used for high-speed communication between computers
11
ASYNCHRONOUS COMMUNICATION Advantages Each character is its own complete timer system Corruption will not spread Good for irregular interval character generation Keyboards Disadvantages Dependence on recognition of start bits Many bits are used only for control purpose and carry no useful information Limits transmission speed Used for speeds up to 3000 bits/second with only simple single-character error detection Asynchronous Serial Transmission
12
DATA WORD AND CONTROL BITS Asynchronous Serial Transmission Start Bit Signals start of transmission of data bits Transition from logic 1 to logic 0 Data Bits Typically 8 data bits (not including parity bit) Least significant bit is transmitted and received first Stop Bit Signals end of data word
13
The rate at which symbols are sent Measured in symbols per second (Bd) Also known as baud or modulation rate Often incorrectly referred to as bits per second Important Baud Variables Bd – Baud rate M – Number of symbols used (voltages, tones, etc) Number of symbols used (M) = 2 N where N = bits / symbol N – Bits per symbol (binary = 1) BAUD RATES
14
The rate at which bits are transmitted Baud * Bits / Symbol Measured in bits per second (bps) NOT bytes per second (Bps) Often incorrectly referred to as data rate Gross Bit Rate – total number of bits transmitted per second Includes protocol overhead bits and data bits R b = 1 / T b where T b is the bit transmission time Symbol Rate ≤ Gross Bit Rate Only equal when 2 bits per symbol (binary) Information Rate – rate at which useful data is transmitted Information rate ≤ Gross Bit Rate Unless there is no protocol (risky!) I R = R b * Data Bit Number / Total Bit Number BIT RATES
15
Symbol Number (M) Analog modem capable 64 different voltage levels (symbols) sends out how many bits per symbol? M = 65 = 2 N. N = 6 bits per symbol Baud Rate A baud rate of 100 Baud = 100 symbols / second Bit Rate At 9,600 Baud with 3 voltage levels what is the bits per second? Bits BPS = 9,600 * 1.5850 = 15,216 bps Information Rate Given a protocol with 3 bits of protocol, 8 bits of data, 9600 baud, and 1 bit per symbol (binary) what is the IR? I R = 9600 * log2(2) * 8/11 = 6981 data bits per second BAUD RATES EXAMPLES
16
Overhead Bits Start bit – Start of “frame” bit Parity Bit – Error check bit Stop Bits – End of “frame” bit Data Bit – the actual data ASYNCHRONOUS SERIAL TRANSMISSION
17
One bit The first bit of a serial data word Signals the start of data transmission Detected as a transition from the idle state to the active state Referred to as a “mark-to-space” transition Idle state for HCS12 is high (“1”) Active state for HCS12 is low (“0”) START BIT
18
One bit Used as a crude form of error detection Even / Odd / No Parity Even – Start Bit + Data Bits + Stop Bits + Parity = 0 Odd – Start Bit + Data Bits + Stop Bits + Parity = 1 None – No parity bit included IMPORTANT: for this class, simply count Data Bits + Parity Bit Calculated by transmitter, checked by receiver User specified on the HCS12 PARITY BIT
19
One+ bits Indicate the end of transmission Usually 1 or 2 idle state bits One stop bit on the HCS12 STOP BITS
20
Number of data bits established by protocol Common Transmission Mode 7 bits of data + 1 parity bit = 8 total data bits Other Mode 8 bits of data (full byte) + 1 parity bit = 9 total data bits Bit order is hardware dependent HCS12 sends LSB first DATA BITS
21
Sending #$AB with one start bit, one stop bit, even parity, and 8 bit data Binary is #%1010 1011 Parity Bit is 0 : 0+1+0+1+0+1+0+1+1+P+1 = EVEN EXAMPLE 01 0 1 0101 1 01 Start BitStop Bit Parity Bit Data Bits Direction of Transmission
22
Noise – Noisy signals cause bits to “flip” Overrun – Slow receivers cause loss of data Framing Error – Timing errors cause issues TRANSMISSION ERRORS
23
Noise can cause “1” to appear to be “0” and vice verse Effect lessened by sampling NOISE
24
Each bit after start bit is sampled X pules after center of start bit. X depends on the mode (1,16, and 64) NOISE
25
Very simple concept Receiver doesn’t read data in SCI data register fast enough New data lost OVERRUN
26
The result of reading incoming bits using the wrong starting point Can be detected by using the parity bit Often the result of mismatched baud rates FRAMING ERROR
27
SCI BLOCK DIAGRAM
28
SCI MODULE ON THE HCS12 BILLY ALLEN The SCI Module communicates over PS1 (Tx) and PS0 (Rx). Writing to the SCI Data Registers transmits data over the Tx line. Incoming Rx data is automatically stored in the SCI Data Register. Flags in the SCI Status Registers can be used to trigger interrupts.
29
OVERVIEW OF SCI REGISTERS
30
$00CE $00CF Reading from this register accesses the data received by the SCI receiver. Writing to this register transmits the data through the SCI. T8 and R8 are the 9 th data bit when the SCI is in 9-bit mode. R0-R7 is the data received by the SCI. SCI DATA REGISTERS
31
Writing to SCBIR to set the Baud Rate: $00C8 $00C9 Baud rate = SCI module clock / (16 * SCIBR[12:0]) SETTING THE BAUD RATE
32
Example: To achieve a baud rate of 9600 with an 8MHz module clock: LDX #0052(loads 52 into X) STX $00C8(stores X into the SCIBR Registers $00C8 and $00C9) Note that due to the way the baud rate is calculated, there will be some error in the actual rate that the 12C32 uses. This example actually yields a baud rate of 9615, but that error (0.156%) is small enough to be safely ignored. SETTING THE BAUD RATE
33
$00CA LOOPS: If set to 1, connects the output of TX to the input of RX. SCISWAI: If set to 1, disabled the SCI while in wait mode. RSRC: If LOOPS = 1, RSRC selects the source of the incoming TX signal. If RSRC = 0, the receiver is connected to the transmitter internally. If RSRC = 1, the receiver is connected to an external TX signal. M: Controls the number of data bits. If M = 0, the SCI uses one start bit, eight data bits, one stop bit. If M = 1, the SCI uses one start bit, nine data bits, one stop bit. SCI CONTROL REGISTER 1
34
$00CA WAKE: Defines the input condition that wakes up the receiver. If WAKE = 0, an idle input (0) will wake up the receiver. If WAKE = 1, a high input (1) wakes up the receiver. ILT: Defines when the SCI starts counting to wait for idle bits. If ILT = 0, the counter begins when the start bit is sensed. If ILT = 1, the counter begins when the stop bit is sensed. PE: If PE = 1, a parity bit is added to the data being transferred. PT: Defines how the parity bit it set. If PE = 0, parity bit it set for ODD parity. If PE = 1, parity bit is set for EVEN parity. SCI CONTROL REGISTER 1
35
$00CB TIE: If TIE = 1, the Transmit Data Register Empty flag, TDRE, can generate interrupt requests. TCIE: If TCIE = 1, the Transmission Complete flag, TC, can generate interrupt requests. RIE: If RIE = 1, the Receive Data Register Full flag, RDRF, or the OverRun flag, OR, can generate interrupt requests. ILIE: If ILIE = 1, the idle line flag, IDLE, can generate interrupt requests. SCI CONTROL REGISTER 2
36
$00CB TE: Transmitter Enable. If TE = 1, the transmitter is enabled. RE: Receiver Enable. If RE = 1, the receiver is enabled. RWU: Receiver Wakeup Bit. If RWU = 1, the SCI goes into a standby state and will not trigger interrupt requests until it wakes up from an external signal. SBK: Sent Break Bit. If SBK = 1, sends a pattern of break characters on the TX line. SCI CONTROL REGISTER 2
37
$00CC TDRE: Transmit Data Register Empty Flag This is set to 1 if the transmit data register becomes empty. TC: Transmit Complete Flag This is set to 1 if the transmission is done and nothing new is being sent. RDRF: Receive Data Register Full Flag Set to 1 if there is received data available in the SCI data register. IDLE: Idle Line Flag Set to 1 if 10 or 11 consecutive logic 1 signals appear on the receiver input line. SCI STATUS REGISTER 1
38
$00CC OR: OverRun Flag Is set to 1 if the software fails to read the contents of the data register before the shift register receives more data. NF: Noise Flag Is set to 1 if the SCI detects noise on the receiver input. FE: Framing Error Flag Is set to 1 If the SCI detects that a framing error has occurred. PF: Parity Error Flag Is set to 1 if the parity bit is incorrect. SCI STATUS REGISTER 1
39
$00CD BK13: Break Transmit Character Length Defines the length of the break character used. If BK13 = 0, break character is 10 or 11 bits long. If BK13 = 1, break character is 13 or 14 bits long. TXDIR: Transmitter Pin Data Direction in Single-wire mode If single wire mode is active, this controls the data direction for TXD. If TXDIR = 0, TXD is an input. If TXDIR = 1, TXD is an output. RAF: Receiver Active Flag This is set to 1 if the receiver is currently receiving data. SCI STATUS REGISTER 2
40
After a short delay, send the value $AB over the Tx line with an ODD parity bit. DATA TRANSMIT EXAMPLE
41
Wait until data is received on Rx, then load it into Accumulator X. DATA RECEIVE EXAMPLE
42
QUESTIONS?
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.