SCI Serial Communication Interface

Similar documents
CS/ECE 5780/6780: Embedded System Design

ECE/CS 5780/6780: Embedded System Design

A B C D E F 0480 FE B F5 3B FC F3 E 1A 1D 2A 2D 3A 3D 4A 4D 5A 5D 6A 6D 7A 7D

Asynchronous Data Transfer

Lecture 13 Serial Interfaces

HCS12 Serial Communications Interface (SCI) Block Guide V02.06

EE 3170 Microcontroller Applications

Review for Exam 3. Write 0x05 to ATD0CTL4 to set at fastest conversion speed and 10-bit conversions

Dallas Semiconductor DS1307 Real Time Clock. The DS 1307 is a real-time clock with 56 bytes of NV (nonvolatile)

Serial Communication Prof. James L. Frankel Harvard University. Version of 2:30 PM 6-Oct-2015 Copyright 2015 James L. Frankel. All rights reserved.

Hello, and welcome to this presentation of the STM32 Low Power Universal Asynchronous Receiver/Transmitter interface. It covers the main features of

Serial communication

Informatics for industrial applications

EE 354 November 13, 2017 ARM UART Notes

Sender Receiver Sender

A Synthesizable VHDL Model of the Serial Communication Interface and. Synchronous Serial Interface of Motorola DSP56002

Fig.12.5 Serial Data Line during Serial Communication

COMP2121: Microprocessors and Interfacing

CS/ECE 5780/6780: Embedded System Design

MCS-51 Serial Port A T 8 9 C 5 2 1

Hello, and welcome to this presentation of the STM32 Universal Synchronous/Asynchronous Receiver/Transmitter Interface. It covers the main features

27.7 SCI Control Registers

Introduction to Serial Communication. ECE/CS 5780/6780: Embedded System Design. A Serial Channel. Definitions. SCI versus SPI.

ECE/CS 5780/6780: Embedded System Design. Introduction to Serial Communication

AN Multifunction Serial Interface of FM MCU. Contents. 1 Introduction

M68HC08 Microcontroller The MC68HC908GP32. General Description. MCU Block Diagram CPU08 1

8051 Serial Communication

Synchronous = SPI (3 options)

Chapter 11: Input/Output Organisation. Lesson 05: Asynchronous RS232C Serial Port data transfer

CHAPTER 4 DATA COMMUNICATION MODES

SECTION 5 RESETS AND INTERRUPTS

CoE3DJ4 Digital Systems Design. Chapter 5: Serial Port Operation

Hierarchy of I/O Control Devices

8051SERIAL PORT PROGRAMMING

RL78 Serial interfaces

Serial Interfaces Part 1. ECE 153B Sensor & Peripheral Interface Design Winter 2016

1. Specifications Functions Used Operation Software Flowcharts Program Listing... 13

19.1. Unit 19. Serial Communications

CHAPTER 5 REGISTER DESCRIPTIONS

Universal Asynchronous Receiver / Transmitter (UART)

Serial Communications

Asynchronous & Synchronous Serial Communications Interface. Student's name & ID (1): Partner's name & ID (2): Your Section number & TA's name

Understand the design and operation of the SCI and the I 2 C, IrDA and Smart Card interfaces

Addressing scheme to address a specific devices on a multi device bus Enable unaddressed devices to automatically ignore all frames

MCO556 Practice Test 2

TMS470R1x Serial Communication Interface (SCI) Reference Guide

Concepts of Serial Communication

Chapter 10 Sections 1,2,9,10 Dr. Iyad Jafar

Serial Communication. Simplex Half-Duplex Duplex

ECE251: Thursday November 8

Embedded Systems and Software. Serial Communication

CDP68HC68S1. Serial Multiplexed Bus Interface. Features. Description. Ordering Information. Pinouts. April 1994

Embedded Systems and Software

Hello, and welcome to this presentation of the STM32 I²C interface. It covers the main features of this communication interface, which is widely used

UART. ELEC 418 Advanced Digital Systems Dr. Ron Hayne. Images Courtesy of Cengage Learning

UNIT-V COMMUNICATION INTERFACE

Serial Communication

Section 6. Parallel Input/Output (I/O) Ports

DatraxRF Spread Spectrum Wireless Modem

Lecture #11 Serial Ports Embedded System Engineering Philip Koopman Wednesday, 17-February-2016

