SlideShare una empresa de Scribd logo
1 de 27
Descargar para leer sin conexión
UART – Universal
    Asynchronous Receiver
         Transmitter




1               Presented by:
                Naveen Kumar
                (E.C.E)
CONTENTS
    •   Introduction to UART
    •   Basics of Serial Communication -- RS-232
    •Basic   block diagram of UART
    •Transmitter   block of UART
    •   Receiver block
    •   Interfacing with PIC microcontroller

2   •   Programming of UART
    •   Applications
INTRODUCTION OF UART &
                 USART
   UART – Stands for Universal Asynchronous Receiver Transmitter
   USART – Stands for Universal Synchronous Asynchronous Receiver Transmitter
   In RS-232 we implement serial port with UART
   Actually UART receives/sends data to microprocessor/microcontroller through data
    bus. The remaining part of signal handling of RS-232 is done by UART i.e. start bit,
    stop bit, parity etc.




                                                                                       3
WHY USE A UART?
•   A UART may be used when:
    • High speed is not required
    • An inexpensive communication link between two devices is required


•   UART communication is very cheap
      Single wire for each direction (plus ground wire)
          Asynchronous because no clock signal is transmitted
      Relatively simple hardware




                                                                          4
BASICS OF SERIAL COMMUNICATION
Bit rate:

-Number of bits sent every second (BPS)

Baud rate:

-Number of symbols sent every second, where every symbol can represent more than
one bit.

Ex. high-speed modems which use phase shifts to make every data transition period
represent more than one bit.

-For the PIC 16f877A’s USART, with every clock tick one bit is sent, each symbol
represents one bit.

-So, we can consider bit rate and baud rate the same thing.

                                                                               5
TRANSMISSION REQUIREMENT

   Before transmission begins, transmitter and receiver must agree
    on :

     - Baud rate (75, 150, 300, 600, etc)

    - 1, 1.5 or 2 stop bits

    - 5, 6, 7 or 8 data bits

    - even, odd or no parity


                                                                      6
SERIAL COMMUNICATION BLOCK
          DIAGRAM




                      PC




                             7


                                 7
EIA RS232C SERIAL INTERFACE STANDARD

 • A “Space” (logic 0) will be between 3 and 25 volts.
 • A “ Mark” (logic 1) will be between -3 and -25 volts.
 • The region between 3 & -3 volts is undefined.
 • Maximum data rates may be up to 20 kbps.
 • Maximum serial cable length may be 15 meters.
 • The reason to study RS-232C is that the serial part (Com port) found in PC’S
   uses this standard.




                                                                                  8
SERIAL / RS-232 PORT ON PC & ITS PIN
                 OUT




                                       9
RS-232 PIN ASSIGNMENT




                        10
FUNCTION OF VARIOUS PINS ON SERIAL
                  PORT
Pin No.   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.
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.
                                                                                                                11
TTL 0/5 TO RS-232 -12/12
 LEVEL CONVERSION




                           12
BASIC BLOCK DIAGRAM OF UART




                              13
UART/USART TRANSMITTER




2.The module is enabled by setting the TXEN bit.
3.Data to be sent should be written into the TXREG register. When using 9-bit,
TX9D must be written before writing TXREG.
4.Byte will be immediately transferred to the shift register TSR after the STOP
bit from the pervious load is sent.
5.From there, data will be clocked out onto the TX pin preceded by a START bit    14

and followed by a STOP bit.
TRANSMITTER CONTD.

TXIF bit : in the PIR1 register
   Indicates when data can be written to TXREG(when data is moved from
    TXREG into the Transmit Shift Register,
   It cannot be cleared in software. It will reset only when new data is loaded
    into the TXREG register.
   It doesn’t indicate that the transmission has completed.


TRMT bit:
     Once the data in the TSR register has been clocked out on the TX pin(at
    the beginning of the STOP bit), the TRMT bit in the TXSTA register will be
    set,
   Indicating that the transmission has been completed.

                                                                                   15
UART/USART RECIEVER




1. The clock of the receiver is a multiple of the bit rate, in PIC 16f877A,it’s
   x16 or x64. So, each bit is transmitted/received in 16 clock cycle.
2. If the receiver detects a start bit for a period= bit period (16 clock cycles),
   then it waits for the period of half bit, and then sample the value on the RX
   pin and shift it in the receiving shift register.
                                                                                     16
RECEIVER CONTD.
1. Every received bit is sampled at the middle of the bit’s time period.

2. The USART can be configured to receive eight or nine bits by the RX9 bit in the
   RCSTA register.

3. After the detection of a START bit, eight or nine bits of serial data are shifted
   from the RX pin into the Receive Shift Register, one bit at a time.

4. After the last bit has been shifted in, the STOP bit is checked and the data is
   moved into the FIFO buffer.

5. RCREG is the output of the two element FIFO buffer. A next start bit can be sent
   immediately after the stop bit.

6. RCIF: indicates when data is available in the RCREG.

                                                                                       17
UART CHARACTER TRANSMISSION

 • Below is a timing diagram for the transmission of a single byte

 • Uses a single wire for transmission

 • Each block represents a bit that can be a mark (logic ‘1) or space (logic
       ‘0’)                     1 bit time

mark

space
              Time


                                                                               18
UART REGISTERS
   To use and control the UART, special internal registers are assigned to them.
    Usually there will be at least four registers: control, status, receive and transmit
    registers. All these vary in size depending on the MCU.

    1) Control Register - Contains settings for the UART. Some common
    settings/features include: Number of data bits, number of stop bits, parity
    control, UART TX/RX enable/disable, baud rate setting, RX/TX interrupt
    enable,                                                                etc.

    2) Status Register - From its name, this contains information about the UART's
    condition or state. During run-time, this register may be helpful in guiding the
    processor on the next instruction to execute like when to retrieve data.
    Information that can be retrieved include: data send/receive ready, etc.

    3) Receive Register - This is the where received data is temporarily stored.

    4) Transmit Register - A buffer register/s for temporarily storing data to be sent.
                                                                                           19
