Serial Communication Interface (SCI)

Slides:



Advertisements
Similar presentations
Serial Interface Dr. Esam Al_Qaralleh CE Department
Advertisements

Adders Used to perform addition, subtraction, multiplication, and division (sometimes) Half-adder adds rightmost (least significant) bit Full-adder.
1
Copyright © 2003 Pearson Education, Inc. Slide 1 Computer Systems Organization & Architecture Chapters 8-12 John D. Carpinelli.
1 Copyright © 2013 Elsevier Inc. All rights reserved. Chapter 4 Computing Platforms.
Copyright © 2011, Elsevier Inc. All rights reserved. Chapter 6 Author: Julia Richards and R. Scott Hawley.
FIGURE 8.1 Process and controller.
1 RA I Sub-Regional Training Seminar on CLIMAT&CLIMAT TEMP Reporting Casablanca, Morocco, 20 – 22 December 2005 Status of observing programmes in RA I.
Chapter 5 Input/Output 5.1 Principles of I/O hardware
1 Chapter 11 I/O Management and Disk Scheduling Patricia Roy Manatee Community College, Venice, FL ©2008, Prentice Hall Operating Systems: Internals and.
EUSART Serial Communication.
Figure 12–1 Basic computer block diagram.
Microprocessor Architecture Pipelined Architecture
Accessing I/O Devices Processor Memory BUS I/O Device 1 I/O Device 2.
Slide 5-1 Copyright © 2004 Pearson Education, Inc. Operating Systems: A Modern Perspective, Chapter 5 5 Device Management.
Flip-Flops and Registers
1 RA III - Regional Training Seminar on CLIMAT&CLIMAT TEMP Reporting Buenos Aires, Argentina, 25 – 27 October 2006 Status of observing programmes in RA.
Basel-ICU-Journal Challenge18/20/ Basel-ICU-Journal Challenge8/20/2014.
1..
CONTROL VISION Set-up. Step 1 Step 2 Step 3 Step 5 Step 4.
INPUT-OUTPUT ORGANIZATION
Gursharan Singh Tatla PIN DIAGRAM OF 8086 Gursharan Singh Tatla Gursharan Singh Tatla
Interfacing to the Analog World
PSSA Preparation.
Essential Cell Biology
Chapter 13 Shift Registers
TCP/IP Protocol Suite 1 Chapter 18 Upon completion you will be able to: Remote Login: Telnet Understand how TELNET works Understand the role of NVT in.
Serial Communications Interface (SCI) Michael LennardZachary PetersBao Nguyen.
The 8051 Microcontroller Chapter 5 SERIAL PORT OPERATION.
H. Huang Transparency No.9-1 The HCS12/MC9S12 Microcontroller Copyright © 2010 Delmar Cengage Learning Chapter 9: Serial Communication Interface – SCI.
SCI: Serial Communications Interface Presented by: Sean Kline Chad Smith Jamie Cruce.
Serial I/O - Programmable Communication Interface
Hierarchy of I/O Control Devices
Serial Communication Interface
7-1 Digital Serial Input/Output Two basic approaches  Synchronous shared common clock signal all devices synchronised with the shared clock signal data.
Input/Output and Communication
Harrison Jones Alexis Noel William Allen SERIAL COMMUNICATION INTERFACE (SCI)
1 SCI Serial Communication Interface Gerrit Becker James McClearen Charlie Hagadorn October 21, 2004.
INPUT-OUTPUT ORGANIZATION
Serial Communication Interface (SCI) Kevin Stuart Matt Betts March 27, 2007 ME 6405, Sp 07.
Serial Peripheral Interface Module MTT M SERIAL PERIPHERAL INTERFACE (SPI)
Lecture Set 9 MCS-51 Serial Port.
Universal Synchronous/Asynchronous Receiver/Transmitter (USART)
Universal Asynchronous Receiver/Transmitter (UART)
Chapter 8 Serial and Parallel Port Interfacing Valvano’s Intro. To Embedded Systems.
Scott Baker Will Cross Belinda Frieri March 9 th, 2005 Serial Communication Overview ME4447/6405.
Advanced Microprocessor1 I/O Interface Programmable Interval Timer: 8254 Three independent 16-bit programmable counters (timers). Each capable in counting.
 8251A is a USART (Universal Synchronous Asynchronous Receiver Transmitter) for serial data communication.  Programmable peripheral designed for synchronous.