DATA COMMUNICATION. Part TWO Data Transmission

More on IO: The Universal Serial Bus (USB)

CMPE401 Computer Interfacing

HP 48 I/O Technical Interfacing Guide

Typical modules include interfaces to ARINC-429, ARINC-561, ARINC-629 and RS-422. Each module supports up to 8 Rx or 8Tx channels.

SECTION 4 Host Link Communications

ELE492 Embedded System Design

Data Transmission Definition Data Transmission Analog Transmission Digital Transmission

Menu. What is SPI? EEL 3744 EEL 3744 SPI

Advantages and disadvantages

Serial Interfacing. Pulse width of 1 bit

Chapter 2 Number Systems and Codes Dr. Xu

Serial I-O for Dinesh K. Sharma Electrical Engineering Department I.I.T. Bombay Mumbai (version 14/10/07)

Basics of UART Communication

Fast Communications Controller

Communication. Chirag Sangani

Tutorial Introduction

EEE310 MICROPROCESSORS M. Fatih Tüysüz CHAPTER 7

SERIAL COMMUNICATION BY USING UART

Input-Output Organization

INPUT-OUTPUT ORGANIZATION

In the HEW, open a new project by selecting New workspace from the main menu.

International Journal of Research in Advent Technology IMPLEMENTATION OF UNIVERSAL ASYNCHRONOUS RECEIVER TRANSMITTER BASED ON VHDL

Nios Embedded Processor UART Peripheral

I/O Organization John D. Carpinelli, All Rights Reserved 1

CAN Node using HCS12

Unit 19 - Serial Communications 19.1

Sartorius Comparator. Interface Description for the CC Model Series

Configuration of Local Interconnect Driver Based on AUTOSAR Standard

Universal Asynchronous Receiver Transmitter Communication

Emulating an asynchronous serial interface (ASC0) via software routines

lecture 22 Input / Output (I/O) 4

Interfacing a Hyper Terminal to the Flight 86 Kit

ECE 372 Microcontroller Design Parallel IO Ports - Interrupts. ECE 372 Microcontroller Design Parallel IO Ports - Interrupts

Design with Microprocessors

Module 3.F. Serial Communications Interface (SCI) Tim Rogers 2017

EET203 MICROCONTROLLER SYSTEMS DESIGN Serial Port Interfacing

EECS 373 Design of Microprocessor-Based Systems

DCB1M - Transceiver for Powerline Communication

1. Internal Architecture of 8085 Microprocessor

Transcription:

SCI Serial Communication Interface Gerrit Becker James McClearen Charlie Hagadorn October 21, 2004 1

Learning Objectives of the Overview Knowledge of the general differences between serial and parallel communication Knowledge of the differences between synchronous and asynchronous serial communication More detailed knowledge of the asynchronous serial communication (Examples) Knowledge of the difference between baud rate and bit rate (Example) 2

Types of Data Communication 2 general types of data transmission Parallel Data Communication Serial Data Communication 3

Parallel Data Communication Simultaneous 8-bit transmission Requires 8 separate data lines Bits must stay synchronized Restricted distance to avoid synchronization problems Faster than Serial transmission Expensive Example: Printer connections 1 st word Receiver 2 nd word Transmitter 4

Serial Data Communication Transfers one bit at a time Requires only one data line Slow compared to parallel transmission Less expensive Example: modem Receiver 1 st word 2 nd word Transmitter 5

Serial Data Communication Full duplex If we want to send and receive at the same time Therefore you need 2 wires, one to send, one to receive (and one extra as common ground) Number of Data bits Both, transmitter and receiver must agree on the number of send data bits Usually you use 7 or 8 bit Remark: If you use only 7 bit you send only ASCII values not greater that 127 6

Serial Data Communication Types of Serial Data Communication Synchronous Communication Asynchronous Communication 7

Synchronous Communication Transmitter and receiver have their clocks synchronized Data rates are dependent on clock rates Continuously transmitting characters to remain in sync. 8

Asynchronous Communication NO synchronization No need to send idle characters Transmitter and receiver operate independently Transmitter can send data at any time Receiver is always ready to accept data Requires a start and stop bit to identify each byte of data How does receiver know that data is arriving? If the line is idle, it is sending a constant 1 (mark state) The receiver is able to recognize a jump from 1 to 0 with the start bit and is alerted that data is about to be sent. 9