UART INTERFACING




                   20
UART ALTERNATIVES

Becoming much less common

Largely been replaced by faster, more sophisticated interfaces

   PCs: USB (peripherals), Ethernet (networking)

Still used today when simple low speed communication is needed




                                                                 21
BASIC PROGRAM FOR TRANSMITTING
SERIALLY
Void main(void)
{
TRISB=0;              //initializing PORT B as an output
PORTB=0;              // clearing out PORT B
SPBRG=51;             // the hex value selected from the table
TXSTA=0B00100010;     // determining the settings for the transmitter
RCSTA=0B10010000;     // determining the settings for the receiver
TXREG=0X0;            // intializing the binary valye of the transmitted information


do                    // beginning of the endless loop from ‘do’ to ’while(1)’
{
TXREG++;              // increasing the TXREG by one
while(!TRMT);         // waiting for a whole data frame to be ready for transmission
while(!RCIF);         // waiting for a whole data frame to be received
PORTB=RCREG;          // the received data is sent to PORT B
for(i=0;i<3000;i++)   // delay in order to identify the change by looking at the LEDs
}
while(1);                                                                               22
}
APPLICATIONS
Communication between distant computers
   Serializes data to be sent to modem
   De-serializes data received from modem


                                                        Serial
                                                        Cable
                                        Phone
                                         Line


                        Phone
       Serial                                   Modem
                         Line
       Cable




                Modem


                                                                 23
APPLICATIONS CONTD.
    PC serial port is a UART!
        Serializes data to be sent over serial cable
        De-serializes received data

•   The UART is also responsible for baud rate generation.

•   This determines the speed at which data is transmitted and received. One baud
    is one bit per second (bps).

•    With modern UARTs, 230,400 baud can be achieved with a short cable length
    of a few feet.
                                                                  Serial
                                                                  Cable



                        Serial                                              Device
              Serial    Cable      Serial
               Port                 Port



                                                                                     24
SUMMARY
 To make asynchronous connection using the PIC’s USART:

• At the Transmitter end:

1. Determine the value of the SPBRG register and the BRGH-bit according to the
required baud rate.

2. The SYNC-bit [TXSTA<4>] is cleared, SPEN-bit [RCSTA<7>] is set to enable the
serial port.

3. On 9-bit data transmission, the TX9-bit [TXSTA<6>] is set.

4. TXEN-bit [TXSTA<5>] is set to enable data transmission.

5. On 9-bit data transmission, value of the ninth bit should be written to the TX9D-bit
[TXSTA<0>].

6. Transmission can be started again by writing 8-bit data to the TXREG register,
                                                                                25
usually wait for at least (1ms) between every two writes.
SUMMARY CONTD.
 At the Receiver end:

1.Determine the value of the SPBRG register and the BRGH-bit according to the
  required baud rate.

2.The SYNC-bit [TXSTA<4>] is cleared, SPEN-bit [RCSTA<7>] is set to enable the
  serial port.

3.On 9-bit data receive, the RX9-bit [RCSTA<6>] is set.

4.Data receive should be enabled by setting the CREN-bit [RCSTA<4>].

5.The RCSTA register should be read to get information on possible errors which have
  occurred during transmission.

6.On 9-bit data receive, the ninth bit will be stored in RX9D-bit [RCSTA<0>].

7.Received 8-bit data stored in the RCREG register should be read.                     26
27

Más contenido relacionado

La actualidad más candente (20)

Communication protocols - Embedded Systems
Communication protocols - Embedded SystemsCommunication protocols - Embedded Systems
Communication protocols - Embedded Systems
 
Communication protocols
Communication protocolsCommunication protocols
Communication protocols
 
8051 serial communication-UART
8051 serial communication-UART8051 serial communication-UART
8051 serial communication-UART
 
SPI Bus Protocol
SPI Bus ProtocolSPI Bus Protocol
SPI Bus Protocol
 
Uart
UartUart
Uart
 
Communication Protocols (UART, SPI,I2C)
Communication Protocols (UART, SPI,I2C)Communication Protocols (UART, SPI,I2C)
Communication Protocols (UART, SPI,I2C)
 
