7 Serial Uart

download 7 Serial Uart

of 21

Transcript of 7 Serial Uart

  • 8/6/2019 7 Serial Uart

    1/21

    Serial Communication

    Introduction

    Parallel Communication is a communication bit of the data are

    transferred between source and destination parallelly. Example of the parallel

    communication is a port of the MCS-51 which is transfer data every bit in the

    same time.

    Serial Communication is a communication that separate data into bit

    and send the data from source and destination bit-by-bit. There are 2 major types of

    the serial communication. First type is a Synchronous Serial Communication which

    has reference clock between source and destination in order to make the data that

    transfer in communication correct. Asynchronous Serial Communication is the secondtype. In this communication, there is no clock to synchronous bit but rather use

    Band Rate in order to correct to data.

    http://www.pdfonline.com/easypdf/?gad=CLjUiqcCEgjbNejkqKEugRjG27j-AyCw_-AP
  • 8/6/2019 7 Serial Uart

    2/21

    Introduction

    Introduction

    Synchronous Serial Communication

    Asynchronous Serial Communication

    http://www.pdfonline.com/easypdf/?gad=CLjUiqcCEgjbNejkqKEugRjG27j-AyCw_-AP
  • 8/6/2019 7 Serial Uart

    3/21

    Introduction

    TxD pin 11 of the 8051 (P3.1)

    Data Transmitting Pin

    RxD pin 10 of the 8051 (P3.0)

    Data Receive Pin

    Mode of Serial Communication

    Walky-Talky

    http://www.pdfonline.com/easypdf/?gad=CLjUiqcCEgjbNejkqKEugRjG27j-AyCw_-AP
  • 8/6/2019 7 Serial Uart

    4/21

    UART

    A universal asynchronous receiver/transmitter (usually abbreviated UART)

    is a type of "asynchronous receiver/transmitter", a piece of computer hardware thattranslates data between parallel and serial forms. UARTs are commonly used in

    conjunction with other communication standards such as EIA RS-232.

    A UART is usually an individual (or part of an) integrated circuit used for

    serial communications over a computer or peripheral device serial port. UARTs are

    now commonly included in microcontrollers. A dual UART or DUART combines

    two UARTs into a single chip. Many modern ICs now come with a UART that can

    also communicate synchronously; these devices are called USARTs.

    UART

    Start bit Data Stop bit

    http://www.pdfonline.com/easypdf/?gad=CLjUiqcCEgjbNejkqKEugRjG27j-AyCw_-AP
  • 8/6/2019 7 Serial Uart

    5/21

    Baud Rate

    In telecommunications and electronics, baud, is the unit of

    symbol rate, the number of distinct symbol changes

    (signalling events) made to the transmission medium per

    second in a digitally modulated signal.

    The symbol rate (expressed in baud) is distinct from the

    bit rate (expressed in bit/s). One symbol can carry more

    than one bit of information. In voiceband modems, where

    spectral efficiency is important, it is common for one

    symbol to carry 3 or more bits.

    RS-232 Standard

    The RS-232 standard defines the voltage levels that

    correspond to logical one and logical zero levels. Valid signals are plus

    or minus 3 to 15 volts. The range near zero volts is not a valid RS-232

    level;

    logic one is defined as a negative voltage, the signal condition

    is called marking, and has the functional significance of OFF.

    Logic zero is positive, the signal condition is spacing, and has

    the function ON.

    The standard specifies a maximum open-circuit voltage of 25 volts;signal levels of 5 V,10 V,12 V, and 15 V are all commonly seen

    depending on the power supplies available within a device. RS-232

    drivers and receivers must be able to withstand indefinite short circuit

    to ground or to any voltage level up to +/-25 volts. The slew rate, or

    how fast the signal changes between levels, is also controlled.

    http://www.pdfonline.com/easypdf/?gad=CLjUiqcCEgjbNejkqKEugRjG27j-AyCw_-AP
  • 8/6/2019 7 Serial Uart

    6/21

    RS-232 Standard

    RS-232 Standard (DB-9)

    http://www.pdfonline.com/easypdf/?gad=CLjUiqcCEgjbNejkqKEugRjG27j-AyCw_-AP
  • 8/6/2019 7 Serial Uart

    7/21

    Serial Communication For Multi-CPU

    RS-232 Driver

    http://www.pdfonline.com/easypdf/?gad=CLjUiqcCEgjbNejkqKEugRjG27j-AyCw_-AP
  • 8/6/2019 7 Serial Uart

    8/21

    RS-232 Driver

    RS-232 Driver

    http://www.pdfonline.com/easypdf/?gad=CLjUiqcCEgjbNejkqKEugRjG27j-AyCw_-AP
  • 8/6/2019 7 Serial Uart

    9/21

    RS-232 Driver

    Serial Communication Register

    SBUF (Serial Buffer)

    http://www.pdfonline.com/easypdf/?gad=CLjUiqcCEgjbNejkqKEugRjG27j-AyCw_-AP
  • 8/6/2019 7 Serial Uart

    10/21

    Serial Communication Register

    SBUF (Serial Buffer)

    Serial Communication Register

    Bit interrupt from Receive DataRI (Receive interrupt flag)

    Bit interrupt from Transmit DataTI (Transmit interrupt flag)

    Enable Receive

    1 enable

    0 disable

    REN (Received enable bit)

    9th Bit for Receive Data in Mode 2,3RB8 (Receive bit #8)

    9th Bit for Transmit Data in Mode 2,3TB8 (Transmit bit #8)

    http://www.pdfonline.com/easypdf/?gad=CLjUiqcCEgjbNejkqKEugRjG27j-AyCw_-AP
  • 8/6/2019 7 Serial Uart

    11/21

    Serial Communication Register

    Variable (Set by Timer)UART 9 bit311

    Fixed (Frequency of X-tal /32 or /64)UART 9 bit201

    Variable (Set by Timer)UART 8 bit110

    Fixed (Frequency of X-tal /12)Shift Register000

    Baud RateDetailModeSM1SM0

    Serial Communication Mode 0

    In this mode, MCS-51 will receive data and send data by pin RxD and pin TxD is

    used to send Shift Clock. Eight bits are transmitted and received with the least-significant (LSB)

    first. The baud rate is fixed at 1/12th the on-chip oscillation frequency. The RxD is used for

    both data input and output and the TxD line serves as the clock. Data in this mode is only

    8 bits and baud rate is the crystal frequency divided by 12

    http://www.pdfonline.com/easypdf/?gad=CLjUiqcCEgjbNejkqKEugRjG27j-AyCw_-AP
  • 8/6/2019 7 Serial Uart

    12/21

    Serial Communication Mode 0

    Serial Communication Mode 0

    http://www.pdfonline.com/easypdf/?gad=CLjUiqcCEgjbNejkqKEugRjG27j-AyCw_-AP
  • 8/6/2019 7 Serial Uart

    13/21

    Serial Communication Mode 1,2,3

    In mode 2, MCS-51 will transmit and receive 11 bit data which is consisted of

    1 start bit 8 data bit 1 parity bit (used to check error) and 1 stop bit. Data will receive and

    transmit through SBUF Register and baud rate of the serial communication is set by SMOD.

    If SMOD in PCON register is clear then the baud rate is equal to crystal frequency / 64 and if

    it is set then baud rate equals to crystal frequency / 32.

    In mode 1, MCS-51 will transmit and receive 10 bit data which is consisted of1 start bit 8 data bit and 1 stop bit. Data will receive and transmit through SBUF Register

    and baud rate of the serial communication in this mode can be set by using Timer1

    In mode 3, MCS-51 will transmit and receive 11 bit data which is consisted of1 start bit 8 data bit 1 parity bit (used to check error) and 1 stop bit Data will receive and

    transmit through SBUF Register and baud rate of the serial communication in this mode

    can be set by using Timer1

    Baud Rate Generator Mode 1,3

    )1(32

    2RateOverflowTimerRateBaud

    SMOD

    Normally, Timer1 is used in mode 2 in order to set the baud rate

    ))]1(256[12

    (32

    2

    TH

    FrequencyOscillatorRateBaud

    SMOD

    SMOD is a bit in PCON register and called Double Baud Rate

    http://www.pdfonline.com/easypdf/?gad=CLjUiqcCEgjbNejkqKEugRjG27j-AyCw_-AP
  • 8/6/2019 7 Serial Uart

    14/21

    Baud Rate Generator Mode 1,3

    IDLPDGF0GF1------SMOD

    D7 D0

    MOV A,PCON ;place a copy of PCON in ACC

    SETB ACC.7 ;make D7=1

    MOV PCON,A ;now SMOD=1 without

    ;changing any other bits

    PCON

    Baud Rate Generator Mode 1,3

    http://www.pdfonline.com/easypdf/?gad=CLjUiqcCEgjbNejkqKEugRjG27j-AyCw_-AP
  • 8/6/2019 7 Serial Uart

    15/21

    Baud Rate Generator Mode 1,3

    Example

    if we need baud rate equal to 9600 when crystal

    of the 8051 system = 11.0592 MHz and check for Double Baud Rate

    and no Double Baud Rate

    ))]1(256[12

    100592.11(

    32

    29600

    61

    TH

    x

    TH1 = 256 6 = 250

    = FAH

    ))]1(256[12

    100592.11(

    32

    29600

    60

    TH

    x

    TH1 = 256 3 = 253

    = FDH

    Baud Rate Generator Mode 1,3

    http://www.pdfonline.com/easypdf/?gad=CLjUiqcCEgjbNejkqKEugRjG27j-AyCw_-AP
  • 8/6/2019 7 Serial Uart

    16/21

    Baud Rate Generator Mode 1,3

    Examples

    ORG 0000H ; Code Start at Address 0000H

    JMP START ; Go to Start Label

    ORG 0100H ; Code Start at Address 0100H

    START: CALL INIT_SE

    MOV A,#'1'

    CALL COUT

    MOV A,#'Y'

    CALL COUT

    JMP $

    INIT_SE: MOV SCON,#50H

    MOV TMOD,#20H

    MOV TH1,#0FDHSETB TR1

    SETB TI

    RET

    COUT: JNB TI,COUT

    CLR TI

    MOV SBUF,A

    RET

    END

    http://www.pdfonline.com/easypdf/?gad=CLjUiqcCEgjbNejkqKEugRjG27j-AyCw_-AP
  • 8/6/2019 7 Serial Uart

    17/21

    Examples

    Examples

    http://www.pdfonline.com/easypdf/?gad=CLjUiqcCEgjbNejkqKEugRjG27j-AyCw_-AP
  • 8/6/2019 7 Serial Uart

    18/21

    Examples

    Examples

    http://www.pdfonline.com/easypdf/?gad=CLjUiqcCEgjbNejkqKEugRjG27j-AyCw_-AP
  • 8/6/2019 7 Serial Uart

    19/21

    Examples

    Examples

    http://www.pdfonline.com/easypdf/?gad=CLjUiqcCEgjbNejkqKEugRjG27j-AyCw_-AP
  • 8/6/2019 7 Serial Uart

    20/21

    Examples

    Examples

    http://www.pdfonline.com/easypdf/?gad=CLjUiqcCEgjbNejkqKEugRjG27j-AyCw_-AP
  • 8/6/2019 7 Serial Uart

    21/21

    Examples

    Question ??????

    http://www.pdfonline.com/easypdf/?gad=CLjUiqcCEgjbNejkqKEugRjG27j-AyCw_-AP