Comparison of synchronous and asynchronous communication Synchronous communication is faster but more complicated due to the clock synchronization Asynchronous communication is slower due to the additional bits but easier to accomplish 10

Asynchronous Transmission Format Bit Types Start bit Data bits Parity bit Stop bits 11

Definitions Start Bit Signals the beginning of a word Is normally a 0 and is detected as a transition from high to low Data Bits The actual data, which should be transmitted Sender and receiver have to agree on the number of data bits (usually 8) Always the least significant bit will be send first 12

Definitions cont Parity Bit An error check Odd or even parity Odd parity means the sum of the 1 s will be odd Even parity means the sum of the 1 s will be even You count all bits including the parity bit Disadvantage: If two bytes altered by noise, an error will not be detected by the parity check 13

Definitions cont Stop Bits These bits mark the end of a data word Is usually high (1) 14

Asynchronous Data Transmission Example 1: Hex# 4A 16 is to be sent with one start bit, even parity, 8-bit data length and two stop bits 4A 16 = 0100 1010 2 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 Stop Bit 0 0 1 0 1 0 0 1 0 1 1 1 15

Asynchronous Data Transmission Example 2: Hex# B4 16 is to be sent with one start bit, even parity, 8-bit data length and two stop bits B4 16 = 1011 0100 2 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 Stop Bit 0 0 0 1 0 1 1 0 1 0 1 1 16

Asynchronous Data Transmission Example 3: Hex# B4 16 is to be sent with one start bit, odd parity, 8-bit data length and two stop bits B4 16 = 1011 0100 2 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 Stop Bit 0 0 0 1 0 1 1 0 1 1 1 1 17

Baud Rate vs. Bit Rate Definition Baud Rate: Number of changing states per second Includes start, data, parity and stop bits Definition Bit Rate: Number of data bits transmitted per second Baud Rate > Bit Rate 18

Baud Rate Calculations Example: Consider baud rate: 4800 baud 12 bits/word = 1 start bit + 8 data bits + 1 parity bit + 2 stop bits Bit time = 1/(baud rate) = 1/4800baud = 0.208ms/bit Word time = (12 bits)*(bit time) = 2.5ms Word rate = 1/(word time) = 400 words/s Bit rate = (word rate)*(8 data bits) = 3200 bits/s 19

SCI Registers 5 Main Registers BAUD Sets the bit rate for the SCI system SCCR1 Sets control bits for the 9-bit character format and the receiver wake up feature SCCR2 Main control register for the SCI subsystem SCSR Status register for the SCI system SCDR Main data register for the SCI system 3 Ancillary Registers PORTD Input/Output Port D DDRD Data direction register for Port D SPCR SPI control register 20

BAUD Register Address: $102B Bit 7 6 5 4 3 2 1 Bit 0 Read: 0 0 0 SCP1 SCP0 Write: TCLR RCKB SCR2 SCR1 SCR0 Reset: 0 0 0 0 0 U U U U = Unaffected Used to set the bit rate of the SCI system TCLR Clear baud rate timing chain bit SCP1 - SCP0 Baud rate pre-scale select bits RCKB SCI baud rate clock test bit SCR2 - SCR0 SCI baud rate select bits 21

SCCR1 Register Address: $102C Bit 7 6 5 4 3 2 1 Bit 0 Read: R8 0 0 0 0 T8 M WAKE Write: Reset: U U 0 0 0 0 0 0 U = Unaffected Contains control bits related to the 9-bit data character format and the receiver wake up feature R8 Receive data bit 8 T8 Transmit data bit 8 M SCI character length bit WAKE Wakeup method select bit Bits 0-2 & 5 are not used (always 0) 22

SCCR2 Register Address: $102D Bit 7 6 5 4 3 2 1 Bit 0 Read: Write: TIE TCIE RIE ILIE TE RE RWU Reset: 0 0 0 0 0 0 0 0 U = Unaffected Main control register for SCI sub-system TIE Transmit interrupt enable bit TCIE Transmit complete interrupt enable bit RIE Receive interrupt enable bit ILIE Idle-line interrupt enable bit TE Transmit enable bit RE Receive enable bit RWU Receiver wakeup bit SBK Send break bit SBK 23

