SlideShare uma empresa Scribd logo
1 de 18
COMMUNICATING WITH PC USING SERIAL
COMMUNICATION IN 8051
Objectives of the Lab
 Serial Communication Types
 Registers governing Serial communication
 Using timer1 to set baud rate
 Hardware necessities for serial communication
Deciding Pins or Ports to use
Use with
caution
If EA high
*The pins for this
purpose are by
default P3.0(RXD)
and P3.1(TXD) .
Serial Communication
 Serial communication has the advantage over parallel
communication w.r.t number of wires used but the trade-
off done is on speed of communication.
 The quantity that decides the usage of serial or parallel
communication is the distance, the data needs to cover.
 Synchronous method transfers a block of data at a time
while asynchronous transfers a single byte at a time.
 Serial communication is classified into following types.
SCON Register
SM0 SCON.7 Serial Port Mode specifier
SM1 SCON.6 Serial Port Mode specifier
SM2 SCON.5 Used for multiprocessor communication
REN SCON.4 Set/Cleared by software to enable/disable reception
TB8 SCON.3 Not widely used
RB8 SCON.2 Not widely used
TI SCON.1 Transmit Interrupt, Set by HW after the data is successfully sent,
cleared by SW. (At start, keep it high, so we know that the previous
data was sent)
RI SCON.0 Receive Interrupt, Set by HW after the data is successfully received,
cleared by SW.
SM0 and SM1
SM0 SM1 Mode Description Baud Rate
0 0 0 Shift Register Fixed fXTAL/12
0 1 1 8-bit UART Variable (Set by Timer1)
1 0 2 9-bit UART Fixed (fXTAL/12 or fXTAL/64)
1 1 3 9-bit UART Variable (Set by Timer 1)
UART: Universal Asynchronous Receiver Transmitter
Baud Rate: Speed (Bits per Second)
SBUF and TMOD
 SBUF is a very important register in serial communication. It
is not bit addressable and is dual purpose serial read/write.
 When transmitting, data to be transmitted should be in SBUF.
 When receiving, data will be received in SBUF.
 TMOD register is used to set variable baud rate using timer1.
 We will use in 8-bit auto-reload as count is mostly <255.
 To find the TH0 value against baud rate, following is done.
 Baud Rate=Timer1 OV flow rate ÷ 32 => OV= B.R. × 32
 e.g. B.R.= 1200 bps OV=1200*32=38400 b/s
 Delay generated by timer1 should be
1
𝑂𝑉
=
1
38400
𝑠𝑒𝑐𝑜𝑛𝑑𝑠
 Value in timer1=counts=
1
𝑂𝑉
1 𝑚.𝑐.
=
1
38400
12
11059200
=
11059200
12∗38400
= 24
Try fXTAL = 12 MHz
SMOD bit (PCON.7) and Universal
Baud Rates
PCON is not bit addressable, so to clear PCON.7, use
Anl PCON,#01111111b, and to set Orl PCON,#10000000b
Pseudo-Code for Transmitting and
Receiving Data through serial port
1. Move value in SMOD using mode1, keeping REN=1, RI=0 and
TI=1.
2. Configure TMOD for timer1, mode 2 and load value in TH1 and
TL1 for desired baud rate and run timer by setting TR1 high.
3. Use SMOD bit as desired.
4. For transmission of data,
 Clear TI.
 Move data in SBUF
 Then wait till TI gets high i.e. Data is transmitted.
5. For reception of data,
 Wait till RI gets high i.e. Data is received.
 Clear RI
 Move data from SBUF in desired register.
Data Transmit/Receive Protocol
 To transmit a character use mov a,#‘X’.
 During reception, ASCII of a character will be received.
 To transmit integer, first make it ASCII, add a,#30h.
 During reception, use clr c & subb a,#30h to make integer.
 To display a line, use look-up table.
mov dptr,#line1
again:
mov a,#0
movc a,@a+dptr
inc dptr
jz exit1
clr ti
mov sbuf,a
jnb ti,$
jmp again
exit1:
line1: db “Hello World”,0ah,0dh,0
Proteus Devices needed in this Lab
1. AT89c51
2. Virtual Terminal (TXD, RXD, use in cross-connection)
Virtual Terminal Settings:
Baud Rate= as desired. Rest settings as default
Serial communication with PC
 Communicating serially in software is much easier and doesn’t
