UART

Naveen Kumar
Naveen KumarExecutive Director at ASPL, Editor-in-Chief at Elixir Publications à Elixir Publications
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
1 sur 27

Recommandé

Uart par
UartUart
UartAditee Apurvaa
4.2K vues70 diapositives
UART par
UARTUART
UARTSomdatta Ganguly
963 vues20 diapositives
Uart par
UartUart
Uartمحمدعبد الحى
3.8K vues27 diapositives
I2C Protocol par
I2C ProtocolI2C Protocol
I2C ProtocolSudhanshu Janwadkar
11.4K vues30 diapositives
SPI Bus Protocol par
SPI Bus ProtocolSPI Bus Protocol
SPI Bus ProtocolSudhanshu Janwadkar
6.9K vues20 diapositives
I2C Bus (Inter-Integrated Circuit) par
I2C Bus (Inter-Integrated Circuit)I2C Bus (Inter-Integrated Circuit)
I2C Bus (Inter-Integrated Circuit)Varun Mahajan
17.5K vues21 diapositives

Contenu connexe

Tendances

Serial Communication Interfaces par
Serial Communication InterfacesSerial Communication Interfaces
Serial Communication Interfacesanishgoel
16.8K vues27 diapositives
Uart par
UartUart
UartAnkit Singh
6.1K vues39 diapositives
I2C Protocol par
I2C ProtocolI2C Protocol
I2C ProtocolAnurag Tomar
4.2K vues21 diapositives
PIC 16F877A by PARTHIBAN. S. par
PIC 16F877A   by PARTHIBAN. S.PIC 16F877A   by PARTHIBAN. S.
PIC 16F877A by PARTHIBAN. S.parthi_arjun
33.7K vues35 diapositives
RS 232 par
RS 232RS 232
RS 232Sandeep Kamath
19.5K vues14 diapositives
ARM Processors par
ARM ProcessorsARM Processors
ARM ProcessorsMathivanan Natarajan
12.7K vues32 diapositives

Tendances(20)

Serial Communication Interfaces par anishgoel
Serial Communication InterfacesSerial Communication Interfaces
Serial Communication Interfaces
anishgoel16.8K vues
PIC 16F877A by PARTHIBAN. S. par parthi_arjun
PIC 16F877A   by PARTHIBAN. S.PIC 16F877A   by PARTHIBAN. S.
PIC 16F877A by PARTHIBAN. S.
parthi_arjun33.7K vues
Rs232 485 fundamental par rounak077
Rs232 485 fundamentalRs232 485 fundamental
Rs232 485 fundamental
rounak07713.7K vues
Microprocessor 8085 complete par Shubham Singh
Microprocessor 8085 completeMicroprocessor 8085 complete
Microprocessor 8085 complete
Shubham Singh37.2K vues
I2C And SPI Part-23 par Techvilla
I2C And  SPI Part-23I2C And  SPI Part-23
I2C And SPI Part-23
Techvilla1.3K vues
SPI introduction(Serial Peripheral Interface) par SUNODH GARLAPATI
SPI introduction(Serial Peripheral Interface)SPI introduction(Serial Peripheral Interface)
SPI introduction(Serial Peripheral Interface)
SUNODH GARLAPATI1.5K vues

Similaire à UART

Universal Asynchronous Receive and transmit IP core par
Universal Asynchronous Receive and transmit IP coreUniversal Asynchronous Receive and transmit IP core
Universal Asynchronous Receive and transmit IP coreAneesh Raveendran
591 vues26 diapositives
Micro c lab8(serial communication) par
Micro c lab8(serial communication)Micro c lab8(serial communication)
Micro c lab8(serial communication)Mashood
364 vues18 diapositives
serial-200505101453.pdf par
serial-200505101453.pdfserial-200505101453.pdf
serial-200505101453.pdfKiranG731731
1 vue39 diapositives
Serial Communication par
Serial CommunicationSerial Communication
Serial CommunicationUshaRani289
1.4K vues39 diapositives
Tutorial par
TutorialTutorial
TutorialROBOTZLABZ
432 vues15 diapositives
lect7-181009123028 (1).pptx par
lect7-181009123028 (1).pptxlect7-181009123028 (1).pptx
lect7-181009123028 (1).pptxKiranG731731
1 vue48 diapositives