SCSR Register Address: $102E Bit 7 6 5 4 3 2 1 Bit 0 Read: TDRE TC RDRF IDLE OR NF FE 0 Write: Reset: 1 1 0 0 0 0 0 0 U = Unaffected SCI status register TDRE Transmit data register empty bit TC Transmit complete bit RDRF Receive data register full bit IDLE Idle-line detect bit OR Overrun error bit NF Noise flag FE Framing Error bit Bit 0 is not used (always 0) 24

SCDR Register Address: $102F Bit 7 6 5 4 3 2 1 Bit 0 Read: R7 R6 R5 R4 R3 R2 R1 R0 Write: T7 T6 T5 T4 T3 T2 T1 T0 Reset: Unaffected by rest U = Unaffected SCI data register Two separate registers When SCDR is read, the read-only RDR is accessed When SCDR is written, the write-only TDR is accessed R7 - R0 Read bits T7 - T0 Write bits 25

Ancillary Registers PORT D SCI uses the two least significant bits of Port D These bits are used for receiving and transmitting data Data direction register does not control Port D while SCI is in use but it is important since it will have control when the SCI operation is aborted SPCR register controls the Port D wire-or mode bit, which controls the driver functions of the Port D pins, even if they are being used by the SCI 26

Wake Up M68HC11 supports a receiver wake up function, which is intended for systems having more than one receiver The transmitting device directs messages to an individual receiver or group of receivers by passing addressing information in the initial byte Receivers not addressed activate the receiver wakeup function This makes these receivers dormant for the remainder of the unwanted message Wake up mode is enable by writing a 1 to the RWU bit in the SCCR2 register 27

Wake Up Two methods of Wakeup Idle-Line Uninterested receivers are only sent the messaging frame All receivers are awake (RWU = 0) when each message begins When a receiver detects a non-interesting message the software sets RWU = 1 This inhibits further flag setting until the RxD line goes idle at then end of the message When the idle line is detected, hardware clears the RWU bit so the first frame of the next message can be read 28

Wake Up and Send Breaks Two methods of Wakeup Address-Mark Wakeup Most significant bit is used to indicate if the message is data(0) or address(1) All receivers wake up if the bit is 1 and check to see if the message is for them Send Breaks Break characters are character-length periods where the TxD line goes to 0 Character length is influenced by the M bit in the SCCR1 M = 0 All characters are 10 bit times long M = 1 all characters are 11 bit times long Break characters have no start and stop bits 29

How to Send and Receive Data Transmitter Receiver Set Baud rate of transmitter Must match Receiver Set Baud rate of receiver Must match Transmitter Set M bit of SCCR1 for 8 or 9 bit data Must match Receiver Set M bit of SCCR1 for 8 or 9 bit data Must match Transmitter Set TE bit of SCCR2 high to enable transmitter Set RE bit of SCCR2 high to enable receiver 30

How to Send and Receive Data Transmitter Receiver Activate WAKE condition Load data character into SCDR When TDRE bit of SCSR register goes high, the SCDR register is clear and another character can be loaded Set WAKE bit on SCCR1 RDRF bit of SCSR set when all data has entered RDR Read data from RDR and Store Check flags for possible error protocols 31

How to Send and Receive Data Transmitter Receiver When TC bit of SCSR register goes high, transmit buffer clear Receiver returns to wake/sleep mode previously set Transmitter resumes Idle 32

Noise Flag HC11 Noise is detected if three samples, taken near the middle, during the data and stop bit times do not agree During the reception of the start bit, four additional samples are taken during the first half of the bit time Detects the leading edge of the bit and verification of a start bit If any of these three samples are not zero, the noise flag is set Noise Flag 0 No noise detected during reception of the character in the SCDR 1 Data recovery logic detected noise during reception of the character in the SCDR Noise flag does not generate interrupt because it is associated with RDRF RDRF = Receive Data Register Full SCDR = SCI Data Register 33

Noise Noise causes start bit to be detected too soon RT5 and RT7 are 0, so start will be accepted RT3 is 1, so noise flag will be set 34

Noise Start bit is found correctly Start accepted because RT3, RT5 and RT7 are 0 RT8 and RT10 are 1, so noise flag will be set, but bit sense is still 0, because it is start bit 35

SCI Interrupts 2 Interrupts for Transmitter TDRE enabled with TIE bit in SCCR2 TCIE enabled with TC bit in SCCR2 2 Receiver Interrupts RDRF enabled with RIE bit in SCCR2 OR enabled with RIE bit in SCCR2 One Interrupt Vector for SCI System 36