require electronic equipment and any debugging but hardware
serial communication with PC is quite complicated.
 First of all, we need to use hyper-terminal in windows XP. It’s
location is in ‘Start>Programs>Accessories>Communication
>Hyper-terminal.’ (Settings=> Bits per second: B.R. ,
Data bits=8, Parity=None, Flow-Control=None)
 Then, we have to use a serial cable. (Straight/Cross)
 Then, a level converter IC.
 And finally the microcontroller coded with serial
communication.
Serial communication with PC
Level converter IC
Serial Port and Cable
Serial cables have serial ports on both sides of it. If internally pin2 and pin3 of one port
are short with pin2 and pin3 of other port it is straight cable, if pin2 of one port is
connected to pin3 of other port and pin3 of one port is connected to pin2, this is cross cable.
RS-232 to TTL converter
(MAX-232)
 As we know, that the microcontroller level low is ‘0 volts’ and level
high is ‘5 volts’, these are called TTL levels.
 RS-232 levels are different than TTL levels and thus we need a
conversion of levels.
 In RS-232, a level low is represented by ‘+3~+25 volts’ where as a
level high is represented by ‘-3~-25 volts’.
*MAX-233 doesn’t require capacitors but is costly.
Debugging Stages:
1. First of all check the serial-cable, whether it is straight or
cross.
2. Then check the serial-cable, whether it is functioning or not.
For this short pins 2 & 3 and write something in hyper-
terminal, if data is echoed, the cable is fine.
3. Then check the level converter IC, by shorting its TXD and
RXD pins on the side of μC.
4. μC 8051 should already be checked by LED test.
5. The program should be verified in PROTEUS.
Final Remark on μC 8051 LAB:
Small Size, Low-Cost, Same
Function: AT89C2051
Lab Tasks
 Serially communicate with PC. If key pressed is that of
your workstation number then display ‘Workstation#xy’
otherwise display ‘Invalid input’.
 Quiz Next Week of Timers.
1. Last Week Submissions: Project SW, HW and Report
(ADC0804 submission)
2. Vivas from Project and μC Lab
3. Lab Manual Submission

Mais conteúdo relacionado

Mais procurados

Serial communication
Serial communicationSerial communication
Serial communicationVikas Dongre
 
Serial communication in LPC2148
Serial communication in LPC2148Serial communication in LPC2148
Serial communication in LPC2148sravannunna24
 
Universal Serial Communication Interface
Universal Serial Communication InterfaceUniversal Serial Communication Interface
Universal Serial Communication InterfaceSandesh Agrawal
 
Microcontroller serial communication
Microcontroller serial communicationMicrocontroller serial communication
Microcontroller serial communicationNeeta Sawant
 
Serial Communication
Serial CommunicationSerial Communication
Serial CommunicationRashmi
 
Mridul_Verma_Intern_Tech_Adityaa_UART
Mridul_Verma_Intern_Tech_Adityaa_UARTMridul_Verma_Intern_Tech_Adityaa_UART
Mridul_Verma_Intern_Tech_Adityaa_UARTMridul Verma
 
Universal asynchronous receiver-transmitter UART Dsa project report
Universal asynchronous receiver-transmitter UART Dsa project reportUniversal asynchronous receiver-transmitter UART Dsa project report
Universal asynchronous receiver-transmitter UART Dsa project reportShahrukh Javed
 
Seminar on serial communication
Seminar on serial communicationSeminar on serial communication
Seminar on serial communicationSamarth Patel
 
USART - 8251 / usart-8251A Pallav Shukla
USART - 8251 / usart-8251A Pallav ShuklaUSART - 8251 / usart-8251A Pallav Shukla
USART - 8251 / usart-8251A Pallav ShuklaPallav Shukla
 
UART(universal asynchronous receiver transmitter ) PPT
UART(universal asynchronous receiver transmitter ) PPTUART(universal asynchronous receiver transmitter ) PPT
UART(universal asynchronous receiver transmitter ) PPTSai_praneeth
 
Verification of uart ip core using uvm
Verification of uart ip core using uvmVerification of uart ip core using uvm
Verification of uart ip core using uvmeSAT Publishing House
 