Similaire à UART(20)

Universal Asynchronous Receive and transmit IP core par Aneesh Raveendran
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) par Mashood
Micro c lab8(serial communication)Micro c lab8(serial communication)
Micro c lab8(serial communication)
Mashood364 vues
Serial Communication par UshaRani289
Serial CommunicationSerial Communication
Serial Communication
UshaRani2891.4K vues
Synthesis & FPGA Implementation of UART IP Soft Core par ijsrd.com
Synthesis & FPGA Implementation of UART IP Soft CoreSynthesis & FPGA Implementation of UART IP Soft Core
Synthesis & FPGA Implementation of UART IP Soft Core
ijsrd.com834 vues
Universal Serial Communication Interface par Sandesh Agrawal
Universal Serial Communication InterfaceUniversal Serial Communication Interface
Universal Serial Communication Interface
Sandesh Agrawal4.4K vues
Gsm presentation par samuelhard
Gsm presentationGsm presentation
Gsm presentation
samuelhard5.6K vues
Serial Communication In Atmega 16 par Suren Kumar
Serial Communication In Atmega 16Serial Communication In Atmega 16
Serial Communication In Atmega 16
Suren Kumar13.2K vues

Plus de Naveen Kumar

Security in GSM(2G) and UMTS(3G) Networks par
Security in GSM(2G) and UMTS(3G) NetworksSecurity in GSM(2G) and UMTS(3G) Networks
Security in GSM(2G) and UMTS(3G) NetworksNaveen Kumar
16.2K vues26 diapositives
Mobile tower radiation par
Mobile tower radiationMobile tower radiation
Mobile tower radiationNaveen Kumar
27.7K vues17 diapositives
Mobile security par
Mobile securityMobile security
Mobile securityNaveen Kumar
3.1K vues17 diapositives
Ph.D Research proposal par
Ph.D Research proposalPh.D Research proposal
Ph.D Research proposalNaveen Kumar
10.5K vues18 diapositives
Wi-Fi Technology par
Wi-Fi TechnologyWi-Fi Technology
Wi-Fi TechnologyNaveen Kumar
113.6K vues45 diapositives
Cell Phone Antennas par
Cell Phone AntennasCell Phone Antennas
Cell Phone AntennasNaveen Kumar
41.1K vues24 diapositives

Plus de Naveen Kumar(20)

Security in GSM(2G) and UMTS(3G) Networks par Naveen Kumar
Security in GSM(2G) and UMTS(3G) NetworksSecurity in GSM(2G) and UMTS(3G) Networks
Security in GSM(2G) and UMTS(3G) Networks
Naveen Kumar16.2K vues
Mobile tower radiation par Naveen Kumar
Mobile tower radiationMobile tower radiation
Mobile tower radiation
Naveen Kumar27.7K vues
Ph.D Research proposal par Naveen Kumar
Ph.D Research proposalPh.D Research proposal
Ph.D Research proposal
Naveen Kumar10.5K vues
Wi-Fi Technology par Naveen Kumar
Wi-Fi TechnologyWi-Fi Technology
Wi-Fi Technology
Naveen Kumar113.6K vues
Cell Phone Antennas par Naveen Kumar
Cell Phone AntennasCell Phone Antennas
Cell Phone Antennas
Naveen Kumar41.1K vues
VHDL coding in Xilinx par Naveen Kumar
VHDL coding in XilinxVHDL coding in Xilinx
VHDL coding in Xilinx
Naveen Kumar10.8K vues
Free space optical communication par Naveen Kumar
Free space optical communicationFree space optical communication
Free space optical communication
Naveen Kumar36.4K vues
A Multi-Band PIFA with Slotted Ground Plane par Naveen 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
Naveen Kumar1.9K vues
Study of Planar Inverted - F Antenna (PIFA) for mobile devices par 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
Naveen Kumar6.7K vues
A novel low profile planar inverted f antenna (pifa) for mobile handsets par Naveen Kumar
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
Naveen Kumar2K vues
A compact planar inverted-F antenna with slotted ground plane par Naveen Kumar
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
Naveen Kumar1.9K vues
Adaptive Resonance Theory par Naveen Kumar
Adaptive Resonance TheoryAdaptive Resonance Theory
Adaptive Resonance Theory
Naveen Kumar34.4K vues