Serial Peripheral Interface(SPI)
Serial Peripheral Interface(SPI)Serial Peripheral Interface(SPI)
Serial Peripheral Interface(SPI)
 
Unit III ARM Interface and ARM Programming
Unit III ARM Interface and ARM Programming Unit III ARM Interface and ARM Programming
Unit III ARM Interface and ARM Programming
 
Serial Peripheral Interface
Serial Peripheral InterfaceSerial Peripheral Interface
Serial Peripheral Interface
 
UART Communication
UART CommunicationUART Communication
UART Communication
 
USART
USARTUSART
USART
 
Master synchronous serial port (mssp)
Master synchronous serial port (mssp)Master synchronous serial port (mssp)
Master synchronous serial port (mssp)
 
APB protocol v1.0
APB protocol v1.0APB protocol v1.0
APB protocol v1.0
 
Advance Peripheral Bus
Advance Peripheral Bus Advance Peripheral Bus
Advance Peripheral Bus
 
DRAM Cell - Working and Read and Write Operations
DRAM Cell - Working and Read and Write OperationsDRAM Cell - Working and Read and Write Operations
DRAM Cell - Working and Read and Write Operations
 
axi protocol
axi protocolaxi protocol
axi protocol
 
Serial Communication in 8051
Serial Communication in 8051Serial Communication in 8051
Serial Communication in 8051
 
USB protocol
USB protocolUSB protocol
USB protocol
 
8251 USART
8251 USART8251 USART
8251 USART
 
8051 Microcontroller ppt
8051 Microcontroller ppt8051 Microcontroller ppt
8051 Microcontroller ppt
 

Similar a UART

Universal Asynchronous Receive and transmit IP core
Universal Asynchronous Receive and transmit IP coreUniversal Asynchronous Receive and transmit IP core
Universal Asynchronous Receive and transmit IP coreAneesh Raveendran
 
Micro c lab8(serial communication)
Micro c lab8(serial communication)Micro c lab8(serial communication)
Micro c lab8(serial communication)Mashood
 
serial-200505101453.pdf
serial-200505101453.pdfserial-200505101453.pdf
serial-200505101453.pdfKiranG731731
 
Serial Communication
Serial CommunicationSerial Communication
Serial CommunicationUshaRani289
 
The presentation is about USART and serial communication
The presentation is about USART and serial communicationThe presentation is about USART and serial communication
The presentation is about USART and serial communicationsinaankhalil
 
Lecture 10 (serial communication)
Lecture 10 (serial communication)Lecture 10 (serial communication)
Lecture 10 (serial communication)cairo university
 
Synthesis & FPGA Implementation of UART IP Soft Core
Synthesis & FPGA Implementation of UART IP Soft CoreSynthesis & FPGA Implementation of UART IP Soft Core
Synthesis & FPGA Implementation of UART IP Soft Coreijsrd.com
 
Universal Serial Communication Interface
Universal Serial Communication InterfaceUniversal Serial Communication Interface
Universal Serial Communication InterfaceSandesh Agrawal
 
Firmware implementation of UART using Bare metal programming
Firmware implementation of UART using Bare metal programmingFirmware implementation of UART using Bare metal programming
Firmware implementation of UART using Bare metal programmingIRJET Journal
 
Gsm presentation
Gsm presentationGsm presentation
Gsm presentationsamuelhard
 
Gsm presentation
Gsm presentationGsm presentation
Gsm presentationsamuelhard
 
Serial Communication In Atmega 16
Serial Communication In Atmega 16Serial Communication In Atmega 16
Serial Communication In Atmega 16Suren Kumar
 
Microcontrollers and microprocessors in electrical communication engineering....
Microcontrollers and microprocessors in electrical communication engineering....Microcontrollers and microprocessors in electrical communication engineering....
Microcontrollers and microprocessors in electrical communication engineering....ANKUSH445845
 

Similar a UART (20)

Universal Asynchronous Receive and transmit IP core
Universal Asynchronous Receive and transmit IP coreUniversal Asynchronous Receive and transmit IP core
Universal Asynchronous Receive and transmit IP core
 
Micro c lab8(serial communication)
Micro c lab8(serial communication)Micro c lab8(serial communication)
Micro c lab8(serial communication)
 
serial-200505101453.pdf
serial-200505101453.pdfserial-200505101453.pdf
serial-200505101453.pdf
 
Serial Communication
Serial CommunicationSerial Communication
Serial Communication
 
Tutorial
TutorialTutorial
Tutorial
 
8251 USART.pptx
8251 USART.pptx8251 USART.pptx
8251 USART.pptx
 
The presentation is about USART and serial communication
The presentation is about USART and serial communicationThe presentation is about USART and serial communication
The presentation is about USART and serial communication
 
Lecture 10 _serial_communication
Lecture 10 _serial_communicationLecture 10 _serial_communication
Lecture 10 _serial_communication
 
Lecture 10 (serial communication)
Lecture 10 (serial communication)Lecture 10 (serial communication)
Lecture 10 (serial communication)
 
8251 a basic
8251 a basic8251 a basic
8251 a basic
 