Design and implementation of uart on soc
Design and implementation of uart on socDesign and implementation of uart on soc
Design and implementation of uart on socIjrdt Journal
 
8251 08 Serial
8251 08 Serial8251 08 Serial
8251 08 SerialAisu
 
Master synchronous serial port (mssp)
Master synchronous serial port (mssp)Master synchronous serial port (mssp)
Master synchronous serial port (mssp)babak danyal
 

Mais procurados (20)

Serial communication
Serial communicationSerial communication
Serial communication
 
Serial communication in LPC2148
Serial communication in LPC2148Serial communication in LPC2148
Serial communication in LPC2148
 
Universal Serial Communication Interface
Universal Serial Communication InterfaceUniversal Serial Communication Interface
Universal Serial Communication Interface
 
UART
UARTUART
UART
 
Microcontroller serial communication
Microcontroller serial communicationMicrocontroller serial communication
Microcontroller serial communication
 
Uart
UartUart
Uart
 
Serial data transfer
Serial data transferSerial data transfer
Serial data transfer
 
Uart
UartUart
Uart
 
Serial communication of microcontroller 8051
Serial communication of microcontroller 8051Serial communication of microcontroller 8051
Serial communication of microcontroller 8051
 
Serial Communication
Serial CommunicationSerial Communication
Serial Communication
 
Mridul_Verma_Intern_Tech_Adityaa_UART
Mridul_Verma_Intern_Tech_Adityaa_UARTMridul_Verma_Intern_Tech_Adityaa_UART
Mridul_Verma_Intern_Tech_Adityaa_UART
 
Universal asynchronous receiver-transmitter UART Dsa project report
Universal asynchronous receiver-transmitter UART Dsa project reportUniversal asynchronous receiver-transmitter UART Dsa project report
Universal asynchronous receiver-transmitter UART Dsa project report
 
Seminar on serial communication
Seminar on serial communicationSeminar on serial communication
Seminar on 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
 
UART(universal asynchronous receiver transmitter ) PPT
UART(universal asynchronous receiver transmitter ) PPTUART(universal asynchronous receiver transmitter ) PPT
UART(universal asynchronous receiver transmitter ) PPT
 
Verification of uart ip core using uvm
Verification of uart ip core using uvmVerification of uart ip core using uvm
Verification of uart ip core using uvm
 
Design and implementation of uart on soc
Design and implementation of uart on socDesign and implementation of uart on soc
Design and implementation of uart on soc
 
Serial1
Serial1Serial1
Serial1
 
8251 08 Serial
8251 08 Serial8251 08 Serial
8251 08 Serial
 
Master synchronous serial port (mssp)
Master synchronous serial port (mssp)Master synchronous serial port (mssp)
Master synchronous serial port (mssp)
 

Destaque

Controlling stepper motor using serial communication with computer
Controlling stepper motor using serial communication with computerControlling stepper motor using serial communication with computer
Controlling stepper motor using serial communication with computernoumanahmed90
 
Direct memory access (dma) with 8257 DMA Controller
Direct memory access (dma) with 8257 DMA ControllerDirect memory access (dma) with 8257 DMA Controller
Direct memory access (dma) with 8257 DMA ControllerMuhammed Afsal Villan
 
Serial Communication
Serial CommunicationSerial Communication
Serial CommunicationYong Heui Cho
 
Direct Memory Access(DMA)
Direct Memory Access(DMA)Direct Memory Access(DMA)
Direct Memory Access(DMA)Page Maker
 
ANTIVIRUS AND VIRUS Powerpoint presentation
ANTIVIRUS AND VIRUS Powerpoint presentationANTIVIRUS AND VIRUS Powerpoint presentation
ANTIVIRUS AND VIRUS Powerpoint presentationabhijit chintamani
 

Destaque (6)

Controlling stepper motor using serial communication with computer
Controlling stepper motor using serial communication with computerControlling stepper motor using serial communication with computer
Controlling stepper motor using serial communication with computer
 
Direct memory access (dma) with 8257 DMA Controller
Direct memory access (dma) with 8257 DMA ControllerDirect memory access (dma) with 8257 DMA Controller
Direct memory access (dma) with 8257 DMA Controller
 
