Sci Lecture: Dung Nguyen Joseph Glasofer Alan Carr

You might also like

Download as ppt, pdf, or txt
Download as ppt, pdf, or txt
You are on page 1of 32

SCI LECTURE

Dung Nguyen Joseph Glasofer Alan Carr ME 4447 March 27, 2002

What is SCI ?

SCI is an acronym for Serial Communication Interface

SCI Block Diagram

RxD Receive Data Line (PD0) TxD Transmit Data Line (PD1) Access through port D in our case

SCI Block Diagram Cont

Serial Data Communication


Type of data transmissions Mode of data communications Data transmission rates

Type of Data Transmission


There are two types of data transmission
Parallel data transmission Serial data transmission

Parallel Data Transmission


Parallel
Simultaneous 8-bit transmission
Requires 16 data lines Transmitter uses 8 data lines Receiver uses 8 data lines Faster than serial transmission Expensive

Serial Data Transmission


Serial
Transfers 1 bit at a time Requires two data lines One line for the transmitter One line for the receiver Can be used to connect to a terminal or PC Slower than the parallel Low cost

Mode Of Data Communications


There are two modes of data communications
Synchronous Data Communications Asynchronous Data Communications

They refer to the type of clocking used to transfer the data.

Synchronous Data Communications


Data words are locked into the system clocking Receiver and Transmitter must be synchronized because there is no two-way communication Usually, one device will request some data from other device, wait a fixed period, and then read or transmit the data

Asynchronous Data Communications


Data words are not locked into the system clocking Start and Stop bits are added into the transmitter and receiver If the receiver detects the stop bit (end of data word), it will then wait for the next data word.

Data Transmission Rate


There are two common terms used in serial data communication. Those are Baud rate and the bit rate.

Do not confuse the Baud rate with the Bit rate, they are not the same.

Baud Rate Vs Bit Rate


The baud rate includes the all the data bits The bit rate only includes the parity, and information bits See example

Baud Rate Vs Bit rate Example

Role of stop, start, and parity bits

Baud Rate Vs Bit rate Example Cont


Baud - rate (BR)
1 1 110 (baud ) bit time 9.09 ( ms)

Time to transmit one characterword (TW) T (# bits data word) 9.09 ms/bit 11 9.09E 3 .1 s Word - rate WR 1 10 characters BR 110 10 characters 8 bit/character 80 bits/sec /sec Bit - rateBTR 80bits/secincluding parity
0.1 s second

Asynchronous Serial Transmission


Data is transmitted one bit at a time Several types of bits are used to maintain the integrity between words, including:
Start Bit Data Bit Stop Bit Parity Bit

Start Bit
A bit that comes before every word Signals the receiver that a data word is about to be transmitted In the HC11, this is a low logic bit (a zero)

Data Bit
The bits that make up a data word Either a high or low logic bit (a one or a zero)

Stop Bit
Bit that comes after every data word Signals to the receiver that the data word is finished For the HC11, this is a high logic bit (a one)

Parity Bit
This is a bit before the stop bit Maintains the integrity of the word Counts the number of ones in the data word, including the parity bit Is either set to odd or even Parity bit is used to prevent noise

Noise
Noise is interference in the line Can cause the data word to be misinterpreted The parity bit can prevent a single noise signal in a data word, but would miss a double noise signal. HC11 combats this by taking three samples near the middles of each bit

SCI Registers
Port D ($1008) Port D Data Direction Register (DDRD $1009) BAUD Rate Control Register (BAUD $102B)

SCI Registers (cont.)


SCI Control Register 1 (SCCR1 - $102C) SCI Control Register 2 (SCCR2 - $102D) SCI Status Register (SCSR - $102E) SCI Data Register (SCDR - $102F)

BAUD Rate Control Register


7 6 5 4 3 2 1 0

$102B TCLR
RESET 0

0
0

SCP1 SCP0 RCKB SCR2 SCR1 SCR0


0 0 0 U U U

BAUD

E-clock is scaled by the SCP0-1 and SCR02 bits Other bits are empty or for factory use only

SCI Control Register


SCCR1

R8

T8

WAKE

$102C

R8, T8 are ninth bit when the SCI is configured for nine bits M bit is to set SCI for 8 (0) or 9 (1) bits WAKE bit is the Wake-up Method Select bit

SCI Control Register (cont.)


SCCR2

TIE

TCIE

RIE

ILIE

TE

RE

RWU

SBK

$102D

TIE stands for Transmit Interrupt Enable TCIE stands for Transmit Complete Interrupt Enable RIE stands for Receive Interrupt Enable ILIE stands for Idle-Interrupt Enable

SCI Control Register (cont.)


TE stands for Transmit Enable RE stands for Receive Enable RWU stands for Receiver Wake Up SBK stands for Send Break

SCI Status Register


SCSR

TDRE

TC

RDRF

IDLE

OR

NF

FE

$102E

TDRE stands for Transmit Data Register Empty TC stands for Transmit Complete RDRF stands for Receive Data Register Full

SCI Status Register (cont.)


IDLE stands for Idle-Line Detect OR stands for Overrun Error NF is the Noise Flag FE is the Framing Error 0 Bit is empty

SCI Data Register


SCDR

R7 T7

R6 T6

R5 T5

R4 T4

R3 T3

R2 T2

R1 T1

R0 T0

$102F

Data Register used as two separate registers Read only RDR is accessed for Receiver mode Write only TDR is accessed for Transmitter Mode

Transmitting Steps
1. 2. 3. 4. 5. 6. 7. 8. Set Baud rate to equal receiver Set TE (SCCR2) high to enable Set Wake Up mode (SCCR1) TE sends idle character to wake receiver Receiver determines if message is intended for it Load character into SCI Data Register (SCDR) Character placed in shift register and shifted out When TDRE (SCSR) sets back to 1, load another character (both polling and interrupts can be used). 9. Transmission complete (TC in SCSR) 10. Idle line rests at logic 1, RWU goes to 0

Receiving Steps
1. 2.
3.

4.

5. 6.

Set Baud rate in Baud register ($102B) Set bit 4 in SCCR1 ($102C) to select 8 or 9 bit characters; set bit 3 to select wake up mode Set bit 2 in SCCR2 ($102D) to enable receiver; set bit 4 to enable interrupt on idle; set bit 5 to enable interrupt when character received or overrun occurs. Read status of receive from SCSR ($102E) Bit 5 will be set when data is received; framing error sets bit 1; noise sets bit 2; overrun sets bit 3; idle sets bit 4 Read data received from SCDR ($102F) If 9 bit data format is used, the ninth bit of data will be located in bit 7 of SCCR1 ($102C)

You might also like