SlideShare a Scribd company logo
1 of 20
UNIVERSAL SYNCHRONOUS
ASYNCHRONOUS RECEIVER
TRANSMITTER(USART)
USART:
• To communicate with external components such as
computers or microcontrollers, the PIC micro uses a
component called USART - Universal Synchronous
Asynchronous Receiver Transmitter.This component can be
configured as:
• a Full-Duplex asynchronous system that can communicate
with peripheral devices, such as CRT terminals and personal
computers
• a Half-Duplex synchronous system that can communicate
with peripheral devices, such as A/D or D/A integrated
circuits, serial EEPROMs, etc.
To enable the serial communication with PIC micro we must set different parameters within two
registers:
1. TXSTA - Transmit Status and Control Register
2. RCSTA - Receive Status and Control Register
TXSTA Description:-
The size of this register is one byte (8 bits). Each bit has an important role in
the definition of the component. Here's a breakdown of the bit roles:
CSRC: Clock Source Select bit – this bit is meaningful only in Synchronous
communication in Half-Duplex mode. It “determines” if the component is Master
(transmitter) or Slave (receiver). It does not matter in the case of Full-Duplex mode.
Asynchronous mode:
Don’t care.
Synchronous mode:
1 = Master mode (clock generated internally from BRG)
0 = Slave mode (clock from external source)
TX9: 9-bit Transmit Enable bit - this bit lets select the transmitted frame size 8 or
9-bit
1 = Selects 9-bit transmission
0 = Selects 8-bit transmission
TXEN: Transmit Enable bit
1 = Transmit enabled
0 = Transmit disabled
SYNC: USART Mode Select bit
1 = Synchronous mode
0 = Asynchronous mode
BRGH - High Baud Rate Select bit – setting this bit “determines” the transmission
speed (High / Low). The setting of this bit valid only for asynchronous mode, and not
used for synchronous mode:
Asynchronous mode:
1 = High speed
0 = Low speed
Synchronous mode:
Unused in this mode.
TRMT - Transmit Shift Register Status bit
1 = TSR empty
0 = TSR full
TX9D - Place for a 9th bit, in the case of transmitting 9-bits.
RCSTA Description:-
The size of this register is also 8 bits. The role of each bit is discussed below:
SPEN: Serial Port Enable bit
1 = Serial port enabled (configures pin RC7/RX/DT for receiving the information into the PIC, and pin RC6/TX/CK
for transmitting the information from PIC)
0 = Serial port disabled
RX9: 9th -bit Receive Enable bit
1 = enables reception of 9 bit
0 = enables reception of 8 bit
SREN - Single Receive Enable bit - this bit enables or cancels transmission of packets. In the asynchronous
mode - this bit is not important. The importance of this bit is only in the synchronous mode (Half-Duplex) and
only when PIC is Master.
Asynchronous mode:
Don’t care.
Synchronous mode – Master:
1 = Enables single receive
0 = Disables single receive
This bit is cleared after reception is complete.
Synchronous mode – Slave:
Don’t care.
CREN - Continuous Receive Enable bit
Asynchronous mode:
1 = Enables continuous receive
0 = Disables continuous receive
Synchronous mode:
1 = Enables continuous receive until enable bit CREN is cleared (CREN overrides SREN)
0 = Disables continuous receive
ADDEN - Address Detect Enable bit - this bit enables interrupt only when the frame size is 9-bit. It does not matter, when the
size of the frame is 8-bit.
Asynchronous mode 9-bit (RX9 = 1):
1 = Enables address detection, enables interrupt and load of the receive buffer when RSR[8] is set
0 = Disables address detection, all bytes are received and ninth bit can be used as parity bit
FERR – Framing Error bit
Logic level “1” – means the STOP bit was not received. In serial communication we use START bit and STOP bit when
transmitting the information.
1 = Framing error (can be updated by reading RCREG register and receive next valid byte)
0 = No framing error
OERR - Overrun Error bit
Logical level “1” means that new byte of data was received, while there is still previous data that did not proceed into the PIC.
In this case, the new received information is lost.
1 = Overrun error (can be cleared by clearing bit CREN)
0 = No overrun error
RX9D: 9th bit of Received Data, in the case of receiving 9-bits.
Synchronous communication
• When using the synchronous communication – the information is transmitted
from the transmitter to the receiver:
• in sequence
• bit after bit
• with fixed baud rate
• and the clock frequency is transmitted along with the bits
• That means that the transmitter and the receiver are synchronized between
them by the same clock frequency. The clock frequency can be transmitted along
with the information, while it is encoded in the information itself, or in many
cases there is an additional wire for the clock.
• This type of communication is faster compare to the asynchronous
communication since it is "constantly transmitting” the information, with no
stops.
Asynchronous communication
• When using the asynchronous communication - the transmitter and the
receiver refraining to transmit long sequences of bits because there isn't
a full synchronization between the transmitter, that sends the data, and
the receiver, that receives the data.
• In this case, the information is divided into frames, in the size of byte.
Each one of the frame has:
“Start” bit marks the beginning of a new frame.
“Stop” bit marks the end of the frame.
• Frames of information must not necessarily be transmitted at equal time
space, since they are independent of the clock.
ANALOG-TO-DIGITAL CONVERTER(ADC)
• The A/D module has four 8 bit registers. These registers are:
• ADCON0 - A/D Control Register 0; determines the behavior of the A/D
• ADCON1 - A/D Control Register 1; determines the configuration of the
PORTA and PORTE and how the result of conversion of A/D will be
store
• ADRESH - A/D Result High Register
• ADRESL - A/D Result Low Register
The size of this register is one byte (8 bits). Each bit has an important role in the definition of the component. Here's
a breakdown of the bits role:
GO/DONE: A/D Conversion Status bit
If ADON = 1:
1 = A/D conversion in progress (setting this bit starts the A/D conversion)
0 = A/D conversion not in progress (this bit is automatically cleared by hardware when the A/D conversion is complete)
ADON: A/D On bit
1 = A/D converter module is operating
0 = A/D converter module is shut-off and consumes no operating current
ADFM: A/D Result Format Select bit
1 = Right justified. 6 Most Significant bits of ADRESH are read as ‘0’.
0 = Left justified. 6 Least Significant bits of ADRESL are read as ‘0’.
As we said, the A/D converter has a resolution of ten bits, i.e., the result of the conversion can not be stored in one register of
eight bits.
Therefore, the result is stored in two registers: ADRESL and ADRESH. The size of each register is 8 bits long, so that we have 16
(2*8) bits all together. We can store the result of the conversion which is 10 bits long using the two registers ADRESL and
ADRESH in the following 2 ways:
• alignment to the left
• alignment to the right
Alignment to the left – the eight MSB bits are stored in the ADRESH, and the two LSB bits are stored in ADRESL. In this case, the
remaining six bits appear as - "0".
Alignment to the right – the eight LSB bits are stored in ADRESL, and two MSB bits are stored in the ADRESH. In this case six
highest bits appear as - "0".
Right justified(ADFM =1) XXXXXX1111111111
Left Justified(ADFM =0) 1111111111XXXXXX.
PCFG3:PCFG0: A/D Port Configuration Control bits:
With these bits we can control the pins of PORTA or PORTE. We can decide an analog (A) or digital (D) mode.
• If we want to work with the PORTA and PORTE as analog ports, then we select
the option PCFG3: PCFG0 = 0000; If we want to work with ports as digital,
then we select the option PCFG3: PCFG0 = 011x.
• In general, after the specified desired behavior of the A/D converter unit and
before we start the conversion operation, we have to set up channel through
which the analog information will be received using TRIS command. To begin
making the conversion, we have to set the GO/DONE =1. This is done by using
the command ADGO = 1. When the conversion ends, the result will be loaded
into 2 registers ADRESH: ADRESL. Status bit GO/DONE (the register ADCON0)
will be set to zero and the ADIF flag is set.
Analog to Digital BLOCK DIAGRAM
To summarize, the following steps should be followed for doing an A/D Conversion:
1. Configure the A/D module:
• Configure analog pins/voltage reference and digital I/O (ADCON1)
• Select A/D input channel (ADCON0)
• Select A/D conversion clock (ADCON0)
• Turn on A/D module (ADCON0)
2. Configure A/D interrupt (if desired):
• Clear ADIF bit
• Set ADIE bit
• Set PEIE bit
• Set GIE bit
3. Wait the required acquisition time.
4. Start conversion:
• Set GO/DONE bit (ADCON0)
5. Wait for A/D conversion to complete, by either:
• Polling for the GO/DONE bit to be cleared(with interrupts enabled); OR
• Waiting for the A/D interrupt
6. Read A/D result register pair (ADRESH:ADRESL), clear bit ADIF if required.
7. For the next conversion, go to step 1 or step 2, as required.