Synthesis & FPGA Implementation of UART IP Soft Core
Synthesis & FPGA Implementation of UART IP Soft CoreSynthesis & FPGA Implementation of UART IP Soft Core
Synthesis & FPGA Implementation of UART IP Soft Core
 
Universal Serial Communication Interface
Universal Serial Communication InterfaceUniversal Serial Communication Interface
Universal Serial Communication Interface
 
ES UNIT3.pptx
ES UNIT3.pptxES UNIT3.pptx
ES UNIT3.pptx
 
Firmware implementation of UART using Bare metal programming
Firmware implementation of UART using Bare metal programmingFirmware implementation of UART using Bare metal programming
Firmware implementation of UART using Bare metal programming
 
Gsm presentation
Gsm presentationGsm presentation
Gsm presentation
 
Gsm presentation
Gsm presentationGsm presentation
Gsm presentation
 
Ju2416921695
Ju2416921695Ju2416921695
Ju2416921695
 
Serial Communication In Atmega 16
Serial Communication In Atmega 16Serial Communication In Atmega 16
Serial Communication In Atmega 16
 
Microcontrollers and microprocessors in electrical communication engineering....
Microcontrollers and microprocessors in electrical communication engineering....Microcontrollers and microprocessors in electrical communication engineering....
Microcontrollers and microprocessors in electrical communication engineering....
 
4 ql uart_psb_ds_revc
4 ql uart_psb_ds_revc4 ql uart_psb_ds_revc
4 ql uart_psb_ds_revc
 

Más de Naveen Kumar

Security in GSM(2G) and UMTS(3G) Networks
Security in GSM(2G) and UMTS(3G) NetworksSecurity in GSM(2G) and UMTS(3G) Networks
Security in GSM(2G) and UMTS(3G) NetworksNaveen Kumar
 
Mobile tower radiation
Mobile tower radiationMobile tower radiation
Mobile tower radiationNaveen Kumar
 
Ph.D Research proposal
Ph.D Research proposalPh.D Research proposal
Ph.D Research proposalNaveen Kumar
 
Cell Phone Antennas
Cell Phone AntennasCell Phone Antennas
Cell Phone AntennasNaveen Kumar
 
VHDL coding in Xilinx
VHDL coding in XilinxVHDL coding in Xilinx
VHDL coding in XilinxNaveen Kumar
 
Optimization in HFSS
Optimization in HFSSOptimization in HFSS
Optimization in HFSSNaveen Kumar
 
Free space optical communication
Free space optical communicationFree space optical communication
Free space optical communicationNaveen Kumar
 
A Multi-Band PIFA with Slotted Ground Plane
A Multi-Band PIFA with Slotted Ground Plane A Multi-Band PIFA with Slotted Ground Plane
A Multi-Band PIFA with Slotted Ground Plane Naveen Kumar
 
Study of Planar Inverted - F Antenna (PIFA) for mobile devices
Study of Planar Inverted - F Antenna (PIFA) for mobile devices Study of Planar Inverted - F Antenna (PIFA) for mobile devices
Study of Planar Inverted - F Antenna (PIFA) for mobile devices Naveen Kumar
 
A novel low profile planar inverted f antenna (pifa) for mobile handsets
A novel low profile planar inverted f antenna (pifa) for mobile handsetsA novel low profile planar inverted f antenna (pifa) for mobile handsets
A novel low profile planar inverted f antenna (pifa) for mobile handsetsNaveen Kumar
 
A compact planar inverted-F antenna with slotted ground plane
A compact planar inverted-F antenna with slotted ground planeA compact planar inverted-F antenna with slotted ground plane
A compact planar inverted-F antenna with slotted ground planeNaveen Kumar
 
Secure Socket Layer
Secure Socket LayerSecure Socket Layer
Secure Socket LayerNaveen Kumar
 
Adaptive Resonance Theory
Adaptive Resonance TheoryAdaptive Resonance Theory
Adaptive Resonance TheoryNaveen Kumar
 
HDLC, PPP and SLIP
HDLC, PPP and SLIPHDLC, PPP and SLIP
HDLC, PPP and SLIPNaveen Kumar
 

Más de Naveen Kumar (20)

Security in GSM(2G) and UMTS(3G) Networks
Security in GSM(2G) and UMTS(3G) NetworksSecurity in GSM(2G) and UMTS(3G) Networks
Security in GSM(2G) and UMTS(3G) Networks
 
Mobile tower radiation
Mobile tower radiationMobile tower radiation
Mobile tower radiation
 
Mobile security
Mobile securityMobile security
Mobile security
 
Ph.D Research proposal
Ph.D Research proposalPh.D Research proposal
Ph.D Research proposal
 
Wi-Fi Technology
Wi-Fi TechnologyWi-Fi Technology
Wi-Fi Technology
 
Cell Phone Antennas
Cell Phone AntennasCell Phone Antennas
Cell Phone Antennas
 
Thesis on PIFA
Thesis on PIFAThesis on PIFA
Thesis on PIFA
 
Electronics Quiz
Electronics QuizElectronics Quiz
Electronics Quiz
 