Universal Asynchronous Receiver/Transmitter (UART)
Serial Communication Interface Ta Kim Nicholas Earnhart Razid Ahmad ME 6405 – Fall 2008 November 6, 2008.
Asynchronous Serial I/O Unit 12 - Part 1. SCI Registers – Channel 0 SCI0BDH – SCI Baud Rate Register High Byte SCI0BDL – SCI Baud Rate Register Low.
ME 4447/6405 Microprocessor Control of Manufacturing Systems and
1 October 26, 2006ME 6405 MechatronicsSerial Communication Interface Brian Guerriero Jon Rogers Robert Thiets.
Serial Communications Interface Module Slide #1 of 19 MC68HC908GP20 Training PURPOSE -To explain how to configure and use the Serial Communications Interface.
Unit 1 Lecture 4.
CE-2810 Dr. Mark L. Hornick 1 Serial Communications Sending and receiving data between devices.
8251 USART.
SCI Communication Proudly Presented By: Adam Cardi & Aaron Enes.
Serial Communications
The HCS12 SCI Subsystem A HCS12 device may have one or two serial communication interface. These two SCI interfaces are referred to as SCI0 and SCI1. The.
Serial mode of data transfer
Serial I/O and Data Communication.
SERIAL PORT PROGRAMMING
1 Input-Output Organization Computer Organization Computer Architectures Lab Peripheral Devices Input-Output Interface Asynchronous Data Transfer Modes.
E3165 DIGITAL ELECTRONIC SYSTEM
UART Serial Port Programming
Serial Communication Interface
Serial Communication Interface: Using 8251
EUSART Serial Communication.
Serial Communications
Presentation transcript:

Serial Communication Interface (SCI) Ellenor Brown Howard Liles Algan Samur

Presentation Outline Types of data transmission Serial Communication Parallel Serial Serial Communication Synchronous Asynchronous Baud and Bit Rates Asynchronous Serial Transmission Start Bit Data Bit Stop Bit Parity Bit Noise SCI Registers Show two examples of how data words are transmitted Howard Liles Ellenor Brown Algan Samur

Electronic devices communicating with each other Data Transmission Power supply circuit Electronic devices communicating with each other Desktop computer Lights Turbine generators Printer Hard drive

Types of Data Transmission Serial Data Transmission One bit at a time Parallel Data Transmission One word (N bits) at a time Receiver (Monitor) Receiver (printer) = bits Word Transmitter (CPU) Transmitter (microprocessor)

Parallel vs. Serial Parallel requires more transfer lines Bits have to be synchronized Fast, but expensive Examples: Printer cables Serial requires less transfer lines Transfers one bit at a time Slow comparatively, but less expensive Examples: USB, Firewire, ethernet

Serial Communication Synchronous Serial Communication Transmitter and Receiver have synchronized clocks Data must be sent constantly in order for them to stay synchronized Any data not sent on a regular clock cycle is considered noise Transmission parameters are set up before sending data 30% faster than asynchronous transmission for large continuous blocks of data Clock rate determines data transfer rate Transmitter Receiver Asynchronous Communication Transmitter and receiver do not have synchronized clocks and act independently Simpler and less expensive than synchronous Start, Stop and Parity “caution” bits are sent with each word of data Transmitter Receiver Word

Comparisons SYNCHRONOUS ASYNCHRONOUS How It Works Clock   SYNCHRONOUS ASYNCHRONOUS How It Works Clock Start and Stop bits Advantages Lower overhead Greater throughput Faster Simple Cheap hardware Disadvantages More complex hardware More expensive Large overhead Slower Andrew Byrley

Baud and Bit Rates Baud Rate (Bd) is the rate at which Symbols are transferred. A symbol is a given signaling event ‘Symbols/second’ Number of bits per Symbol is Hardware Specific (our hardware uses 1 baud/bit) Conversion factor: 1 bit = 1 Symbol = 1 baud Bit rate (bps) - the rate at which bits are transmitted or “bits/second” Conversion Equation: Bit rate (bps) = baud rate × number of bits per baud

Baud and Bit Rates Cont.’d Some bits are data and some are not! Remember the start, stop, and parity bits which are also known as “overhead bits” Data throughput can be determined by Characters per second (cps) Cps = actual rate of data being sent 1 Standard Character = 1 Bit Characters per second (cps)=Bit rate*(character bits/total bits) *Remember CPS is not same as bytes/second. CPS does not include overhead!

Baud and Bit Rates Example You have an asynchronous serial connection. Assuming 2 bits per symbol, 9600 bd line speed, 8 bit data format with no parity, 1 start bit and 1 stop bit, calculate the throughput in cps. Bit rate (bps) = baud rate × number of bits per baud bps= 9600x2=19200 (cps)=Bit rate*(character bits/total bits) cps=19200*(8/10)= 15360

