1 / 24

Serial Communication

Serial Communication. Serial Communication. Sending/receiving data one bit at a time Can be: one data line : unbalanced circuit or two data line : differencial circuit Less noise than parallel communication => simple circuit and longer distance. Sample. Synchronous/Asynchronous.

theola
Download Presentation

Serial Communication

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Serial Communication

  2. Serial Communication • Sending/receiving data one bit at a time • Can be: • one data line : unbalanced circuit or • two data line : differencial circuit • Less noise than parallel communication => simple circuit and longer distance

  3. Sample

  4. Synchronous/Asynchronous • Both need clock for timing • Synchronous : timing scope normally many blocks of byte • Asynchronous : timing scope only a single byte

  5. Duplex VS Simplex • Simplex : one way communication • Duplex : two way communication at the same time • Half-duplex : two way communication not the same time

  6. Flow Control / Handshaking • When the data start • When the data end • LSB or MSB sent first • Sender and receiver is ready or not • How fast to send data • What are inside the frame

  7. Bit Rate / Baud Rate • Bit rate : how many bits can be sent in a second • Baud rate : how many time a symbol change in a second • Start from 300 > 600 > 1200 > 2400 > 4800 > 9600 > 19200 >>>>>> • With no encoding bit rate = baud rate • With encoding says 1 symbol carry 3 bit 1000 baud => 3000 bit/s

  8. Example of Serial Communications • RS232/422/485 • USB • Ethernet • Serial ATA • Firewire • Midi • ETC...

  9. RS232-C • Originate by Electronic Industries Association (EIA) • Common interface for computer terminal via telephone line • Therefore design for modem connection • IBM PC borrow to use as COM port

  10. RS232 Electrical Characteristics • High level : +5 to +15 V. • Low level : -5 to -15 V. • (TTL High:+5 V, Low:0 V) • 2 V. noise margin therefore: • High level : +3 to +15 • Low level : -3 to -15 • Logic ‘1’ : low level => marking • Logic ‘0’ : high level => spacing

  11. RS232 Electrical Characteristics

  12. RS232 Usage

  13. RS232 DB9 Pins

  14. RS232-C Null Modem • Communication without modem • PC -> PC • PC -> Printer • PC -> Devices • Must cross-over pins • Rx1 -> Tx2 • Tx1 -> Rx2

  15. Null Modem Sample 1 : No Handshaking

  16. Null Modem Sample 1 : Loop-back Handshaking

  17. 8051 Serial Communication • Built-in Universal Asynchronous Receiver Transmitter (UART) • Controlling via SCON and PCON registers • Read and write data on SBUF register

  18. UART

  19. MCS-51 Special Function Registers 8DH TH1 8CH F0H TH0 B 8BH E0H TL1 A 8AH D0H TL0 PSW 89H B8H TMOD IP 88H B0H TCON P3 87H A8H PCON IE 83H A0H DPTRH P2 82H 99H SBUF DPTRL 81H 98H SP SCON 80H 90H P0 P1

  20. B7 B6 B5 B4 B3 B2 B1 B0 SM0 SM1 SM2 REN TB8 RB8 TI RI SCON Register • SM0, SM1 serial mode • SM2 multiprocessor comm. enable • REN receiver enable • TB8 transmit bit 8, the 9th bit to transmit in mode 2 and 3 • RB8 transmit bit 8, the 9th bit received in mode 2 and 3 • TI transmit flag, set when a byte completely transmitted • RI receive flag, set when a byte completely received • MOV SCON, #01010000B

  21. SM1-SM0 Functions Baud 8-bit shift register OSC/12 00 =>0 10 =>1 8-bit UART Timer1* 10 =>2 9-bit UART OSC/64* 11 =>3 9-bit UART Timer1* SCON Modes (*) Note: Baud rate is double if PCON.7 is set Timer 1 must be in mode 2 8-bit auto reload

  22. Interrupt Jump Address Pin Reset 0000h 9 INT0 0003h 12(P3.2) Timer 0 000Bh internal INT1 0013h 13(P3.3) Timer 1 001Bh internal Serial communication 0023h internal MCS-51 Interrupt Vectors

  23. Baud Rate Calculation • TH1 = 256 – ( fosc / 384 ) / baud) • fosc = oscillator frequency => 11.0592 MHz • Example baud 9600 • TH1 = 256 – (11059200/384)/9600 • TH1 = 256 – (28800)/9600 • TH1 = 256 – 3 • TH1 = 253 = FDH

  24. Sample Code MOV TMOD, #20H ;timer1 mode 2 reload MOV TH1, #0E8H ;baud 1200 MOV TL1, #0E8H ;reload value MOV SCON, #50H ;serial in mode 1 SETB TR1 ;start timer1 MOV SBUF, #41H ;value to send LP: JNB TI, LOOP ;wait until transmision done CLR TI ;reset TI LJMP 0036H ;back to monitor

More Related