VHDL coding in Xilinx
VHDL coding in XilinxVHDL coding in Xilinx
VHDL coding in Xilinx
 
Optimization in HFSS
Optimization in HFSSOptimization in HFSS
Optimization in HFSS
 
Free space optical communication
Free space optical communicationFree space optical communication
Free space optical communication
 
A Multi-Band PIFA with Slotted Ground Plane
A Multi-Band PIFA with Slotted Ground Plane A Multi-Band PIFA with Slotted Ground Plane
A Multi-Band PIFA with Slotted Ground Plane
 
Study of Planar Inverted - F Antenna (PIFA) for mobile devices
Study of Planar Inverted - F Antenna (PIFA) for mobile devices Study of Planar Inverted - F Antenna (PIFA) for mobile devices
Study of Planar Inverted - F Antenna (PIFA) for mobile devices
 
A novel low profile planar inverted f antenna (pifa) for mobile handsets
A novel low profile planar inverted f antenna (pifa) for mobile handsetsA novel low profile planar inverted f antenna (pifa) for mobile handsets
A novel low profile planar inverted f antenna (pifa) for mobile handsets
 
A compact planar inverted-F antenna with slotted ground plane
A compact planar inverted-F antenna with slotted ground planeA compact planar inverted-F antenna with slotted ground plane
A compact planar inverted-F antenna with slotted ground plane
 
Secure Socket Layer
Secure Socket LayerSecure Socket Layer
Secure Socket Layer
 
Adaptive Resonance Theory
Adaptive Resonance TheoryAdaptive Resonance Theory
Adaptive Resonance Theory
 
HDLC, PPP and SLIP
HDLC, PPP and SLIPHDLC, PPP and SLIP
HDLC, PPP and SLIP
 
AR model
AR modelAR model
AR model
 
VLSI routing
VLSI routingVLSI routing
VLSI routing
 

Último

COMPUTER 10: Lesson 7 - File Storage and Online Collaboration
COMPUTER 10: Lesson 7 - File Storage and Online CollaborationCOMPUTER 10: Lesson 7 - File Storage and Online Collaboration
COMPUTER 10: Lesson 7 - File Storage and Online Collaborationbruanjhuli
 
ADOPTING WEB 3 FOR YOUR BUSINESS: A STEP-BY-STEP GUIDE
ADOPTING WEB 3 FOR YOUR BUSINESS: A STEP-BY-STEP GUIDEADOPTING WEB 3 FOR YOUR BUSINESS: A STEP-BY-STEP GUIDE
ADOPTING WEB 3 FOR YOUR BUSINESS: A STEP-BY-STEP GUIDELiveplex
 
UiPath Platform: The Backend Engine Powering Your Automation - Session 1
UiPath Platform: The Backend Engine Powering Your Automation - Session 1UiPath Platform: The Backend Engine Powering Your Automation - Session 1
UiPath Platform: The Backend Engine Powering Your Automation - Session 1DianaGray10
 
Linked Data in Production: Moving Beyond Ontologies
Linked Data in Production: Moving Beyond OntologiesLinked Data in Production: Moving Beyond Ontologies
Linked Data in Production: Moving Beyond OntologiesDavid Newbury
 
activity_diagram_combine_v4_20190827.pdfactivity_diagram_combine_v4_20190827.pdf
activity_diagram_combine_v4_20190827.pdfactivity_diagram_combine_v4_20190827.pdfactivity_diagram_combine_v4_20190827.pdfactivity_diagram_combine_v4_20190827.pdf
activity_diagram_combine_v4_20190827.pdfactivity_diagram_combine_v4_20190827.pdfJamie (Taka) Wang
 
Comparing Sidecar-less Service Mesh from Cilium and Istio
Comparing Sidecar-less Service Mesh from Cilium and IstioComparing Sidecar-less Service Mesh from Cilium and Istio
Comparing Sidecar-less Service Mesh from Cilium and IstioChristian Posta
 
Building AI-Driven Apps Using Semantic Kernel.pptx
Building AI-Driven Apps Using Semantic Kernel.pptxBuilding AI-Driven Apps Using Semantic Kernel.pptx
Building AI-Driven Apps Using Semantic Kernel.pptxUdaiappa Ramachandran
 
UiPath Community: AI for UiPath Automation Developers
UiPath Community: AI for UiPath Automation DevelopersUiPath Community: AI for UiPath Automation Developers
UiPath Community: AI for UiPath Automation DevelopersUiPathCommunity
 
20230202 - Introduction to tis-py
20230202 - Introduction to tis-py20230202 - Introduction to tis-py
20230202 - Introduction to tis-pyJamie (Taka) Wang
 
UiPath Studio Web workshop series - Day 8
UiPath Studio Web workshop series - Day 8UiPath Studio Web workshop series - Day 8
UiPath Studio Web workshop series - Day 8DianaGray10
 
Cybersecurity Workshop #1.pptx
Cybersecurity Workshop #1.pptxCybersecurity Workshop #1.pptx
Cybersecurity Workshop #1.pptxGDSC PJATK
 