Serial Communication
Serial CommunicationSerial Communication
Serial Communication
 
Hard disk
Hard diskHard disk
Hard disk
 
Direct Memory Access(DMA)
Direct Memory Access(DMA)Direct Memory Access(DMA)
Direct Memory Access(DMA)
 
ANTIVIRUS AND VIRUS Powerpoint presentation
ANTIVIRUS AND VIRUS Powerpoint presentationANTIVIRUS AND VIRUS Powerpoint presentation
ANTIVIRUS AND VIRUS Powerpoint presentation
 

Semelhante a Micro c lab8(serial communication)

serial-200505101453.pdf
serial-200505101453.pdfserial-200505101453.pdf
serial-200505101453.pdfKiranG731731
 
EC8691 - UNIT 5.pdf
EC8691 - UNIT 5.pdfEC8691 - UNIT 5.pdf
EC8691 - UNIT 5.pdfSPonmalar1
 
AN INTRODUCTION TO SERIAL PORT INTERFACING
AN INTRODUCTION TO SERIAL PORT INTERFACINGAN INTRODUCTION TO SERIAL PORT INTERFACING
AN INTRODUCTION TO SERIAL PORT INTERFACINGTotal Project Solutions
 
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
 
8051 serial communication1
8051 serial communication1 8051 serial communication1
8051 serial communication1 vijaydeepakg
 
Serial Port Device Driver
Serial Port Device DriverSerial Port Device Driver
Serial Port Device DriverEmblogic
 
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
 
Interfacing rs232
Interfacing rs232Interfacing rs232
Interfacing rs232PRADEEP
 
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
 
Sereial com. ppt
Sereial com. pptSereial com. ppt
Sereial com. pptgaurav5345
 
Serial Communication & Embedded System Interface
Serial Communication & Embedded System InterfaceSerial Communication & Embedded System Interface
Serial Communication & Embedded System InterfaceKUET
 
8051 serial communication
8051 serial communication8051 serial communication
8051 serial communicationcanh phan
 

Semelhante a Micro c lab8(serial communication) (20)

serial-200505101453.pdf
serial-200505101453.pdfserial-200505101453.pdf
serial-200505101453.pdf
 
Serial Communication in 8051
Serial Communication in 8051Serial Communication in 8051
Serial Communication in 8051
 
EC8691 - UNIT 5.pdf
EC8691 - UNIT 5.pdfEC8691 - UNIT 5.pdf
EC8691 - UNIT 5.pdf
 
AN INTRODUCTION TO SERIAL PORT INTERFACING
AN INTRODUCTION TO SERIAL PORT INTERFACINGAN INTRODUCTION TO SERIAL PORT INTERFACING
AN INTRODUCTION TO SERIAL PORT INTERFACING
 
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
 
Batch 25(a)
Batch 25(a)Batch 25(a)
Batch 25(a)
 
12 mt06ped019
12 mt06ped019 12 mt06ped019
12 mt06ped019
 
Tutorial
TutorialTutorial
Tutorial
 
8051 serial communication1
8051 serial communication1 8051 serial communication1
8051 serial communication1
 
Serial Port Device Driver
Serial Port Device DriverSerial Port Device Driver
Serial Port Device Driver
 
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....
 
45039336 rs232
45039336 rs23245039336 rs232
45039336 rs232
 
Interfacing rs232
Interfacing rs232Interfacing rs232
Interfacing rs232
 
8251 USART.pptx
8251 USART.pptx8251 USART.pptx
8251 USART.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
 
Sereial com. ppt
Sereial com. pptSereial com. ppt
Sereial com. ppt
 
8251 USART
8251 USART8251 USART
8251 USART
 
Serial Communication & Embedded System Interface
Serial Communication & Embedded System InterfaceSerial Communication & Embedded System Interface
Serial Communication & Embedded System Interface
 
8051 serial communication
8051 serial communication8051 serial communication
8051 serial communication
 
Chap10
Chap10Chap10
Chap10
 

Mais de Mashood

Patience (1).pptx
Patience (1).pptxPatience (1).pptx
Patience (1).pptxMashood
 
Micro c lab7(timers)
Micro c lab7(timers)Micro c lab7(timers)
Micro c lab7(timers)Mashood
 