Dernier

CXL at OCP par
CXL at OCPCXL at OCP
CXL at OCPCXL Forum
208 vues66 diapositives
Java Platform Approach 1.0 - Picnic Meetup par
Java Platform Approach 1.0 - Picnic MeetupJava Platform Approach 1.0 - Picnic Meetup
Java Platform Approach 1.0 - Picnic MeetupRick Ossendrijver
25 vues39 diapositives
Transcript: The Details of Description Techniques tips and tangents on altern... par
Transcript: The Details of Description Techniques tips and tangents on altern...Transcript: The Details of Description Techniques tips and tangents on altern...
Transcript: The Details of Description Techniques tips and tangents on altern...BookNet Canada
119 vues15 diapositives
"How we switched to Kanban and how it integrates with product planning", Vady... par
"How we switched to Kanban and how it integrates with product planning", Vady..."How we switched to Kanban and how it integrates with product planning", Vady...
"How we switched to Kanban and how it integrates with product planning", Vady...Fwdays
61 vues24 diapositives
Photowave Presentation Slides - 11.8.23.pptx par
Photowave Presentation Slides - 11.8.23.pptxPhotowave Presentation Slides - 11.8.23.pptx
Photowave Presentation Slides - 11.8.23.pptxCXL Forum
126 vues16 diapositives
AI: mind, matter, meaning, metaphors, being, becoming, life values par
AI: mind, matter, meaning, metaphors, being, becoming, life valuesAI: mind, matter, meaning, metaphors, being, becoming, life values
AI: mind, matter, meaning, metaphors, being, becoming, life valuesTwain Liu 刘秋艳
34 vues16 diapositives

Dernier(20)