More Related Content

What's hot

Serial Peripheral Interface(SPI)
Serial Peripheral Interface(SPI)Serial Peripheral Interface(SPI)
Serial Peripheral Interface(SPI)Dhaval Kaneria
 
SPI introduction(Serial Peripheral Interface)
SPI introduction(Serial Peripheral Interface)SPI introduction(Serial Peripheral Interface)
SPI introduction(Serial Peripheral Interface)SUNODH GARLAPATI
 
I2C And SPI Part-23
I2C And  SPI Part-23I2C And  SPI Part-23
I2C And SPI Part-23Techvilla
 
AHB To APB BRIDGE.pptx
AHB To APB BRIDGE.pptxAHB To APB BRIDGE.pptx
AHB To APB BRIDGE.pptxGuckChick
 
I2c protocol - Inter–Integrated Circuit Communication Protocol
I2c protocol - Inter–Integrated Circuit Communication ProtocolI2c protocol - Inter–Integrated Circuit Communication Protocol
I2c protocol - Inter–Integrated Circuit Communication ProtocolAnkur Soni
 
8251 a usart programmable communication interface(1)
8251 a usart   programmable communication interface(1)8251 a usart   programmable communication interface(1)
8251 a usart programmable communication interface(1)divyangpit
 
I2C Bus (Inter-Integrated Circuit)
I2C Bus (Inter-Integrated Circuit)I2C Bus (Inter-Integrated Circuit)
I2C Bus (Inter-Integrated Circuit)Varun Mahajan
 
