Published on


Published in: Technology, Business
  • Be the first to comment

No Downloads
Total views
On SlideShare
From Embeds
Number of Embeds
Embeds 0
No embeds

No notes for slide

    2. 2. An Introduction to Serial communication <ul><li>As the name implies, in the Serial communication you send bits of data serially i.e. one bit at a time. </li></ul><ul><li>Normally we predefine rate of transfer such as </li></ul><ul><li>2400 bits/sec. (2400bps) </li></ul><ul><li>56,000 bits/sec. (56 kbps) </li></ul><ul><li>And then depending upon this rate we interpret bits boundaries. </li></ul>
    3. 3. Example of Serial Waveform <ul><li>For example you receive following waveform from serial port of your PC and it is stated that data rate is 2400bps </li></ul>
    4. 4. Methods of timing used to find bit boundaries <ul><li>Synchronous communication </li></ul>
    5. 5. Asynchronous Communication <ul><li>In Asynchronous communication the sender and receiver decide a data rate before communication. They decide upon signaling used for start & stop of data transmission. </li></ul><ul><li>Both sender & receiver use a precise timing reference internally to divide serial received data into bits. </li></ul>
    6. 6. Basics of Serial Communication <ul><li>Baud Rate </li></ul><ul><li>The baud rate is simply “the rate of data transmission expressed in bits per second, kilo Bits per second or Mega bits per second etc”. </li></ul><ul><li>The sender & receiver decide upon no of bits in one data word such as 8 bits (1byte) etc. More over they decide that: </li></ul><ul><li>A first bit before transmission of data word will always be 0 (or 1) after which data bits will follow. It is called start bit. </li></ul><ul><li>The last bit followed by data bits will always be 1(or 0) after which it requires start bit for transmission of next word. This bit is called stop bit </li></ul>
    7. 7. Advantage of Start / Stop bits
    8. 8. Some measures for error detection <ul><li>Parity </li></ul><ul><li>Is of two types </li></ul><ul><li>1. Even parity </li></ul><ul><li>2. Odd parity </li></ul><ul><li>Suppose your data word is 8 bit in length i.e. one byte. </li></ul><ul><li>The sender, before transmitting byte, determines whether the no of bits in the byte to be sent are even. Suppose sender’s wants to send </li></ul><ul><li>10011101 </li></ul><ul><li>In which there are 5 “ 1’s ” and 3 “ 0’s ”. </li></ul><ul><li>To keep the no. of 1’s even the sender adds an extra bit at the end of byte so that the total no. of 1’s are 6 (an even no.). This extra bits is called parity bit. Since this bit keeps the no. of 1’s even, so it is called even parity. </li></ul>
    9. 9. Overview of total bits with Parity Odd Parity Odd parity is added to keep the no. of 1’s odd in transmission. For example for above case of data being 10011101 The odd parity will be added as 0 as no of 1’s are already 5 (an odd no.).
    10. 10. Failure of Parity <ul><li>What if you transmit above byte 10011101 with even parity being used and on receiver side you receive </li></ul><ul><li>100 00 101 1 </li></ul><ul><li>shows bits inverted during transmission </li></ul><ul><li>On receiver side the no. of 1’s including parity=4 (no error for even parity). But actually it is false. </li></ul><ul><li>So parity does not ensure error detection in all cases. </li></ul>
    11. 11. EIA RS232C Serial Interface Standard <ul><li>A “Space” (logic 0) will be between 3 and 25 volts. </li></ul><ul><li>A “ Mark” (logic 1) will be between -3 and -25 volts. </li></ul><ul><li>The region between 3 & -3 volts is undefined. </li></ul><ul><li>Maximum data rates may be up to 20 kbps. </li></ul><ul><li>Maximum serial cable length may be 15 meters. </li></ul><ul><li>The reason to study RS-232C is that the serial part (Com port) found in PC’S uses this standard. </li></ul><ul><li>Above are the sufficient points to start implementation of the serial interfacing on PC. </li></ul>
    12. 12. Serial / RS-232 Port on PC & its Pin Out
    13. 13. Introduction of UART & USART <ul><li>UART – Stands for Universal Asynchronous Receiver Transmitter </li></ul><ul><li>USART – Stands for Universal Synchronous Asynchronous Receiver Transmitter </li></ul><ul><li>In RS-232 we implement serial port with UART </li></ul><ul><li>Actually UART receives/sends data to microprocessor through data bus. The remaining part of signal handing of RS-232 is done by UART i.e. start bit, stop bit, parity etc. </li></ul>
    14. 14. Port Address of Serial Part <ul><li>Name Address IRQ </li></ul><ul><li>COM 1 3F8-3FF 4 </li></ul><ul><li>COM 2 2F8-2FF 3 </li></ul><ul><li>COM 3 3E8-3EF 4 </li></ul><ul><li>COM 4 2E8-3FF 3 </li></ul>
    15. 15. Configuration of Serial Port Base Address DLAB Read/ Write Abr. Registered Mar-- +0 0 0 1 W R R/W - - - Transmit holding buffer Receive Buffer Divisor latch low byte +1 0 1 R/W R/W IER Interrupt enable register Divisor latch high byte +2 - - R W IIR FCR Interrupt Identification Register FIFO Control register. +3 +4 +5 +6 +7 - - - - - R/W R/W R R R/W LCR MCR LSR MSR - Line Control Register modem Control Register Line Status Register Modem Status Register Scratch Register.
    16. 16. Setting Baud Rate <ul><li>Usually the internal clock frequencies of UART=115, 200 Hz. </li></ul><ul><li>Suppose we want to set baud rate to 2400 bps. </li></ul><ul><li>Now we find the quotient. </li></ul><ul><li>115,200/2400=48=0x30 </li></ul><ul><li>Taking it as 16 bit no the quotient is =0x00 high byte 0x30­low byte </li></ul><ul><li>Now we set a bit DLAB (divisor latch access bit) which is bit 7 of the line control register (LCR)at base address +3 </li></ul><ul><li>Usually the command is </li></ul><ul><li>outportb(0x3f8 +3,inportb (0x3f8+3)|0x80); </li></ul>
    17. 17. Setting Baud Rate (Contd.) <ul><li>After setting DLAB bit in LCR, the function of registers at 0x3F8 & 0x3F9 changes as follows </li></ul><ul><li>Base Address Normal Function Function When DLAB=1 </li></ul><ul><li>Ox3F8 Tx/Rx register Divisor latch Low byte </li></ul><ul><li>Ox3F9 Interrupt enable register Divisor latch high byte. </li></ul><ul><li>For baud rate = 2400bps </li></ul><ul><li>Divisor Latch Low byte = 0x30 </li></ul><ul><li>Divisor Latch high byte= 0x00 </li></ul><ul><li>Loading these registers with above values configures your serial port for baud rate of 2400bps. </li></ul>
    18. 18. Specifying Start / Stop Bit & Parity <ul><li>The functionality of each bit of line control register (LCR) is shown in table below: </li></ul>
    19. 19. Bit # Functional Description 7 1 Divisor Latch Access Bit ( DLAB ON ) 0 DLAB=0, Access to Tx/Rx & IER for normal operation 6 Set Brake Enable 3:5 Bit 5 Bit 4 Bit 3 Parity Select x x 0 No Parity 0 0 1 1 0 1 0 1 1 1 1 1 Odd Parity Even Parity High Parity ( Sticky ) Low Parity ( Sticky ) 2 Length of stop bit 0 One stop bit 1 2 stop bits for words of length 6, 7 or 8 bits 1.5 stop bits for words of length 5 bits 0:1 Bit 1 Bit 0 Word Length 0 0 1 1 0 1 0 1 5 Bits 6 Bits 7 Bits 8 Bits
    20. 20. The Function of various pins on Serial Port Pin # on DB – 9 Pin Symbol Function 1 CD Carrier Detect: It is used by Modem to inform PC that it has detected Carrier on Phone Line. 2 RD Serial data is received on this line by PC. 3 TD Serial Data is transmitted on this pin by PC. 4 DTR Data Terminal Ready When terminal (computer) powers up it asserts DTR high. 5 SG It is signal ground with reference to which voltages are interpreted as high or low. 6 DSR Data Set Ready. When modem powers up it asserts DSR high. 7 RTS Request to Send. Request to send is sent from (DTE) terminal (PC) to modem (DCE) to inform it that PC wants to send some data to modem.
    21. 21. The Function of various pins on Serial Port (Contd) 8 CTS Clear To Send. Upon received RTS from DTE (PC), the modem (DCE) asserts CTS high whenever it is ready to receive data. 9 RI Ring Indicator. It is set by modem to indicate the PC that a ringing signal has been detected on line.
    22. 22. Common way of Handling Flow Control Signals. <ul><li>PC1 Serial Port PC2 Serial Port DB 9 Pins DB 9 pins </li></ul><ul><li>3 TD RD 2 </li></ul><ul><li>2 RD TD 3 </li></ul><ul><li>5 SG SG 5 </li></ul><ul><li>4 DTR DTR 4 </li></ul><ul><li>6 DSR DSR 6 </li></ul><ul><li>1 CD CD 1 </li></ul><ul><li>7 RTS RTS 7 </li></ul><ul><li>8 CTS CTS 8 </li></ul><ul><li>9 Open Ckt. 9 </li></ul>
    23. 23. Details of remaining registers <ul><li>To study details of each bit of remaining registers of serial port you can refer to the documentation provided in the document </li></ul><ul><li>“ Interfacing the Serial /RS232 port” </li></ul><ul><li>found on by Craig C Peacock </li></ul><ul><li>A discussion of important registers follows: </li></ul>
    24. 24. Modem Control Register (MCR) <ul><li>Bit Notes </li></ul><ul><li>Bit 7 Reserved </li></ul><ul><li>Bit 6 Reserved </li></ul><ul><li>Bit 5 Autoflow Control Enabled (16750 only) </li></ul><ul><li>Bit 4 LoopBack Mode </li></ul><ul><li>Bit 3 Aux Output 2 </li></ul><ul><li>Bit 2 Aux Output 1 </li></ul><ul><li>Bit 1 Force Request to Send </li></ul><ul><li>Bit 0 Force Data Terminal Ready </li></ul>
    25. 25. Modem Status Register (MSR) <ul><li>Bit Notes </li></ul><ul><li>Bit 7 Carrier Detect </li></ul><ul><li>Bit 6 Ring Indicator </li></ul><ul><li>Bit 5 Data Set Ready </li></ul><ul><li>Bit 4 Clear To Send </li></ul><ul><li>Bit 3 Delta Data Carrier Detect </li></ul><ul><li>Bit 2 Trailing Edge Ring Indicator </li></ul><ul><li>Bit 1 Delta Data Set Ready </li></ul><ul><li>Bit 0 Delta Clear to Send </li></ul>
    26. 26. Line Status Register (LSR) <ul><li>Bit Notes </li></ul><ul><li>Bit 7 Error in Received FIFO </li></ul><ul><li>Bit 6 Empty Data Holding Registers </li></ul><ul><li>Bit 5 Empty Transmitter Holding Register </li></ul><ul><li>Bit 4 Break Interrupt </li></ul><ul><li>Bit 3 Framing Error </li></ul><ul><li>Bit 2 Parity Error </li></ul><ul><li>Bit 1 Overrun Error </li></ul><ul><li>Bit 0 Data Ready </li></ul>
    27. 27. Writing a C Program to Send Serial Data to Micro-Controller for Motor Control <ul><li>#include <stdio.h> </li></ul><ul><li>#include <conio.h> </li></ul><ul><li>#define PORT1 0x3F8 </li></ul><ul><li>void main(void) </li></ul><ul><li>{ </li></ul><ul><li>int c; </li></ul><ul><li>outportb(PORT1+1,0);/* Turn off interrupts*/ </li></ul><ul><li>/* of Port1 to use software testing mode*/ </li></ul><ul><li>/* Now we set baud rate to 2400 bps */ </li></ul><ul><li>outportb(PORT1+3,0x80); /* SET DLAB ON */ </li></ul><ul><li>outportb(PORT1+0,0x30); </li></ul><ul><li>/*Divisor Latch Low Byte */ </li></ul><ul><li>outportb(PORT1 + 1 , 0x00); </li></ul><ul><li>/*Divisor Latch High Byte */ </li></ul>
    28. 28. <ul><li>outportb(PORT1+3,0x03); </li></ul><ul><li>/* 8 Bits, No Parity, 1 Stop Bit */ </li></ul><ul><li>printf(&quot;n Motor Speed Control Programn&quot;); </li></ul><ul><li>printf(&quot; Enter 27 to quit n&quot;); </li></ul><ul><li>do { </li></ul><ul><li>printf(&quot;n Please enter a number between 0 to 255 except 27 : &quot;); </li></ul><ul><li>scanf(&quot;%d&quot;,&c); </li></ul><ul><li>printf(&quot;n&quot;); </li></ul><ul><li>outportb(PORT1,c); </li></ul><ul><li>/* Send the input number to Serial Port */ </li></ul><ul><li>} while (c !=27); </li></ul><ul><li>/* Quit when 27 is entered */ </li></ul><ul><li>} </li></ul>
    29. 29. Introduction to USB <ul><li>USB –Universal Serial Bus </li></ul><ul><li>A port to provide Plug and Play peripheral connectivity. </li></ul><ul><li>Developed and Standardized by joint venture of five major companies Compaq, DEC, IBM, Intel, Microsoft, NEC and Northern Telecom . </li></ul><ul><li>An expandable bus connectivity. </li></ul><ul><li>Facilitates use of Bus Powered Devices </li></ul>
    30. 30. Advantages offered by USB <ul><li>USB provide fast data rate of transmission from 1.5 Mb/sec to 12 megabit/s </li></ul><ul><li>Single model for cabling and connectors </li></ul><ul><li>Self identifying peripherals, automatic mapping of function to driver, and configuration </li></ul><ul><li>Dynamically attachable and reconfigurable peripherals </li></ul>
    31. 31. USB implementation model
    32. 32. <ul><li> </li></ul><ul><li>Components At Your Doorstep… </li></ul><ul><li>Total Project Solutions E7/83F, Ashoka Society Arera Colony,Bhopal 462016(M.P.),India +91-9826015410/9826050109 +91-755-2420735 </li></ul>