VoIP Service and Marketing using Odoo and Asterisk PBX
VoIP Service and Marketing using Odoo and Asterisk PBXVoIP Service and Marketing using Odoo and Asterisk PBX
VoIP Service and Marketing using Odoo and Asterisk PBXTarek Kalaji
 
AI You Can Trust - Ensuring Success with Data Integrity Webinar
AI You Can Trust - Ensuring Success with Data Integrity WebinarAI You Can Trust - Ensuring Success with Data Integrity Webinar
AI You Can Trust - Ensuring Success with Data Integrity WebinarPrecisely
 
Videogame localization & technology_ how to enhance the power of translation.pdf
Videogame localization & technology_ how to enhance the power of translation.pdfVideogame localization & technology_ how to enhance the power of translation.pdf
Videogame localization & technology_ how to enhance the power of translation.pdfinfogdgmi
 
Nanopower In Semiconductor Industry.pdf
Nanopower  In Semiconductor Industry.pdfNanopower  In Semiconductor Industry.pdf
Nanopower In Semiconductor Industry.pdfPedro Manuel
 
Empowering Africa's Next Generation: The AI Leadership Blueprint
Empowering Africa's Next Generation: The AI Leadership BlueprintEmpowering Africa's Next Generation: The AI Leadership Blueprint
Empowering Africa's Next Generation: The AI Leadership BlueprintMahmoud Rabie
 
Building Your Own AI Instance (TBLC AI )
Building Your Own AI Instance (TBLC AI )Building Your Own AI Instance (TBLC AI )
Building Your Own AI Instance (TBLC AI )Brian Pichman
 
UiPath Studio Web workshop series - Day 6
UiPath Studio Web workshop series - Day 6UiPath Studio Web workshop series - Day 6
UiPath Studio Web workshop series - Day 6DianaGray10
 

Último (20)

COMPUTER 10: Lesson 7 - File Storage and Online Collaboration
COMPUTER 10: Lesson 7 - File Storage and Online CollaborationCOMPUTER 10: Lesson 7 - File Storage and Online Collaboration
COMPUTER 10: Lesson 7 - File Storage and Online Collaboration
 
ADOPTING WEB 3 FOR YOUR BUSINESS: A STEP-BY-STEP GUIDE
ADOPTING WEB 3 FOR YOUR BUSINESS: A STEP-BY-STEP GUIDEADOPTING WEB 3 FOR YOUR BUSINESS: A STEP-BY-STEP GUIDE
ADOPTING WEB 3 FOR YOUR BUSINESS: A STEP-BY-STEP GUIDE
 
UiPath Platform: The Backend Engine Powering Your Automation - Session 1
UiPath Platform: The Backend Engine Powering Your Automation - Session 1UiPath Platform: The Backend Engine Powering Your Automation - Session 1
UiPath Platform: The Backend Engine Powering Your Automation - Session 1
 
Linked Data in Production: Moving Beyond Ontologies
Linked Data in Production: Moving Beyond OntologiesLinked Data in Production: Moving Beyond Ontologies
Linked Data in Production: Moving Beyond Ontologies
 
activity_diagram_combine_v4_20190827.pdfactivity_diagram_combine_v4_20190827.pdf
activity_diagram_combine_v4_20190827.pdfactivity_diagram_combine_v4_20190827.pdfactivity_diagram_combine_v4_20190827.pdfactivity_diagram_combine_v4_20190827.pdf
activity_diagram_combine_v4_20190827.pdfactivity_diagram_combine_v4_20190827.pdf
 
Comparing Sidecar-less Service Mesh from Cilium and Istio
Comparing Sidecar-less Service Mesh from Cilium and IstioComparing Sidecar-less Service Mesh from Cilium and Istio
Comparing Sidecar-less Service Mesh from Cilium and Istio
 
Building AI-Driven Apps Using Semantic Kernel.pptx
Building AI-Driven Apps Using Semantic Kernel.pptxBuilding AI-Driven Apps Using Semantic Kernel.pptx
Building AI-Driven Apps Using Semantic Kernel.pptx
 
201610817 - edge part1
201610817 - edge part1201610817 - edge part1
201610817 - edge part1
 
UiPath Community: AI for UiPath Automation Developers
UiPath Community: AI for UiPath Automation DevelopersUiPath Community: AI for UiPath Automation Developers
UiPath Community: AI for UiPath Automation Developers
 
20230202 - Introduction to tis-py
20230202 - Introduction to tis-py20230202 - Introduction to tis-py
20230202 - Introduction to tis-py
 
UiPath Studio Web workshop series - Day 8
UiPath Studio Web workshop series - Day 8UiPath Studio Web workshop series - Day 8
UiPath Studio Web workshop series - Day 8
 
Cybersecurity Workshop #1.pptx
Cybersecurity Workshop #1.pptxCybersecurity Workshop #1.pptx
Cybersecurity Workshop #1.pptx
 
VoIP Service and Marketing using Odoo and Asterisk PBX
VoIP Service and Marketing using Odoo and Asterisk PBXVoIP Service and Marketing using Odoo and Asterisk PBX
VoIP Service and Marketing using Odoo and Asterisk PBX
 