APB protocol v1.0
APB protocol v1.0APB protocol v1.0
APB protocol v1.0Azad Mishra
 
Double data rate (ddr)
Double data rate (ddr)Double data rate (ddr)
Double data rate (ddr)Anderson Huang
 
Introduction about APB Protocol
Introduction about APB ProtocolIntroduction about APB Protocol
Introduction about APB ProtocolPushpa Yakkala
 

What's hot (20)

Serial Peripheral Interface(SPI)
Serial Peripheral Interface(SPI)Serial Peripheral Interface(SPI)
Serial Peripheral Interface(SPI)
 
AMBA_APB_pst
AMBA_APB_pstAMBA_APB_pst
AMBA_APB_pst
 
SPI introduction(Serial Peripheral Interface)
SPI introduction(Serial Peripheral Interface)SPI introduction(Serial Peripheral Interface)
SPI introduction(Serial Peripheral Interface)
 
8251 USART
8251 USART8251 USART
8251 USART
 
I2C And SPI Part-23
I2C And  SPI Part-23I2C And  SPI Part-23
I2C And SPI Part-23
 
SPI Bus Protocol
SPI Bus ProtocolSPI Bus Protocol
SPI Bus Protocol
 
SPI Protocol
SPI ProtocolSPI Protocol
SPI Protocol
 
AHB To APB BRIDGE.pptx
AHB To APB BRIDGE.pptxAHB To APB BRIDGE.pptx
AHB To APB BRIDGE.pptx
 
I2c protocol - Inter–Integrated Circuit Communication Protocol
I2c protocol - Inter–Integrated Circuit Communication ProtocolI2c protocol - Inter–Integrated Circuit Communication Protocol
I2c protocol - Inter–Integrated Circuit Communication Protocol
 
Uart
UartUart
Uart
 
8251 a usart programmable communication interface(1)
8251 a usart   programmable communication interface(1)8251 a usart   programmable communication interface(1)
8251 a usart programmable communication interface(1)
 