Transcript: The Details of Description Techniques tips and tangents on altern... par BookNet Canada
Transcript: The Details of Description Techniques tips and tangents on altern...Transcript: The Details of Description Techniques tips and tangents on altern...
Transcript: The Details of Description Techniques tips and tangents on altern...
BookNet Canada119 vues
"How we switched to Kanban and how it integrates with product planning", Vady... par Fwdays
"How we switched to Kanban and how it integrates with product planning", Vady..."How we switched to Kanban and how it integrates with product planning", Vady...
"How we switched to Kanban and how it integrates with product planning", Vady...
Fwdays61 vues
Photowave Presentation Slides - 11.8.23.pptx par CXL Forum
Photowave Presentation Slides - 11.8.23.pptxPhotowave Presentation Slides - 11.8.23.pptx
Photowave Presentation Slides - 11.8.23.pptx
CXL Forum126 vues
AI: mind, matter, meaning, metaphors, being, becoming, life values par Twain Liu 刘秋艳
AI: mind, matter, meaning, metaphors, being, becoming, life valuesAI: mind, matter, meaning, metaphors, being, becoming, life values
AI: mind, matter, meaning, metaphors, being, becoming, life values
PharoJS - Zürich Smalltalk Group Meetup November 2023 par Noury Bouraqadi
PharoJS - Zürich Smalltalk Group Meetup November 2023PharoJS - Zürich Smalltalk Group Meetup November 2023
PharoJS - Zürich Smalltalk Group Meetup November 2023
Noury Bouraqadi113 vues
Upskilling the Evolving Workforce with Digital Fluency for Tomorrow's Challen... par NUS-ISS
Upskilling the Evolving Workforce with Digital Fluency for Tomorrow's Challen...Upskilling the Evolving Workforce with Digital Fluency for Tomorrow's Challen...
Upskilling the Evolving Workforce with Digital Fluency for Tomorrow's Challen...
NUS-ISS23 vues
"Role of a CTO in software outsourcing company", Yuriy Nakonechnyy par Fwdays
"Role of a CTO in software outsourcing company", Yuriy Nakonechnyy"Role of a CTO in software outsourcing company", Yuriy Nakonechnyy
"Role of a CTO in software outsourcing company", Yuriy Nakonechnyy
Fwdays40 vues
Five Things You SHOULD Know About Postman par Postman
Five Things You SHOULD Know About PostmanFive Things You SHOULD Know About Postman
Five Things You SHOULD Know About Postman
Postman25 vues
Microchip: CXL Use Cases and Enabling Ecosystem par CXL Forum
Microchip: CXL Use Cases and Enabling EcosystemMicrochip: CXL Use Cases and Enabling Ecosystem
Microchip: CXL Use Cases and Enabling Ecosystem
CXL Forum129 vues
Understanding GenAI/LLM and What is Google Offering - Felix Goh par NUS-ISS
Understanding GenAI/LLM and What is Google Offering - Felix GohUnderstanding GenAI/LLM and What is Google Offering - Felix Goh
Understanding GenAI/LLM and What is Google Offering - Felix Goh
NUS-ISS39 vues
Webinar : Competing for tomorrow’s leaders – How MENA insurers can win the wa... par The Digital Insurer
Webinar : Competing for tomorrow’s leaders – How MENA insurers can win the wa...Webinar : Competing for tomorrow’s leaders – How MENA insurers can win the wa...
Webinar : Competing for tomorrow’s leaders – How MENA insurers can win the wa...
Web Dev - 1 PPT.pdf par gdsczhcet
Web Dev - 1 PPT.pdfWeb Dev - 1 PPT.pdf
Web Dev - 1 PPT.pdf
gdsczhcet52 vues
"AI Startup Growth from Idea to 1M ARR", Oleksandr Uspenskyi par Fwdays
"AI Startup Growth from Idea to 1M ARR", Oleksandr Uspenskyi"AI Startup Growth from Idea to 1M ARR", Oleksandr Uspenskyi
"AI Startup Growth from Idea to 1M ARR", Oleksandr Uspenskyi
Fwdays26 vues
Empathic Computing: Delivering the Potential of the Metaverse par Mark Billinghurst
Empathic Computing: Delivering  the Potential of the MetaverseEmpathic Computing: Delivering  the Potential of the Metaverse
Empathic Computing: Delivering the Potential of the Metaverse
.conf Go 2023 - How KPN drives Customer Satisfaction on IPTV par Splunk
.conf Go 2023 - How KPN drives Customer Satisfaction on IPTV.conf Go 2023 - How KPN drives Customer Satisfaction on IPTV
.conf Go 2023 - How KPN drives Customer Satisfaction on IPTV
Splunk86 vues
JCon Live 2023 - Lice coding some integration problems par Bernd Ruecker
JCon Live 2023 - Lice coding some integration problemsJCon Live 2023 - Lice coding some integration problems
JCon Live 2023 - Lice coding some integration problems
Bernd Ruecker67 vues
Business Analyst Series 2023 - Week 3 Session 5 par DianaGray10
Business Analyst Series 2023 -  Week 3 Session 5Business Analyst Series 2023 -  Week 3 Session 5
Business Analyst Series 2023 - Week 3 Session 5
DianaGray10165 vues

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