AI You Can Trust - Ensuring Success with Data Integrity Webinar
AI You Can Trust - Ensuring Success with Data Integrity WebinarAI You Can Trust - Ensuring Success with Data Integrity Webinar
AI You Can Trust - Ensuring Success with Data Integrity Webinar
 
Videogame localization & technology_ how to enhance the power of translation.pdf
Videogame localization & technology_ how to enhance the power of translation.pdfVideogame localization & technology_ how to enhance the power of translation.pdf
Videogame localization & technology_ how to enhance the power of translation.pdf
 
Nanopower In Semiconductor Industry.pdf
Nanopower  In Semiconductor Industry.pdfNanopower  In Semiconductor Industry.pdf
Nanopower In Semiconductor Industry.pdf
 
20230104 - machine vision
20230104 - machine vision20230104 - machine vision
20230104 - machine vision
 
Empowering Africa's Next Generation: The AI Leadership Blueprint
Empowering Africa's Next Generation: The AI Leadership BlueprintEmpowering Africa's Next Generation: The AI Leadership Blueprint
Empowering Africa's Next Generation: The AI Leadership Blueprint
 
Building Your Own AI Instance (TBLC AI )
Building Your Own AI Instance (TBLC AI )Building Your Own AI Instance (TBLC AI )
Building Your Own AI Instance (TBLC AI )
 
UiPath Studio Web workshop series - Day 6
UiPath Studio Web workshop series - Day 6UiPath Studio Web workshop series - Day 6
UiPath Studio Web workshop series - Day 6
 