Micro c lab6(lcd)
Micro c lab6(lcd)Micro c lab6(lcd)
Micro c lab6(lcd)Mashood
 
Micro c lab5(stepper-motor)
Micro c lab5(stepper-motor)Micro c lab5(stepper-motor)
Micro c lab5(stepper-motor)Mashood
 
Micro c lab4(keypad)
Micro c lab4(keypad)Micro c lab4(keypad)
Micro c lab4(keypad)Mashood
 
Micro c lab3(ssd)
Micro c lab3(ssd)Micro c lab3(ssd)
Micro c lab3(ssd)Mashood
 
Micro c lab2(led patterns)
Micro c lab2(led patterns)Micro c lab2(led patterns)
Micro c lab2(led patterns)Mashood
 
Micro c lab1(intro to 8051)
Micro c lab1(intro to 8051)Micro c lab1(intro to 8051)
Micro c lab1(intro to 8051)Mashood
 
Amplifiers (analog electronics ii lab)
Amplifiers (analog electronics ii lab)Amplifiers (analog electronics ii lab)
Amplifiers (analog electronics ii lab)Mashood
 
Pcb design using proteus
Pcb design using proteusPcb design using proteus
Pcb design using proteusMashood
 
Function Generator
Function GeneratorFunction Generator
Function GeneratorMashood
 
Speed Measuring Circuit
Speed Measuring CircuitSpeed Measuring Circuit
Speed Measuring CircuitMashood
 

Mais de Mashood (12)

Patience (1).pptx
Patience (1).pptxPatience (1).pptx
Patience (1).pptx
 
Micro c lab7(timers)
Micro c lab7(timers)Micro c lab7(timers)
Micro c lab7(timers)
 
Micro c lab6(lcd)
Micro c lab6(lcd)Micro c lab6(lcd)
Micro c lab6(lcd)
 
Micro c lab5(stepper-motor)
Micro c lab5(stepper-motor)Micro c lab5(stepper-motor)
Micro c lab5(stepper-motor)
 
Micro c lab4(keypad)
Micro c lab4(keypad)Micro c lab4(keypad)
Micro c lab4(keypad)
 
Micro c lab3(ssd)
Micro c lab3(ssd)Micro c lab3(ssd)
Micro c lab3(ssd)
 
Micro c lab2(led patterns)
Micro c lab2(led patterns)Micro c lab2(led patterns)
Micro c lab2(led patterns)
 
Micro c lab1(intro to 8051)
Micro c lab1(intro to 8051)Micro c lab1(intro to 8051)
Micro c lab1(intro to 8051)
 
Amplifiers (analog electronics ii lab)
Amplifiers (analog electronics ii lab)Amplifiers (analog electronics ii lab)
Amplifiers (analog electronics ii lab)
 
Pcb design using proteus
Pcb design using proteusPcb design using proteus
Pcb design using proteus
 
Function Generator
Function GeneratorFunction Generator
Function Generator
 
Speed Measuring Circuit
Speed Measuring CircuitSpeed Measuring Circuit
Speed Measuring Circuit
 

Último

9548086042 for call girls in Indira Nagar with room service
9548086042  for call girls in Indira Nagar  with room service9548086042  for call girls in Indira Nagar  with room service
9548086042 for call girls in Indira Nagar with room servicediscovermytutordmt
 
mini mental status format.docx
mini    mental       status     format.docxmini    mental       status     format.docx
mini mental status format.docxPoojaSen20
 
Beyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global ImpactBeyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global ImpactPECB
 
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...EduSkills OECD
 
Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityGeoBlogs
 
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)eniolaolutunde
 
Interactive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationInteractive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationnomboosow
 
Measures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeMeasures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeThiyagu K
 
Student login on Anyboli platform.helpin
Student login on Anyboli platform.helpinStudent login on Anyboli platform.helpin
Student login on Anyboli platform.helpinRaunakKeshri1
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfciinovamais
 
Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..Disha Kariya
 
JAPAN: ORGANISATION OF PMDA, PHARMACEUTICAL LAWS & REGULATIONS, TYPES OF REGI...
JAPAN: ORGANISATION OF PMDA, PHARMACEUTICAL LAWS & REGULATIONS, TYPES OF REGI...JAPAN: ORGANISATION OF PMDA, PHARMACEUTICAL LAWS & REGULATIONS, TYPES OF REGI...
JAPAN: ORGANISATION OF PMDA, PHARMACEUTICAL LAWS & REGULATIONS, TYPES OF REGI...anjaliyadav012327
 
Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104misteraugie
 
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Sapana Sha
 