Presentation Outline Types of data transmission Serial Communication Parallel Serial Serial Communication Synchronous Asynchronous Baud and Bit Rates Asynchronous Serial Transmission Start Bit Data Bit Stop Bit Parity Bit Noise SCI Registers Show two examples of how data words are transmitted Howard Liles Ellenor Brown Algan Samur

Asynchronous Serial Communication Transmitter and Receiver are independent Transmitter sends ‘Start’, ‘Parity’ and ‘Stop’ bits with each word of data Data received between a Stop bit and the next Start bit is ignored Parity Start Transmitter Receiver Data Stop Transmitter and Receiver operate independently Transmitter sends data at any time Receiver is always ready to accept data The baud rate clock is synchronized with the bus clock and drives the receiver. The baud rate clock divided by 16 drives the transmitter. The receiver has an acquisition rate of 16 samples per bit time. No synchronized clock signals… but format and transfer rate must match during transmission The SCI allows asynchronous serial communications with peripheral devices and other CPUs.

Data Frame Format Start bit – Indicates beginning of data Data bit – Data being transmitted Parity bit – Integrity check Stop bit – Indicates end of data word Data frame size: 10 or 11 bits Parity Start Transmitter Receiver Data Stop

Start Bit One bit Indicates the beginning of word Opposite polarity from idle bit state Idle state for HCS12 is 1’s Start bit = 0 Alerts receiver that the data transmission is about to begin

Data Bits Actual data being transmitted plus a parity bit Most common mode: 8-bit transmission Used for ASCII character transmission (7-bit ASCII + 1-bit parity = 8-bit) Less common mode: 9-bit transmission Can be used to send a full byte of data + parity bit HCS12 sends least significant bit (LSB) first 128 characters 9-bit example: sending an address

Parity Bit Used to determine if an error occurred during data transmission Error Detection Transmitter calculates proper parity bit Receiver calculates parity bit based on data it received Receiver compares its parity bit to the one it received Evan Johnson

Parity Bit 2 types of Parity functionality Even Parity Odd Parity Parity bit is set to 1 if there is an odd number of 1’s in data bits  # of 1’s becomes even Odd Parity Parity bit is set to 1 if there is an even number of 1s in data bits  # of 1’s becomes odd) Even/Odd Parity is set by user on HCS12 Evan Johnson

Stop Bit 1 or 2 bits Used due to asynchronous nature Directly after the parity bit Stop bit is the same as the polarity of the data-line’s idle state Idle state for HCS12 = all 1’s Stop bits = 1 (Synchronous transmitters/receivers don’t need start/stop bits)

Asynchronous Data Transmission Example 1: Hex# 4A16 is to be sent with one start bit, even parity, 8-bit data length and one stop bit 4A16 = 0100 10102 LSB Start Bit Data Bit 0 Data Bit 1 Data Bit 2 Data Bit 3 Data Bit 4 Data Bit 5 Data Bit 6 Data Bit 7 Parity Bit Stop Bit 1 1 1 1 1

Asynchronous Data Transmission Example 2: Hex# B416 is to be sent with one start bit, even parity, 8-bit data length and one stop bit B416 = 1011 01002 Start Bit Data Bit 0 Data Bit 1 Data Bit 2 Data Bit 3 Data Bit 4 Data Bit 5 Data Bit 6 Data Bit 7 Parity Bit Stop Bit 1

Asynchronous Data Transmission Example 3: Hex# B416 is to be sent with one start bit, odd parity, 8- bit data length and one stop bit B416 = 1011 01002 Start Bit Data Bit 0 Data Bit 1 Data Bit 2 Data Bit 3 Data Bit 4 Data Bit 5 Data Bit 6 Data Bit 7 Parity Bit Stop Bit 1

Error sources Frame shift Overrun Noise Detected when a logic 0 is accepted as the stop bit Overrun Software fails to read the SCI data register before the shift register receives the next frame Noise SCI detects noise on the receiver input

Occurs when stop bit is not where receiver expects it to be Framing Error Occurs when stop bit is not where receiver expects it to be Detected when a logic 0 is accepted as the stop bit Ex: “4” bit is skipped and stop bit is one bit before it should be 1 2 3 4 5 6 7

Overrun Software fails to read the SCI data register before it receives the next frame Data in the shift register is lost Data already in the SCI data registers is not affected RECEIVER SOFTWARE REGISTER TRANSMITTER

Noise Detection SCI detects noise on the receiver input

Presentation Outline Types of data transmission Serial Communication Parallel Serial Serial Communication Synchronous Asynchronous Baud and Bit Rates Asynchronous Serial Transmission Start Bit Data Bit Stop Bit Parity Bit Noise SCI Registers Coding example Howard Liles Ellenor Brown Algan Samur

