Serial Communication Interface (SCI)

Serial Communication Interface (SCI)

SERIAL COMMUNICATION INTERFACE (SCI) Harrison Jones Alexis Noel William Allen INTRODUCTION & OUTLINE 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

SERIAL COMMUNICATION Serial = one after the other Serial Communication = sending one bit at a time over a channel Byte b0 b1 b2 b3 b4 b5 b6 b7 Serial Communication b0 b1

b2 b3 b4 b5 b6 b7 Byte b0 b1 b2 b3 b4 b5 b6 b7 PARALLEL COMMUNICATION Parallel Communication = several bits sent at a time on several parallel channels

Parallel Communication b0 Byte b0 b1 b2 b3 b4 b5 b6 b7 b1 b2

b3 b4 b5 b6 b7 Byte b0 b1 b2 b3 b4 b5 b6

b7 WHICH OF THESE DOES NOT SEND DATA IN A SERIAL STREAM? Ethernet Serial Port USB Parallel Port Fiber Optic Cable

HDMI WHICH TYPE SHOULD I USE? 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 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 Differential movie over from a hard Signal drive) Fun Fact: Longest ever deep sea Fiber-Optic cable will run through thawing artic between UK and Japan (thats 9,693 miles of cable!)

SYNCHRONOUS VS. ASYNCHRONOUS COMMUNICATION Synchronous 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

Asynchronous Serial Transmission Data transmitted one character at a time Each character contains its own clock Start bits and stop bits Resynchronizes with each character 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 S y n c h ro n o u s u s e d f o r h i g h - s p e e d c o m m u n i c a t i o n b e t w e e n c o m p u t e r s ASYNCHRONOUS COMMUNICATION Asynchronous Serial Transmission Disadvantages

Advantages Each character is its Dependence on own complete timer recognition of start bits Many bits are used only system Corruption will not for control purpose and spread carry no useful Good for irregular information Limits transmission

interval character generation speed Used for speeds up to 3000 bits/second with only Keyboards simple single-character error detection 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 Stop Bit first Signals end of data word BAUD RATES 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) BIT RATES 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 BAUD RATES EXAMPLES 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 ASYNCHRONOUS SERIAL TRANSMISSION Overhead Bits Start bit Start of frame bit Parity Bit Error check bit Stop Bits End of frame bit Data Bit the actual data START BIT 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) PARITY BIT 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 STOP BITS One+ bits

Indicate the end of transmission Usually 1 or 2 idle state bits One stop bit on the HCS12 DATA BITS 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

EXAMPLE 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 Parity Bit 0 Start Bit 1 0

1 0 1 0 1 Data Bits Direction of Transmission

1 0 1 Stop Bit TRANSMISSION ERRORS Noise Noisy signals cause bits to flip Overrun Slow receivers cause loss of data Framing Error Timing errors cause issues NOISE

Noise can cause 1 to appear to be 0 and vice verse Effect lessened by sampling NOISE Each bit after start bit is sampled X pules after center of start bit. X depends on the mode (1,16, and 64) OVERRUN Very simple concept Receiver doesnt read data in SCI data register fast enough New data lost

FRAMING ERROR 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 SCI BLOCK DIAGRAM SCI MODULE ON THE HCS12 B I L LY A L L E N 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. OVERVIEW OF SCI REGISTERS SCI DATA REGISTERS $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 t h data bit when the SCI is in 9-bit mode. R0-R7 is the data received by the SCI. SETTING THE BAUD RATE Writing to SCBIR to set the Baud Rate: $00C8 $00C9 Baud rate = SCI module clock / (16 * SCIBR[12:0])

SETTING THE BAUD RATE Example: To achieve a baud rate of 9600 with an 8MHz module clock: LDX STX #0052 (loads 52 into X) $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. SCI CONTROL REGISTER 1 $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 $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 2 $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 $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 STATUS REGISTER 1 $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 $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 2 $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. DATA TRANSMIT EXAMPLE After a short delay, send the value $AB over the Tx line with an ODD parity bit . DATA RECEIVE EXAMPLE Wait until data is received on Rx, then load it into Accumulator X.

QUESTIONS?

Recently Viewed Presentations

  • Il curricolo verticale - vallauri.edu

    Il curricolo verticale - vallauri.edu

    Conclusioni del Consiglio europeo su occupazione, riforme economiche e coesione sociale, Lisbona, 23-24 marzo 2000 * La certificazione delle competenze/1 Art. 8 del DPR n. 122 del 22 giugno 2009 - Regolamento sulla valutazione Certificazione delle competenze 1.
  • Feature Selection in Classification and R Packages

    Feature Selection in Classification and R Packages

    Feature selection methods. Wrapper methods. Select a feature subset by building classifiers e.g. LASSO (least absolute shrinkage and selection operator) [R Tibshirani, 1996] SVM-RFE (SVM with recursive feature elimination) [I Guyon, etc. 2002] RF-RFE (random forest with recursive feature elimination)...
  • Key Philosophies that Guide our Practice: Developmental ...

    Key Philosophies that Guide our Practice: Developmental ...

    Key Philosophies that Guide our Practice: Developmental Advising and Liberal Education Rosalyn Benson Lindsay Dobucki
  • CDS Business Mapping - RiskMeter Online

    CDS Business Mapping - RiskMeter Online

    Red-In the 100 year flood plain Green-Outside the 100 year flood plain Overhead View Profile View The location falls within the extents of the flood plain Base Flood Elevation (BFE) is the elevation of the surface of the water when...
  • LESSON 1 What Is Prayer? Prayer Is Communication

    LESSON 1 What Is Prayer? Prayer Is Communication

    What truth do you find about God in these accounts? How should that impact the way you pray? Share some of your findings with a friend, parent, or spiritual mentor. Take time to pray and praise God for being our...
  • Potential Energy - McMaster University

    Potential Energy - McMaster University

    What is the initial velocity of the CM of the system (neutron plus deuteron)? v0 x CM Since: Physics 1D03 - Lecture 16 * v0 CM 1/3v0 1/3v0 Physics 1D03 - Lecture 16 * Examples: A springboard diver does a...
  • Briefing the Portfolio Committee on PRESENTATION TITLE Water

    Briefing the Portfolio Committee on PRESENTATION TITLE Water

    -Presentation to support & motivation for the proposal (as presented to stakeholders, consultation tool)-Notices of consultation with customers (communication with stakeholders & invitations)
  • 11. Threads

    11. Threads

    11. Threads A way to support several parallel activities in a program Execute asynchronously and "simultaneously" e.g. timeslicing If two threads are dependent on each other synchronization may be necessary If they depend on a shared resource then deadlock, livelock...