42
Harrison Jones Alexis Noel William Allen SERIAL COMMUNICATION INTERFACE (SCI)

Serial Communication Interface (SCI)

  • Upload
    kelli

  • View
    65

  • Download
    0

Embed Size (px)

DESCRIPTION

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 - PowerPoint PPT Presentation

Citation preview

Page 1: Serial Communication Interface (SCI)

Harrison JonesAlexis NoelWilliam Allen

SERIAL COMMUNICATION

INTERFACE(SCI)

Page 2: Serial Communication Interface (SCI)

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

Page 3: Serial Communication Interface (SCI)

SERIAL COMMUNICATION

Serial = one after the otherSerial Communication = sending one bit at a

time over a channel

Byteb0 b1 b2b3 b4 b5

b6 b7

Byteb0 b1 b2b3 b4 b5

b6 b7

b0 b1 b2 b3 b4 b5 b6 b7

Serial Communication

Page 4: Serial Communication Interface (SCI)

PARALLEL COMMUNICATION

Parallel Communication = several bits sent at a time on several parallel channels

b0

Parallel Communication

b1

b2

b3

b4

b5

b6

b7

b0b1b2b3b4b5b6b7

Byteb0b1b2b3b4b5b6b7

Byte

Page 5: Serial Communication Interface (SCI)

WHICH OF THESE DOES NOT SEND DATA IN A SERIAL STREAM?

Ethernet USB

Serial Port

Fiber Optic Cable

HDMIParallel Port

Page 6: Serial Communication Interface (SCI)

WHICH TYPE SHOULD I USE?

Page 7: Serial Communication Interface (SCI)

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

Page 8: Serial Communication Interface (SCI)

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!)

Page 9: Serial Communication Interface (SCI)

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

Page 10: Serial Communication Interface (SCI)

SYNCHRONOUS COMMUNICATION

Synchronous Serial TransmissionAdvantages

• 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

Page 11: Serial Communication Interface (SCI)

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

speedUsed for speeds up to 3000 bits/second with only simple single-character error detection

Asynchronous Serial Transmission

Page 12: Serial Communication Interface (SCI)

DATA WORD AND CONTROL BITS

Asynchronous Serial TransmissionStart Bit

• Signals start of transmission of data bits• Transition from logic 1 to logic 0Data Bits• Typically 8 data bits (not including parity bit)• Least significant bit is transmitted and

received firstStop Bit• Signals end of data word

Page 13: Serial Communication Interface (SCI)

The rate at which symbols are sentMeasured 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) = 2N where N = bits / symbol N – Bits per symbol (binary = 1)

BAUD RATES

Page 14: Serial Communication Interface (SCI)

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 Rb = 1 / Tb where Tb 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!) IR = Rb * Data Bit Number / Total Bit Number

BIT RATES

Page 15: Serial Communication Interface (SCI)

Symbol Number (M) Analog modem capable 64 different voltage levels (symbols)

sends out how many bits per symbol? M = 65 = 2N. 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? IR = 9600 * log2(2) * 8/11 = 6981 data bits per second

BAUD RATES EXAMPLES

Page 16: Serial Communication Interface (SCI)

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

Page 17: Serial Communication Interface (SCI)

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

Page 18: Serial Communication Interface (SCI)

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 BitCalculated by transmitter, checked by receiver

User specified on the HCS12

PARITY BIT

Page 19: Serial Communication Interface (SCI)

One+ bits

Indicate the end of transmission

Usually 1 or 2 idle state bits

One stop bit on the HCS12

STOP BITS

Page 20: Serial Communication Interface (SCI)

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

Page 21: Serial Communication Interface (SCI)

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

0 1 0 1 0 1 0 1 1 0 1

Start Bit Stop Bit

Parity Bit

Data Bits

Direction of Transmission

Page 22: Serial Communication Interface (SCI)

Noise – Noisy signals cause bits to “flip”

Overrun – Slow receivers cause loss of data

Framing Error – Timing errors cause issues

TRANSMISSION ERRORS

Page 23: Serial Communication Interface (SCI)

Noise can cause “1” to appear to be “0” and vice verse Effect lessened by sampling

NOISE

Page 24: Serial Communication Interface (SCI)

Each bit after start bit is sampled X pules after center of start bit. X depends on the mode (1,16, and 64)

NOISE

Page 25: Serial Communication Interface (SCI)

Very simple concept

Receiver doesn’t read data in SCI data register fast enough

New data lost

OVERRUN

Page 26: Serial Communication Interface (SCI)

The result of reading incoming bits using the wrong starting point

Can be detected by using the parity bitOften the result of mismatched baud rates

FRAMING ERROR

Page 27: Serial Communication Interface (SCI)

SCI BLOCK DIAGRAM

Page 28: Serial Communication Interface (SCI)

SCI MODULE ON THE HCS12B 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.

Page 29: Serial Communication Interface (SCI)

OVERVIEW OF SCI REGISTERS

Page 30: Serial Communication Interface (SCI)

$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

Page 31: Serial Communication Interface (SCI)

Writing to SCBIR to set the Baud Rate:$00C8

$00C9

Baud rate = SCI module clock / (16 * SCIBR[12:0])

SETTING THE BAUD RATE

Page 32: Serial Communication Interface (SCI)

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

Page 33: Serial Communication Interface (SCI)

$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

Page 34: Serial Communication Interface (SCI)

$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

Page 35: Serial Communication Interface (SCI)

$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

Page 36: Serial Communication Interface (SCI)

$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

Page 37: Serial Communication Interface (SCI)

$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

Page 38: Serial Communication Interface (SCI)

$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

Page 39: Serial Communication Interface (SCI)

$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

Page 40: Serial Communication Interface (SCI)

After a short delay, send the value $AB over the Tx line with an ODD parity bit .

DATA TRANSMIT EXAMPLE

Page 41: Serial Communication Interface (SCI)

Wait until data is received on Rx, then load it into Accumulator X.

DATA RECEIVE EXAMPLE

Page 42: Serial Communication Interface (SCI)

QUESTIONS?