UART

  • 1. UART – Universal Asynchronous Receiver Transmitter 1 Presented by: Naveen Kumar (E.C.E)
  • 2. CONTENTS • Introduction to UART • Basics of Serial Communication -- RS-232 •Basic block diagram of UART •Transmitter block of UART • Receiver block • Interfacing with PIC microcontroller 2 • Programming of UART • Applications
  • 3. INTRODUCTION OF UART & USART  UART – Stands for Universal Asynchronous Receiver Transmitter  USART – Stands for Universal Synchronous Asynchronous Receiver Transmitter  In RS-232 we implement serial port with UART  Actually UART receives/sends data to microprocessor/microcontroller through data bus. The remaining part of signal handling of RS-232 is done by UART i.e. start bit, stop bit, parity etc. 3
  • 4. WHY USE A UART? • A UART may be used when: • High speed is not required • An inexpensive communication link between two devices is required • UART communication is very cheap Single wire for each direction (plus ground wire) Asynchronous because no clock signal is transmitted Relatively simple hardware 4
  • 5. BASICS OF SERIAL COMMUNICATION Bit rate: -Number of bits sent every second (BPS) Baud rate: -Number of symbols sent every second, where every symbol can represent more than one bit. Ex. high-speed modems which use phase shifts to make every data transition period represent more than one bit. -For the PIC 16f877A’s USART, with every clock tick one bit is sent, each symbol represents one bit. -So, we can consider bit rate and baud rate the same thing. 5
  • 6. TRANSMISSION REQUIREMENT  Before transmission begins, transmitter and receiver must agree on : - Baud rate (75, 150, 300, 600, etc) - 1, 1.5 or 2 stop bits - 5, 6, 7 or 8 data bits - even, odd or no parity 6
  • 7. SERIAL COMMUNICATION BLOCK DIAGRAM PC 7 7
  • 8. EIA RS232C SERIAL INTERFACE STANDARD • A “Space” (logic 0) will be between 3 and 25 volts. • A “ Mark” (logic 1) will be between -3 and -25 volts. • The region between 3 & -3 volts is undefined. • Maximum data rates may be up to 20 kbps. • Maximum serial cable length may be 15 meters. • The reason to study RS-232C is that the serial part (Com port) found in PC’S uses this standard. 8
  • 9. SERIAL / RS-232 PORT ON PC & ITS PIN OUT 9
  • 11. FUNCTION OF VARIOUS PINS ON SERIAL PORT Pin No. 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. 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. 11
  • 12. TTL 0/5 TO RS-232 -12/12 LEVEL CONVERSION 12
  • 13. BASIC BLOCK DIAGRAM OF UART 13
  • 14. UART/USART TRANSMITTER 2.The module is enabled by setting the TXEN bit. 3.Data to be sent should be written into the TXREG register. When using 9-bit, TX9D must be written before writing TXREG. 4.Byte will be immediately transferred to the shift register TSR after the STOP bit from the pervious load is sent. 5.From there, data will be clocked out onto the TX pin preceded by a START bit 14 and followed by a STOP bit.
  • 15. TRANSMITTER CONTD. TXIF bit : in the PIR1 register  Indicates when data can be written to TXREG(when data is moved from TXREG into the Transmit Shift Register,  It cannot be cleared in software. It will reset only when new data is loaded into the TXREG register.  It doesn’t indicate that the transmission has completed. TRMT bit:  Once the data in the TSR register has been clocked out on the TX pin(at the beginning of the STOP bit), the TRMT bit in the TXSTA register will be set,  Indicating that the transmission has been completed. 15
  • 16. UART/USART RECIEVER 1. The clock of the receiver is a multiple of the bit rate, in PIC 16f877A,it’s x16 or x64. So, each bit is transmitted/received in 16 clock cycle. 2. If the receiver detects a start bit for a period= bit period (16 clock cycles), then it waits for the period of half bit, and then sample the value on the RX pin and shift it in the receiving shift register. 16
  • 17. RECEIVER CONTD. 1. Every received bit is sampled at the middle of the bit’s time period. 2. The USART can be configured to receive eight or nine bits by the RX9 bit in the RCSTA register. 3. After the detection of a START bit, eight or nine bits of serial data are shifted from the RX pin into the Receive Shift Register, one bit at a time. 4. After the last bit has been shifted in, the STOP bit is checked and the data is moved into the FIFO buffer. 5. RCREG is the output of the two element FIFO buffer. A next start bit can be sent immediately after the stop bit. 6. RCIF: indicates when data is available in the RCREG. 17
  • 18. UART CHARACTER TRANSMISSION • Below is a timing diagram for the transmission of a single byte • Uses a single wire for transmission • Each block represents a bit that can be a mark (logic ‘1) or space (logic ‘0’) 1 bit time mark space Time 18
  • 19. UART REGISTERS  To use and control the UART, special internal registers are assigned to them. Usually there will be at least four registers: control, status, receive and transmit registers. All these vary in size depending on the MCU.  1) Control Register - Contains settings for the UART. Some common settings/features include: Number of data bits, number of stop bits, parity control, UART TX/RX enable/disable, baud rate setting, RX/TX interrupt enable, etc. 2) Status Register - From its name, this contains information about the UART's condition or state. During run-time, this register may be helpful in guiding the processor on the next instruction to execute like when to retrieve data. Information that can be retrieved include: data send/receive ready, etc. 3) Receive Register - This is the where received data is temporarily stored. 4) Transmit Register - A buffer register/s for temporarily storing data to be sent. 19
  • 21. UART ALTERNATIVES Becoming much less common Largely been replaced by faster, more sophisticated interfaces PCs: USB (peripherals), Ethernet (networking) Still used today when simple low speed communication is needed 21
  • 22. BASIC PROGRAM FOR TRANSMITTING SERIALLY Void main(void) { TRISB=0; //initializing PORT B as an output PORTB=0; // clearing out PORT B SPBRG=51; // the hex value selected from the table TXSTA=0B00100010; // determining the settings for the transmitter RCSTA=0B10010000; // determining the settings for the receiver TXREG=0X0; // intializing the binary valye of the transmitted information do // beginning of the endless loop from ‘do’ to ’while(1)’ { TXREG++; // increasing the TXREG by one while(!TRMT); // waiting for a whole data frame to be ready for transmission while(!RCIF); // waiting for a whole data frame to be received PORTB=RCREG; // the received data is sent to PORT B for(i=0;i<3000;i++) // delay in order to identify the change by looking at the LEDs } while(1); 22 }
  • 23. APPLICATIONS Communication between distant computers Serializes data to be sent to modem De-serializes data received from modem Serial Cable Phone Line Phone Serial Modem Line Cable Modem 23
  • 24. APPLICATIONS CONTD. PC serial port is a UART! Serializes data to be sent over serial cable De-serializes received data • The UART is also responsible for baud rate generation. • This determines the speed at which data is transmitted and received. One baud is one bit per second (bps). • With modern UARTs, 230,400 baud can be achieved with a short cable length of a few feet. Serial Cable Serial Device Serial Cable Serial Port Port 24
  • 25. SUMMARY  To make asynchronous connection using the PIC’s USART: • At the Transmitter end: 1. Determine the value of the SPBRG register and the BRGH-bit according to the required baud rate. 2. The SYNC-bit [TXSTA<4>] is cleared, SPEN-bit [RCSTA<7>] is set to enable the serial port. 3. On 9-bit data transmission, the TX9-bit [TXSTA<6>] is set. 4. TXEN-bit [TXSTA<5>] is set to enable data transmission. 5. On 9-bit data transmission, value of the ninth bit should be written to the TX9D-bit [TXSTA<0>]. 6. Transmission can be started again by writing 8-bit data to the TXREG register, 25 usually wait for at least (1ms) between every two writes.
  • 26. SUMMARY CONTD.  At the Receiver end: 1.Determine the value of the SPBRG register and the BRGH-bit according to the required baud rate. 2.The SYNC-bit [TXSTA<4>] is cleared, SPEN-bit [RCSTA<7>] is set to enable the serial port. 3.On 9-bit data receive, the RX9-bit [RCSTA<6>] is set. 4.Data receive should be enabled by setting the CREN-bit [RCSTA<4>]. 5.The RCSTA register should be read to get information on possible errors which have occurred during transmission. 6.On 9-bit data receive, the ninth bit will be stored in RX9D-bit [RCSTA<0>]. 7.Received 8-bit data stored in the RCREG register should be read. 26
  • 27. 27