Web & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdfWeb & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdfJayanti Pande
 
Grant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingGrant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingTechSoup
 
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...Sapna Thakur
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxiammrhaywood
 

Último (20)

9548086042 for call girls in Indira Nagar with room service
9548086042  for call girls in Indira Nagar  with room service9548086042  for call girls in Indira Nagar  with room service
9548086042 for call girls in Indira Nagar with room service
 
mini mental status format.docx
mini    mental       status     format.docxmini    mental       status     format.docx
mini mental status format.docx
 
Beyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global ImpactBeyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global Impact
 
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
 
Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activity
 
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)
 
Interactive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationInteractive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communication
 
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptxINDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
 
Measures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeMeasures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and Mode
 
Student login on Anyboli platform.helpin
Student login on Anyboli platform.helpinStudent login on Anyboli platform.helpin
Student login on Anyboli platform.helpin
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdf
 
Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..
 
JAPAN: ORGANISATION OF PMDA, PHARMACEUTICAL LAWS & REGULATIONS, TYPES OF REGI...
JAPAN: ORGANISATION OF PMDA, PHARMACEUTICAL LAWS & REGULATIONS, TYPES OF REGI...JAPAN: ORGANISATION OF PMDA, PHARMACEUTICAL LAWS & REGULATIONS, TYPES OF REGI...
JAPAN: ORGANISATION OF PMDA, PHARMACEUTICAL LAWS & REGULATIONS, TYPES OF REGI...
 
Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104
 
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
 
Web & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdfWeb & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdf
 
Grant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingGrant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy Consulting
 
Código Creativo y Arte de Software | Unidad 1
Código Creativo y Arte de Software | Unidad 1Código Creativo y Arte de Software | Unidad 1
Código Creativo y Arte de Software | Unidad 1
 
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
 