I2C Bus (Inter-Integrated Circuit)
I2C Bus (Inter-Integrated Circuit)I2C Bus (Inter-Integrated Circuit)
I2C Bus (Inter-Integrated Circuit)
 
APB protocol v1.0
APB protocol v1.0APB protocol v1.0
APB protocol v1.0
 
I2C Protocol
I2C ProtocolI2C Protocol
I2C Protocol
 
I2C
I2CI2C
I2C
 
axi protocol
axi protocolaxi protocol
axi protocol
 
Double data rate (ddr)
Double data rate (ddr)Double data rate (ddr)
Double data rate (ddr)
 
I2C Protocol
I2C ProtocolI2C Protocol
I2C Protocol
 
Introduction about APB Protocol
Introduction about APB ProtocolIntroduction about APB Protocol
Introduction about APB Protocol
 
Amba presentation2
Amba presentation2Amba presentation2
Amba presentation2
 

Similar to USART-PIC Serial Communication

8051 SERIAL PORTS.pptx
8051 SERIAL PORTS.pptx8051 SERIAL PORTS.pptx
8051 SERIAL PORTS.pptxmaheswariM7
 
8255-PPI MPMC text book for engineering.ppt
8255-PPI MPMC text book for engineering.ppt8255-PPI MPMC text book for engineering.ppt
8255-PPI MPMC text book for engineering.pptkhushiduppala
 
Digital logic-formula-notes-final-1
Digital logic-formula-notes-final-1Digital logic-formula-notes-final-1
Digital logic-formula-notes-final-1Kshitij Singh
 
I2C protocol and DS1307 RTC interfacing
I2C protocol and DS1307 RTC interfacingI2C protocol and DS1307 RTC interfacing
I2C protocol and DS1307 RTC interfacingBhargav Kakadiya
 
project report on embedded system
project report on embedded systemproject report on embedded system
project report on embedded systemram avtar
 
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
 
USART - 8251 / usart-8251A Pallav Shukla
USART - 8251 / usart-8251A Pallav ShuklaUSART - 8251 / usart-8251A Pallav Shukla
USART - 8251 / usart-8251A Pallav ShuklaPallav Shukla
 
PIC 16F877 micro controller by Gaurav raikar
PIC 16F877 micro controller by Gaurav raikarPIC 16F877 micro controller by Gaurav raikar
PIC 16F877 micro controller by Gaurav raikarGauravRaikar3
 
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
 
Design and Fabrication of 4-bit processor
Design and Fabrication of  4-bit processorDesign and Fabrication of  4-bit processor
Design and Fabrication of 4-bit processorPriyatham Bollimpalli
 
Training Report on embedded Systems and Robotics
Training Report on embedded  Systems and RoboticsTraining Report on embedded  Systems and Robotics
Training Report on embedded Systems and RoboticsNIT Raipur
 
Lecture 10 (serial communication)
Lecture 10 (serial communication)Lecture 10 (serial communication)
Lecture 10 (serial communication)cairo university
 

Similar to USART-PIC Serial Communication (20)

DATA TRANSFER SCHEMES OF 8085
DATA TRANSFER SCHEMES OF 8085DATA TRANSFER SCHEMES OF 8085
DATA TRANSFER SCHEMES OF 8085
 
Presentation (1)-3.pptx
Presentation (1)-3.pptxPresentation (1)-3.pptx
Presentation (1)-3.pptx
 
8051 SERIAL PORTS.pptx
8051 SERIAL PORTS.pptx8051 SERIAL PORTS.pptx
8051 SERIAL PORTS.pptx
 
8255-PPI MPMC text book for engineering.ppt
8255-PPI MPMC text book for engineering.ppt8255-PPI MPMC text book for engineering.ppt
8255-PPI MPMC text book for engineering.ppt
 
Digital logic-formula-notes-final-1
Digital logic-formula-notes-final-1Digital logic-formula-notes-final-1
Digital logic-formula-notes-final-1
 
unit 4 mc.pdf
unit 4 mc.pdfunit 4 mc.pdf
unit 4 mc.pdf
 
