Sci Lecture: Dung Nguyen Joseph Glasofer Alan Carr
Sci Lecture: Dung Nguyen Joseph Glasofer Alan Carr
Dung Nguyen Joseph Glasofer Alan Carr ME 4447 March 27, 2002
What is SCI ?
RxD Receive Data Line (PD0) TxD Transmit Data Line (PD1) Access through port D in our case
Do not confuse the Baud rate with the Bit rate, they are not the same.
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
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)
$102B TCLR
RESET 0
0
0
BAUD
E-clock is scaled by the SCP0-1 and SCR02 bits Other bits are empty or for factory use only
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
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
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
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)