SCI Baud Rate Registers SCIBDH & SCHBDL - $00C8-$00C9 13-Bits register determines SCI Baud rate Baud rate generator is disabled until TE or RE bit is set for the first time after reset. Baud rate generator is turned off when this register contains $0000 Note: Writing to SCIBDH has no effect w/out writing to SCIBDL

Implementation Specific Features (S12SCIV2) 13-bit baud rate selection 8- or 9-bit data format Separately enabled transmitter and receiver Programmable transmitter output parity Interrupt driven operation with 8 flags 8 registers used to control SCI ($00C8-$00CF) Uses Port S pins 0 & 1 for RXD and TXD respectively

SCI Control Register 1 SCICR1 - $00CA M (data format mode) - 0: 8 data bits, 1: 9 data bits. Both use 1 start bit and 1 stop bit PE (parity enable) – 0: Off, 1: On PT (parity type) – 0: Even, 1: Odd

SCI Control Register 2 SCICR2 - $00CB TIE (transmit interrupt enable) – 0: disables interrupts for transmit data register empty, 1: enables TCIE (transmit complete interrupt enable) – 0: disables interrupts for transmit complete, 1: enables RIE (receiver interrupt enable) – 0: disables interrupts for receiver full and overrun , 1: enables ILIE (idle line interrupt enable) – 0: disables interrupts for idle line, 1: enables TE (transmit enable) – 0: disable transmitter, 1: enable RE (receiver enable) – 0: disable receiver, 1: enable

SCI Status Register 1 SCISR1 - $00CC Read only register Can be used to provide input to the microcontroller for generation of SCI interrupts TDRE (transmit data register empty) – 0: No byte transferred,1: byte successfully transferred to transmit shift register TC (transmit complete flag) – 0: transmission in progress, 1: no transmission in progress RDRF (receive data register full) – 0: no data in data register, 1: data in data register IDLE (idle flag) – 0: receiver input is active, 1: receiver input has become idle

SCI Status Register 1 SCISR1 - $00CC OR (overrun) – 0: no overrun, 1: overrun (overrun happens when new data is received before old data is read) NF (noise flag) – 0: disable, 1: enable FE (framing error flag) – 0: disable, 1: enable PF (parity error) – 0: No parity error, 1: parity error

SCI Status Register 2 SCISR2 - $00CD BK13 (break transmit character length) – 0: 10 or 11 bit, 1: 13 or 14 bit TXDIR (transmitter pin direction) – 0: TXD pin used as input, 1: TXD pin used as output. (used only in single wire mode) RAF (receiver active flag) – 0: no reception in progress, 1: reception in progress

SCI Data Registers SCIDRH &SCIDRL - $00CE - $00CF SCIRDL contains incoming bytes of data from serial port R8 – bit 8 of received 9-bit data T8 – bit 8 of transmitted 9-bit data

SCI is easy SCI module makes it easy to send/receive data SCI module encodes data into standard NRZ format! Hardest part is setting up baud rate Can use either polling or interrupt based logic to drive SCI SCIDRH/SCIDRL are like two registers in one. Read this register to receive data Write to this register to send data

SCI module runs at bus speed Desired value for SCIBR is 52 Example First, calculate baud rate. Assume 8MHz bus and desired baud rate is 9600 SCI module runs at bus speed Desired value for SCIBR is 52 You will have some error margin Exact solution is 52.0833 Actual baud rate is 9615.3 (0.160% error)

Example Write SCIBR ($0034) to SCIBDH/SCIBDL For 8-bit, no parity, no interrupts, default values will work Simply enable transmit and receive in SCICR2 Read from SCIDRL to receive 8-bit data Write data to SCIDRL to send 8-bit data

Code Example

Code Example

#include <hidef.h> /* common defines and macros */ MISC = 0x03; #include <mc9s12c32.h> /* derivative information */ PEAR = 0x0C; #pragma LINK_INFO DERIVATIVE "mc9s12c32" MODE = 0xE2; void SCI_init(void){ //Call function to setup SCI int BR = 0x0034; SCI_init(); SCIBDH = BR>>8; //stores high Byte //Main loop SCIBDL = BR; //stores low Byte while(1) { SCICR2 = 0x0C; //sets TE and RE to 1 } char data = SCI_getByte(); char SCI_getByte(void){ SCI_sendByte(data); while (!(SCISR1_RDRF)) } /* loop forever */ ;//waits FOREVER until receive register is full /* please make sure that you never leave this function */ return SCIDRL; void SCI_sendByte(char data){ while (!(SCISR1_TDRE)) ;//waits FOREVER until transmit register is empty SCIDRL = data; //return void; void main(void) { //variable declarations must go at beginning /* put your own code here */ EnableInterrupts; //required code as per instructions

Thank You! Any Questions?