SPI Protocol in LPC2148
SPI  Protocol in LPC2148SPI  Protocol in LPC2148
SPI Protocol in LPC2148
 
I2C protocol and DS1307 RTC interfacing
I2C protocol and DS1307 RTC interfacingI2C protocol and DS1307 RTC interfacing
I2C protocol and DS1307 RTC interfacing
 
Lecture 10 _serial_communication
Lecture 10 _serial_communicationLecture 10 _serial_communication
Lecture 10 _serial_communication
 
project report on embedded system
project report on embedded systemproject report on embedded system
project report on embedded system
 
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
 
USART - 8251 / usart-8251A Pallav Shukla
USART - 8251 / usart-8251A Pallav ShuklaUSART - 8251 / usart-8251A Pallav Shukla
USART - 8251 / usart-8251A Pallav Shukla
 
PIC 16F877 micro controller by Gaurav raikar
PIC 16F877 micro controller by Gaurav raikarPIC 16F877 micro controller by Gaurav raikar
PIC 16F877 micro controller by Gaurav raikar
 
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....
 
020419.pdf
020419.pdf020419.pdf
020419.pdf
 
Peripheral 8245,16550&8237 dma controller
Peripheral 8245,16550&8237 dma controllerPeripheral 8245,16550&8237 dma controller
Peripheral 8245,16550&8237 dma controller
 
Avr report
Avr reportAvr report
Avr report
 
Design and Fabrication of 4-bit processor
Design and Fabrication of  4-bit processorDesign and Fabrication of  4-bit processor
Design and Fabrication of 4-bit processor
 
Training Report on embedded Systems and Robotics
Training Report on embedded  Systems and RoboticsTraining Report on embedded  Systems and Robotics
Training Report on embedded Systems and Robotics
 
Lecture 10 (serial communication)
Lecture 10 (serial communication)Lecture 10 (serial communication)
Lecture 10 (serial communication)
 

Recently uploaded

Capitol Tech U Doctoral Presentation - April 2024.pptx
Capitol Tech U Doctoral Presentation - April 2024.pptxCapitol Tech U Doctoral Presentation - April 2024.pptx
Capitol Tech U Doctoral Presentation - April 2024.pptxCapitolTechU
 
Full Stack Web Development Course for Beginners
Full Stack Web Development Course  for BeginnersFull Stack Web Development Course  for Beginners
Full Stack Web Development Course for BeginnersSabitha Banu
 
Historical philosophical, theoretical, and legal foundations of special and i...
Historical philosophical, theoretical, and legal foundations of special and i...Historical philosophical, theoretical, and legal foundations of special and i...
Historical philosophical, theoretical, and legal foundations of special and i...jaredbarbolino94
 
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdfssuser54595a
 
Presiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha electionsPresiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha electionsanshu789521
 
How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17Celine George
 
Alper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentAlper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentInMediaRes1
 
CELL CYCLE Division Science 8 quarter IV.pptx
CELL CYCLE Division Science 8 quarter IV.pptxCELL CYCLE Division Science 8 quarter IV.pptx
CELL CYCLE Division Science 8 quarter IV.pptxJiesonDelaCerna
 
Framing an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdf
Framing an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdfFraming an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdf
Framing an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdfUjwalaBharambe
 
Types of Journalistic Writing Grade 8.pptx
Types of Journalistic Writing Grade 8.pptxTypes of Journalistic Writing Grade 8.pptx
Types of Journalistic Writing Grade 8.pptxEyham Joco
 
Like-prefer-love -hate+verb+ing & silent letters & citizenship text.pdf
Like-prefer-love -hate+verb+ing & silent letters & citizenship text.pdfLike-prefer-love -hate+verb+ing & silent letters & citizenship text.pdf
Like-prefer-love -hate+verb+ing & silent letters & citizenship text.pdfMr Bounab Samir
 
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdfEnzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdfSumit Tiwari
 
Crayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon ACrayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon AUnboundStockton
 
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptxECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptxiammrhaywood
 