Micro c lab8(serial communication)

  • 1. COMMUNICATING WITH PC USING SERIAL COMMUNICATION IN 8051
  • 2. Objectives of the Lab  Serial Communication Types  Registers governing Serial communication  Using timer1 to set baud rate  Hardware necessities for serial communication
  • 3. Deciding Pins or Ports to use Use with caution If EA high *The pins for this purpose are by default P3.0(RXD) and P3.1(TXD) .
  • 4. Serial Communication  Serial communication has the advantage over parallel communication w.r.t number of wires used but the trade- off done is on speed of communication.  The quantity that decides the usage of serial or parallel communication is the distance, the data needs to cover.  Synchronous method transfers a block of data at a time while asynchronous transfers a single byte at a time.  Serial communication is classified into following types.
  • 5. SCON Register SM0 SCON.7 Serial Port Mode specifier SM1 SCON.6 Serial Port Mode specifier SM2 SCON.5 Used for multiprocessor communication REN SCON.4 Set/Cleared by software to enable/disable reception TB8 SCON.3 Not widely used RB8 SCON.2 Not widely used TI SCON.1 Transmit Interrupt, Set by HW after the data is successfully sent, cleared by SW. (At start, keep it high, so we know that the previous data was sent) RI SCON.0 Receive Interrupt, Set by HW after the data is successfully received, cleared by SW.
  • 6. SM0 and SM1 SM0 SM1 Mode Description Baud Rate 0 0 0 Shift Register Fixed fXTAL/12 0 1 1 8-bit UART Variable (Set by Timer1) 1 0 2 9-bit UART Fixed (fXTAL/12 or fXTAL/64) 1 1 3 9-bit UART Variable (Set by Timer 1) UART: Universal Asynchronous Receiver Transmitter Baud Rate: Speed (Bits per Second)
  • 7. SBUF and TMOD  SBUF is a very important register in serial communication. It is not bit addressable and is dual purpose serial read/write.  When transmitting, data to be transmitted should be in SBUF.  When receiving, data will be received in SBUF.  TMOD register is used to set variable baud rate using timer1.  We will use in 8-bit auto-reload as count is mostly <255.  To find the TH0 value against baud rate, following is done.  Baud Rate=Timer1 OV flow rate ÷ 32 => OV= B.R. × 32  e.g. B.R.= 1200 bps OV=1200*32=38400 b/s  Delay generated by timer1 should be 1 𝑂𝑉 = 1 38400 𝑠𝑒𝑐𝑜𝑛𝑑𝑠  Value in timer1=counts= 1 𝑂𝑉 1 𝑚.𝑐. = 1 38400 12 11059200 = 11059200 12∗38400 = 24 Try fXTAL = 12 MHz
  • 8. SMOD bit (PCON.7) and Universal Baud Rates PCON is not bit addressable, so to clear PCON.7, use Anl PCON,#01111111b, and to set Orl PCON,#10000000b
  • 9. Pseudo-Code for Transmitting and Receiving Data through serial port 1. Move value in SMOD using mode1, keeping REN=1, RI=0 and TI=1. 2. Configure TMOD for timer1, mode 2 and load value in TH1 and TL1 for desired baud rate and run timer by setting TR1 high. 3. Use SMOD bit as desired. 4. For transmission of data,  Clear TI.  Move data in SBUF  Then wait till TI gets high i.e. Data is transmitted. 5. For reception of data,  Wait till RI gets high i.e. Data is received.  Clear RI  Move data from SBUF in desired register.
  • 10. Data Transmit/Receive Protocol  To transmit a character use mov a,#‘X’.  During reception, ASCII of a character will be received.  To transmit integer, first make it ASCII, add a,#30h.  During reception, use clr c & subb a,#30h to make integer.  To display a line, use look-up table. mov dptr,#line1 again: mov a,#0 movc a,@a+dptr inc dptr jz exit1 clr ti mov sbuf,a jnb ti,$ jmp again exit1: line1: db “Hello World”,0ah,0dh,0
  • 11. Proteus Devices needed in this Lab 1. AT89c51 2. Virtual Terminal (TXD, RXD, use in cross-connection) Virtual Terminal Settings: Baud Rate= as desired. Rest settings as default
  • 12. Serial communication with PC  Communicating serially in software is much easier and doesn’t require electronic equipment and any debugging but hardware serial communication with PC is quite complicated.  First of all, we need to use hyper-terminal in windows XP. It’s location is in ‘Start>Programs>Accessories>Communication >Hyper-terminal.’ (Settings=> Bits per second: B.R. , Data bits=8, Parity=None, Flow-Control=None)  Then, we have to use a serial cable. (Straight/Cross)  Then, a level converter IC.  And finally the microcontroller coded with serial communication.
  • 13. Serial communication with PC Level converter IC
  • 14. Serial Port and Cable Serial cables have serial ports on both sides of it. If internally pin2 and pin3 of one port are short with pin2 and pin3 of other port it is straight cable, if pin2 of one port is connected to pin3 of other port and pin3 of one port is connected to pin2, this is cross cable.
  • 15. RS-232 to TTL converter (MAX-232)  As we know, that the microcontroller level low is ‘0 volts’ and level high is ‘5 volts’, these are called TTL levels.  RS-232 levels are different than TTL levels and thus we need a conversion of levels.  In RS-232, a level low is represented by ‘+3~+25 volts’ where as a level high is represented by ‘-3~-25 volts’. *MAX-233 doesn’t require capacitors but is costly.
  • 16. Debugging Stages: 1. First of all check the serial-cable, whether it is straight or cross. 2. Then check the serial-cable, whether it is functioning or not. For this short pins 2 & 3 and write something in hyper- terminal, if data is echoed, the cable is fine. 3. Then check the level converter IC, by shorting its TXD and RXD pins on the side of μC. 4. μC 8051 should already be checked by LED test. 5. The program should be verified in PROTEUS.
  • 17. Final Remark on μC 8051 LAB: Small Size, Low-Cost, Same Function: AT89C2051
  • 18. Lab Tasks  Serially communicate with PC. If key pressed is that of your workstation number then display ‘Workstation#xy’ otherwise display ‘Invalid input’.  Quiz Next Week of Timers. 1. Last Week Submissions: Project SW, HW and Report (ADC0804 submission) 2. Vivas from Project and μC Lab 3. Lab Manual Submission