Blooming Together_ Growing a Community Garden Worksheet.docx
Blooming Together_ Growing a Community Garden Worksheet.docxBlooming Together_ Growing a Community Garden Worksheet.docx
Blooming Together_ Growing a Community Garden Worksheet.docxUnboundStockton
 
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions  for the students and aspirants of Chemistry12th.pptxOrganic Name Reactions  for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions for the students and aspirants of Chemistry12th.pptxVS Mahajan Coaching Centre
 
How to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxHow to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxmanuelaromero2013
 
What is Model Inheritance in Odoo 17 ERP
What is Model Inheritance in Odoo 17 ERPWhat is Model Inheritance in Odoo 17 ERP
What is Model Inheritance in Odoo 17 ERPCeline George
 

Recently uploaded (20)

Capitol Tech U Doctoral Presentation - April 2024.pptx
Capitol Tech U Doctoral Presentation - April 2024.pptxCapitol Tech U Doctoral Presentation - April 2024.pptx
Capitol Tech U Doctoral Presentation - April 2024.pptx
 
Full Stack Web Development Course for Beginners
Full Stack Web Development Course  for BeginnersFull Stack Web Development Course  for Beginners
Full Stack Web Development Course for Beginners
 
Historical philosophical, theoretical, and legal foundations of special and i...
Historical philosophical, theoretical, and legal foundations of special and i...Historical philosophical, theoretical, and legal foundations of special and i...
Historical philosophical, theoretical, and legal foundations of special and i...
 
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
 
Presiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha electionsPresiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha elections
 
How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17
 
Alper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentAlper Gobel In Media Res Media Component
Alper Gobel In Media Res Media Component
 
CELL CYCLE Division Science 8 quarter IV.pptx
CELL CYCLE Division Science 8 quarter IV.pptxCELL CYCLE Division Science 8 quarter IV.pptx
CELL CYCLE Division Science 8 quarter IV.pptx
 
OS-operating systems- ch04 (Threads) ...
OS-operating systems- ch04 (Threads) ...OS-operating systems- ch04 (Threads) ...
OS-operating systems- ch04 (Threads) ...
 
Framing an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdf
Framing an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdfFraming an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdf
Framing an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdf
 
Types of Journalistic Writing Grade 8.pptx
Types of Journalistic Writing Grade 8.pptxTypes of Journalistic Writing Grade 8.pptx
Types of Journalistic Writing Grade 8.pptx
 
Like-prefer-love -hate+verb+ing & silent letters & citizenship text.pdf
Like-prefer-love -hate+verb+ing & silent letters & citizenship text.pdfLike-prefer-love -hate+verb+ing & silent letters & citizenship text.pdf
Like-prefer-love -hate+verb+ing & silent letters & citizenship text.pdf
 
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdfEnzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
 
ESSENTIAL of (CS/IT/IS) class 06 (database)
ESSENTIAL of (CS/IT/IS) class 06 (database)ESSENTIAL of (CS/IT/IS) class 06 (database)
ESSENTIAL of (CS/IT/IS) class 06 (database)
 
Crayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon ACrayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon A
 
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptxECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
 
Blooming Together_ Growing a Community Garden Worksheet.docx
Blooming Together_ Growing a Community Garden Worksheet.docxBlooming Together_ Growing a Community Garden Worksheet.docx
Blooming Together_ Growing a Community Garden Worksheet.docx
 
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions  for the students and aspirants of Chemistry12th.pptxOrganic Name Reactions  for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
 
How to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxHow to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptx
 
What is Model Inheritance in Odoo 17 ERP
What is Model Inheritance in Odoo 17 ERPWhat is Model Inheritance in Odoo 17 ERP
What is Model Inheritance in Odoo 17 ERP
 

USART-PIC Serial Communication

  • 2. USART: • To communicate with external components such as computers or microcontrollers, the PIC micro uses a component called USART - Universal Synchronous Asynchronous Receiver Transmitter.This component can be configured as: • a Full-Duplex asynchronous system that can communicate with peripheral devices, such as CRT terminals and personal computers • a Half-Duplex synchronous system that can communicate with peripheral devices, such as A/D or D/A integrated circuits, serial EEPROMs, etc.
  • 3. To enable the serial communication with PIC micro we must set different parameters within two registers: 1. TXSTA - Transmit Status and Control Register 2. RCSTA - Receive Status and Control Register
  • 4. TXSTA Description:- The size of this register is one byte (8 bits). Each bit has an important role in the definition of the component. Here's a breakdown of the bit roles: CSRC: Clock Source Select bit – this bit is meaningful only in Synchronous communication in Half-Duplex mode. It “determines” if the component is Master (transmitter) or Slave (receiver). It does not matter in the case of Full-Duplex mode. Asynchronous mode: Don’t care. Synchronous mode: 1 = Master mode (clock generated internally from BRG) 0 = Slave mode (clock from external source) TX9: 9-bit Transmit Enable bit - this bit lets select the transmitted frame size 8 or 9-bit 1 = Selects 9-bit transmission 0 = Selects 8-bit transmission
  • 5. TXEN: Transmit Enable bit 1 = Transmit enabled 0 = Transmit disabled SYNC: USART Mode Select bit 1 = Synchronous mode 0 = Asynchronous mode
  • 6. BRGH - High Baud Rate Select bit – setting this bit “determines” the transmission speed (High / Low). The setting of this bit valid only for asynchronous mode, and not used for synchronous mode: Asynchronous mode: 1 = High speed 0 = Low speed Synchronous mode: Unused in this mode. TRMT - Transmit Shift Register Status bit 1 = TSR empty 0 = TSR full TX9D - Place for a 9th bit, in the case of transmitting 9-bits.
  • 7. RCSTA Description:- The size of this register is also 8 bits. The role of each bit is discussed below: SPEN: Serial Port Enable bit 1 = Serial port enabled (configures pin RC7/RX/DT for receiving the information into the PIC, and pin RC6/TX/CK for transmitting the information from PIC) 0 = Serial port disabled RX9: 9th -bit Receive Enable bit 1 = enables reception of 9 bit 0 = enables reception of 8 bit SREN - Single Receive Enable bit - this bit enables or cancels transmission of packets. In the asynchronous mode - this bit is not important. The importance of this bit is only in the synchronous mode (Half-Duplex) and only when PIC is Master.
  • 8. Asynchronous mode: Don’t care. Synchronous mode – Master: 1 = Enables single receive 0 = Disables single receive This bit is cleared after reception is complete. Synchronous mode – Slave: Don’t care. CREN - Continuous Receive Enable bit Asynchronous mode: 1 = Enables continuous receive 0 = Disables continuous receive Synchronous mode: 1 = Enables continuous receive until enable bit CREN is cleared (CREN overrides SREN) 0 = Disables continuous receive
  • 9. ADDEN - Address Detect Enable bit - this bit enables interrupt only when the frame size is 9-bit. It does not matter, when the size of the frame is 8-bit. Asynchronous mode 9-bit (RX9 = 1): 1 = Enables address detection, enables interrupt and load of the receive buffer when RSR[8] is set 0 = Disables address detection, all bytes are received and ninth bit can be used as parity bit FERR – Framing Error bit Logic level “1” – means the STOP bit was not received. In serial communication we use START bit and STOP bit when transmitting the information. 1 = Framing error (can be updated by reading RCREG register and receive next valid byte) 0 = No framing error OERR - Overrun Error bit Logical level “1” means that new byte of data was received, while there is still previous data that did not proceed into the PIC. In this case, the new received information is lost. 1 = Overrun error (can be cleared by clearing bit CREN) 0 = No overrun error RX9D: 9th bit of Received Data, in the case of receiving 9-bits.
  • 10. Synchronous communication • When using the synchronous communication – the information is transmitted from the transmitter to the receiver: • in sequence • bit after bit • with fixed baud rate • and the clock frequency is transmitted along with the bits • That means that the transmitter and the receiver are synchronized between them by the same clock frequency. The clock frequency can be transmitted along with the information, while it is encoded in the information itself, or in many cases there is an additional wire for the clock. • This type of communication is faster compare to the asynchronous communication since it is "constantly transmitting” the information, with no stops.
  • 11. Asynchronous communication • When using the asynchronous communication - the transmitter and the receiver refraining to transmit long sequences of bits because there isn't a full synchronization between the transmitter, that sends the data, and the receiver, that receives the data. • In this case, the information is divided into frames, in the size of byte. Each one of the frame has: “Start” bit marks the beginning of a new frame. “Stop” bit marks the end of the frame. • Frames of information must not necessarily be transmitted at equal time space, since they are independent of the clock.
  • 12. ANALOG-TO-DIGITAL CONVERTER(ADC) • The A/D module has four 8 bit registers. These registers are: • ADCON0 - A/D Control Register 0; determines the behavior of the A/D • ADCON1 - A/D Control Register 1; determines the configuration of the PORTA and PORTE and how the result of conversion of A/D will be store • ADRESH - A/D Result High Register • ADRESL - A/D Result Low Register
  • 13. The size of this register is one byte (8 bits). Each bit has an important role in the definition of the component. Here's a breakdown of the bits role:
  • 14. GO/DONE: A/D Conversion Status bit If ADON = 1: 1 = A/D conversion in progress (setting this bit starts the A/D conversion) 0 = A/D conversion not in progress (this bit is automatically cleared by hardware when the A/D conversion is complete)
  • 15. ADON: A/D On bit 1 = A/D converter module is operating 0 = A/D converter module is shut-off and consumes no operating current
  • 16. ADFM: A/D Result Format Select bit 1 = Right justified. 6 Most Significant bits of ADRESH are read as ‘0’. 0 = Left justified. 6 Least Significant bits of ADRESL are read as ‘0’. As we said, the A/D converter has a resolution of ten bits, i.e., the result of the conversion can not be stored in one register of eight bits. Therefore, the result is stored in two registers: ADRESL and ADRESH. The size of each register is 8 bits long, so that we have 16 (2*8) bits all together. We can store the result of the conversion which is 10 bits long using the two registers ADRESL and ADRESH in the following 2 ways: • alignment to the left • alignment to the right Alignment to the left – the eight MSB bits are stored in the ADRESH, and the two LSB bits are stored in ADRESL. In this case, the remaining six bits appear as - "0". Alignment to the right – the eight LSB bits are stored in ADRESL, and two MSB bits are stored in the ADRESH. In this case six highest bits appear as - "0". Right justified(ADFM =1) XXXXXX1111111111 Left Justified(ADFM =0) 1111111111XXXXXX.
  • 17. PCFG3:PCFG0: A/D Port Configuration Control bits: With these bits we can control the pins of PORTA or PORTE. We can decide an analog (A) or digital (D) mode.
  • 18. • If we want to work with the PORTA and PORTE as analog ports, then we select the option PCFG3: PCFG0 = 0000; If we want to work with ports as digital, then we select the option PCFG3: PCFG0 = 011x. • In general, after the specified desired behavior of the A/D converter unit and before we start the conversion operation, we have to set up channel through which the analog information will be received using TRIS command. To begin making the conversion, we have to set the GO/DONE =1. This is done by using the command ADGO = 1. When the conversion ends, the result will be loaded into 2 registers ADRESH: ADRESL. Status bit GO/DONE (the register ADCON0) will be set to zero and the ADIF flag is set.
  • 19. Analog to Digital BLOCK DIAGRAM
  • 20. To summarize, the following steps should be followed for doing an A/D Conversion: 1. Configure the A/D module: • Configure analog pins/voltage reference and digital I/O (ADCON1) • Select A/D input channel (ADCON0) • Select A/D conversion clock (ADCON0) • Turn on A/D module (ADCON0) 2. Configure A/D interrupt (if desired): • Clear ADIF bit • Set ADIE bit • Set PEIE bit • Set GIE bit 3. Wait the required acquisition time. 4. Start conversion: • Set GO/DONE bit (ADCON0) 5. Wait for A/D conversion to complete, by either: • Polling for the GO/DONE bit to be cleared(with interrupts enabled); OR • Waiting for the A/D interrupt 6. Read A/D result register pair (ADRESH:ADRESL), clear bit ADIF if required. 7. For the next conversion, go to step 1 or step 2, as required.