SlideShare a Scribd company logo
1
The 8051 Microcontroller
and Embedded Systems
Chapter 10
8051 Serial Communications
From the text by Mazidi & Mazidi (2000)
2
Serial Vs Parallel
3
Serial Transfers
4
Serial Transfers
A protocol is a set of rules agreed by both the sender and receiver
on
How the data is packed
How many bits constitute a character
When the data begins and ends
Asynchronous serial data communication is widely used for
character-oriented transmissions
Each character is placed in between start and stop bits, this is
called framing
Block-oriented data transfers use the synchronous method
The start bit is always one bit, but the stop bit can be one or
two bits
5
Asynchronous
• Bit timing is important since both
transmitter and receiver need to be in
agreement of timing.
• Bit Width = 1/Baud rate or bit rate
• 9600 Baud = bit width of 104uS
6
Setting Baud Rate
• For Baud rate, OSC/12 then /32.
• Timer 1 in Mode 2 is used as Baud Rate
Generator.
• 28,800/3 = 9600 baud
• 28,800/12 = 2400 baud
• 28,800/24 = 1200 baud
• And so on.
7
8
SBUF
• Serial buffer, SBUF is used to hold data to
be transmitted on TxD, and holds received
data on RxD.
• Note that there are actually 2 SBUFs, but
one is read only and one is write only.
MOV SBUF, A
MOV A, SBUF
9
SCON
• SCON, serial control register, is used for
serial control.
Mode 0: In this
mode the serial port
function as half
duplex serial port
with fixed baud
rate.
10
• REN (receive enable)
SCON is a bit-addressable register
When REN is high, it allows 8051 to receive data
on RxD pin; If low the receiver is disable
• TI (transmit interrupt)
When 8051 finishes the transfer of 8-bit character
It raises TI flag to indicate that it is ready to
transfer another byte
TI bit is raised at the beginning of the stop bit
11
• RI (receive interrupt)
When 8051 receives data serially via RxD, it
gets rid of the start and stop bits and places
the byte in SBUF register
It raises the RI flag bit to indicate that a byte
has been received and should be picked up
before it is lost
RI is raised halfway through the stop bit
12
Programming the 8051 to transfer serially
a. Initialize the timer 1 in mode 2 to perform auto reload.
b. Set the baud
c. Load SCON with 50H, indicating serial mode1 where 8 bits data
are transmit with one start and one stop bit
d. Set TR1 to start timer
e. clear interrupt flag, CLR, TI
f. Character byte to be transfer serially is being written into SBUF
g. TI flag is monitored with the use of JNB TI, XX
h. To transfer the next character, go to step e
13
Programming the 8051 to receive data serially
a. Initialize the timer 1 in mode 2 to perform auto reload.
b. Set the baud
c. Load SCON with 50H, indicating serial mode1 where 8 bits data
are transmit with one start and one stop bit
d. Set TR1 to start timer
e. clear interrupt flag, CLR, RI
f. Character byte to be transfer serially is being written into SBUF
g. TI flag is monitored with the use of JNB RI, XX
h. To transfer the next character, go to step e
14
Output?
MOV TMOD,#20H ;timer 1,mode 2(auto reload)
MOV TH1,#-6 ;4800 baud rate
MOV SCON,#50H ;8-bit, 1 stop, REN enabled
SETB TR1 ;start timer 1
AGAIN: MOV SBUF,#”A” ;letter “A” to transfer
HERE: JNB TI,HERE ;wait for the last bit
CLR TI ;clear TI for next char
SJMP AGAIN ;keep sending A
15
Problems
1. Write a program to transfer the letter ‘y’ serially at 9600
baud connected to P3.1 continuously.
2. Write program to take data through ports P0, P1, and P2
one after another and transfer the data serially one by
one.
3. Write the program to receive the data which has been
send in serial form and send it out to port 0 in parallel
form. Save the data at RAM location 60H
4. Write the program to transfer the numbers 1 to 9 serially.
5. Discuss how baud in 8051 can be doubled?
16
Problem 1
MOV TMOD, #20H
MOV TH1, #-3
MOV SCON, #50H
SETB TR1
CLR TI
AGAIN:MOV SBUF, #‘Y’
HERE: JNB TI, HERE
CLR TI
SJMP AGAIN
17
Problem 2
MOV TMOD, #20H
MOV TH1, #-3
MOV SCON, #50H
MOV P0,#0FFH ; MAKE P0 input port
MOV P0,#0FFH
MOV P0,#0FFH
SETB TR1
CLR TI
AGAIN: MOV A, P0
ACALL SEND
MOV A, P1
ACALL SEND
MOV A, P2
ACALL SEND
SJMP AGAIN
SEND: MOV SBUF, A
HERE: JNB TI, HERE
CLR TI
RET
18
DOUBLING THE BAUDS RATE
There are two ways to increase the baud rate of
data transfer
To use a higher frequency crystal
To change a bit in the PCON register
PCON register is an 8-bit register
When 8051 is powered up, SMOD is zero
We can set it to high by software and thereby
double the baud rate
19
Baud rates for SMOD=0
Machine cycle freq. = 11.0592 MHz / 12 = 921.6 kHz
and
921.6 kHz / 32 = 28,800 Hz since SMOD = 0
20
Baud rates for SMOD=1
Machine cycle freq. = 11.0592 MHz / 12 = 921.6 kHz
and
921.6 kHz / 16 = 57,600 Hz since SMOD = 1
MOV A, PCON
SETB ACC.7
MOV PCON, A

More Related Content

Similar to Serial.ppt and it contains all information

Serial communication in 8051 microcontroller
Serial communication in 8051 microcontrollerSerial communication in 8051 microcontroller
Serial communication in 8051 microcontrollerIshwarNirale2
 
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
 
EC8691 - UNIT 5.pdf
EC8691 - UNIT 5.pdfEC8691 - UNIT 5.pdf
EC8691 - UNIT 5.pdfSPonmalar1
 
8051 SERIAL PORTS.pptx
8051 SERIAL PORTS.pptx8051 SERIAL PORTS.pptx
8051 SERIAL PORTS.pptxmaheswariM7
 
I2C protocol and DS1307 RTC interfacing
I2C protocol and DS1307 RTC interfacingI2C protocol and DS1307 RTC interfacing
I2C protocol and DS1307 RTC interfacingBhargav Kakadiya
 
8051 TIMER COUNTER SERIAL COMM. INTERUPT PROGRAMMING.pdf
8051 TIMER COUNTER SERIAL COMM. INTERUPT PROGRAMMING.pdf8051 TIMER COUNTER SERIAL COMM. INTERUPT PROGRAMMING.pdf
8051 TIMER COUNTER SERIAL COMM. INTERUPT PROGRAMMING.pdfShashiKiran664181
 
Sereial com. ppt
Sereial com. pptSereial com. ppt
Sereial com. pptgaurav5345
 
Micro c lab8(serial communication)
Micro c lab8(serial communication)Micro c lab8(serial communication)
Micro c lab8(serial communication)Mashood
 
Unit iii microcontrollers final1
Unit iii microcontrollers final1Unit iii microcontrollers final1
Unit iii microcontrollers final1Saritha Reddy
 
Library Book Locator
Library Book LocatorLibrary Book Locator
Library Book LocatorArun Joseph
 
serial-200505101453.pdf
serial-200505101453.pdfserial-200505101453.pdf
serial-200505101453.pdfKiranG731731
 
Serial Communication
Serial CommunicationSerial Communication
Serial CommunicationUshaRani289
 
Universal Serial Communication Interface
Universal Serial Communication InterfaceUniversal Serial Communication Interface
Universal Serial Communication InterfaceSandesh Agrawal
 
Chp7 pic 16 f84 interfacing - copy
Chp7 pic 16 f84 interfacing - copyChp7 pic 16 f84 interfacing - copy
Chp7 pic 16 f84 interfacing - copymkazree
 
8051 microcontroller notes continuous
8051 microcontroller notes continuous 8051 microcontroller notes continuous
8051 microcontroller notes continuous THANDAIAH PRABU
 

Similar to Serial.ppt and it contains all information (20)

Serial communication in 8051 microcontroller
Serial communication in 8051 microcontrollerSerial communication in 8051 microcontroller
Serial communication in 8051 microcontroller
 
AN INTRODUCTION TO SERIAL PORT INTERFACING
AN INTRODUCTION TO SERIAL PORT INTERFACINGAN INTRODUCTION TO SERIAL PORT INTERFACING
AN INTRODUCTION TO SERIAL PORT INTERFACING
 
EC8691 - UNIT 5.pdf
EC8691 - UNIT 5.pdfEC8691 - UNIT 5.pdf
EC8691 - UNIT 5.pdf
 
8051 SERIAL PORTS.pptx
8051 SERIAL PORTS.pptx8051 SERIAL PORTS.pptx
8051 SERIAL PORTS.pptx
 
I2C protocol and DS1307 RTC interfacing
I2C protocol and DS1307 RTC interfacingI2C protocol and DS1307 RTC interfacing
I2C protocol and DS1307 RTC interfacing
 
Class10
Class10Class10
Class10
 
Serial Communication in 8051
Serial Communication in 8051Serial Communication in 8051
Serial Communication in 8051
 
8051 TIMER COUNTER SERIAL COMM. INTERUPT PROGRAMMING.pdf
8051 TIMER COUNTER SERIAL COMM. INTERUPT PROGRAMMING.pdf8051 TIMER COUNTER SERIAL COMM. INTERUPT PROGRAMMING.pdf
8051 TIMER COUNTER SERIAL COMM. INTERUPT PROGRAMMING.pdf
 
Sereial com. ppt
Sereial com. pptSereial com. ppt
Sereial com. ppt
 
Micro c lab8(serial communication)
Micro c lab8(serial communication)Micro c lab8(serial communication)
Micro c lab8(serial communication)
 
Unit iii microcontrollers final1
Unit iii microcontrollers final1Unit iii microcontrollers final1
Unit iii microcontrollers final1
 
Library Book Locator
Library Book LocatorLibrary Book Locator
Library Book Locator
 
serial-200505101453.pdf
serial-200505101453.pdfserial-200505101453.pdf
serial-200505101453.pdf
 
Serial Communication
Serial CommunicationSerial Communication
Serial Communication
 
Chapter5 dek3133
Chapter5 dek3133Chapter5 dek3133
Chapter5 dek3133
 
Serial data transfer
Serial data transferSerial data transfer
Serial data transfer
 
Universal Serial Communication Interface
Universal Serial Communication InterfaceUniversal Serial Communication Interface
Universal Serial Communication Interface
 
Peripheral 8245,16550&8237 dma controller
Peripheral 8245,16550&8237 dma controllerPeripheral 8245,16550&8237 dma controller
Peripheral 8245,16550&8237 dma controller
 
Chp7 pic 16 f84 interfacing - copy
Chp7 pic 16 f84 interfacing - copyChp7 pic 16 f84 interfacing - copy
Chp7 pic 16 f84 interfacing - copy
 
8051 microcontroller notes continuous
8051 microcontroller notes continuous 8051 microcontroller notes continuous
8051 microcontroller notes continuous
 

Recently uploaded

The Last Leaf, a short story by O. Henry
The Last Leaf, a short story by O. HenryThe Last Leaf, a short story by O. Henry
The Last Leaf, a short story by O. HenryEugene Lysak
 
Students, digital devices and success - Andreas Schleicher - 27 May 2024..pptx
Students, digital devices and success - Andreas Schleicher - 27 May 2024..pptxStudents, digital devices and success - Andreas Schleicher - 27 May 2024..pptx
Students, digital devices and success - Andreas Schleicher - 27 May 2024..pptxEduSkills OECD
 
Open Educational Resources Primer PowerPoint
Open Educational Resources Primer PowerPointOpen Educational Resources Primer PowerPoint
Open Educational Resources Primer PowerPointELaRue0
 
ppt your views.ppt your views of your college in your eyes
ppt your views.ppt your views of your college in your eyesppt your views.ppt your views of your college in your eyes
ppt your views.ppt your views of your college in your eyesashishpaul799
 
An Overview of the Odoo 17 Discuss App.pptx
An Overview of the Odoo 17 Discuss App.pptxAn Overview of the Odoo 17 Discuss App.pptx
An Overview of the Odoo 17 Discuss App.pptxCeline George
 
How to Break the cycle of negative Thoughts
How to Break the cycle of negative ThoughtsHow to Break the cycle of negative Thoughts
How to Break the cycle of negative ThoughtsCol Mukteshwar Prasad
 
PART A. Introduction to Costumer Service
PART A. Introduction to Costumer ServicePART A. Introduction to Costumer Service
PART A. Introduction to Costumer ServicePedroFerreira53928
 
50 ĐỀ LUYỆN THI IOE LỚP 9 - NĂM HỌC 2022-2023 (CÓ LINK HÌNH, FILE AUDIO VÀ ĐÁ...
50 ĐỀ LUYỆN THI IOE LỚP 9 - NĂM HỌC 2022-2023 (CÓ LINK HÌNH, FILE AUDIO VÀ ĐÁ...50 ĐỀ LUYỆN THI IOE LỚP 9 - NĂM HỌC 2022-2023 (CÓ LINK HÌNH, FILE AUDIO VÀ ĐÁ...
50 ĐỀ LUYỆN THI IOE LỚP 9 - NĂM HỌC 2022-2023 (CÓ LINK HÌNH, FILE AUDIO VÀ ĐÁ...Nguyen Thanh Tu Collection
 
Advances in production technology of Grapes.pdf
Advances in production technology of Grapes.pdfAdvances in production technology of Grapes.pdf
Advances in production technology of Grapes.pdfDr. M. Kumaresan Hort.
 
How to Manage Notification Preferences in the Odoo 17
How to Manage Notification Preferences in the Odoo 17How to Manage Notification Preferences in the Odoo 17
How to Manage Notification Preferences in the Odoo 17Celine George
 
Danh sách HSG Bộ môn cấp trường - Cấp THPT.pdf
Danh sách HSG Bộ môn cấp trường - Cấp THPT.pdfDanh sách HSG Bộ môn cấp trường - Cấp THPT.pdf
Danh sách HSG Bộ môn cấp trường - Cấp THPT.pdfQucHHunhnh
 
Application of Matrices in real life. Presentation on application of matrices
Application of Matrices in real life. Presentation on application of matricesApplication of Matrices in real life. Presentation on application of matrices
Application of Matrices in real life. Presentation on application of matricesRased Khan
 
Sectors of the Indian Economy - Class 10 Study Notes pdf
Sectors of the Indian Economy - Class 10 Study Notes pdfSectors of the Indian Economy - Class 10 Study Notes pdf
Sectors of the Indian Economy - Class 10 Study Notes pdfVivekanand Anglo Vedic Academy
 
Basic Civil Engg Notes_Chapter-6_Environment Pollution & Engineering
Basic Civil Engg Notes_Chapter-6_Environment Pollution & EngineeringBasic Civil Engg Notes_Chapter-6_Environment Pollution & Engineering
Basic Civil Engg Notes_Chapter-6_Environment Pollution & EngineeringDenish Jangid
 
Benefits and Challenges of Using Open Educational Resources
Benefits and Challenges of Using Open Educational ResourcesBenefits and Challenges of Using Open Educational Resources
Benefits and Challenges of Using Open Educational Resourcesdimpy50
 
Jose-Rizal-and-Philippine-Nationalism-National-Symbol-2.pptx
Jose-Rizal-and-Philippine-Nationalism-National-Symbol-2.pptxJose-Rizal-and-Philippine-Nationalism-National-Symbol-2.pptx
Jose-Rizal-and-Philippine-Nationalism-National-Symbol-2.pptxricssacare
 
MARUTI SUZUKI- A Successful Joint Venture in India.pptx
MARUTI SUZUKI- A Successful Joint Venture in India.pptxMARUTI SUZUKI- A Successful Joint Venture in India.pptx
MARUTI SUZUKI- A Successful Joint Venture in India.pptxbennyroshan06
 

Recently uploaded (20)

The Last Leaf, a short story by O. Henry
The Last Leaf, a short story by O. HenryThe Last Leaf, a short story by O. Henry
The Last Leaf, a short story by O. Henry
 
Students, digital devices and success - Andreas Schleicher - 27 May 2024..pptx
Students, digital devices and success - Andreas Schleicher - 27 May 2024..pptxStudents, digital devices and success - Andreas Schleicher - 27 May 2024..pptx
Students, digital devices and success - Andreas Schleicher - 27 May 2024..pptx
 
Open Educational Resources Primer PowerPoint
Open Educational Resources Primer PowerPointOpen Educational Resources Primer PowerPoint
Open Educational Resources Primer PowerPoint
 
ppt your views.ppt your views of your college in your eyes
ppt your views.ppt your views of your college in your eyesppt your views.ppt your views of your college in your eyes
ppt your views.ppt your views of your college in your eyes
 
An Overview of the Odoo 17 Discuss App.pptx
An Overview of the Odoo 17 Discuss App.pptxAn Overview of the Odoo 17 Discuss App.pptx
An Overview of the Odoo 17 Discuss App.pptx
 
How to Break the cycle of negative Thoughts
How to Break the cycle of negative ThoughtsHow to Break the cycle of negative Thoughts
How to Break the cycle of negative Thoughts
 
PART A. Introduction to Costumer Service
PART A. Introduction to Costumer ServicePART A. Introduction to Costumer Service
PART A. Introduction to Costumer Service
 
50 ĐỀ LUYỆN THI IOE LỚP 9 - NĂM HỌC 2022-2023 (CÓ LINK HÌNH, FILE AUDIO VÀ ĐÁ...
50 ĐỀ LUYỆN THI IOE LỚP 9 - NĂM HỌC 2022-2023 (CÓ LINK HÌNH, FILE AUDIO VÀ ĐÁ...50 ĐỀ LUYỆN THI IOE LỚP 9 - NĂM HỌC 2022-2023 (CÓ LINK HÌNH, FILE AUDIO VÀ ĐÁ...
50 ĐỀ LUYỆN THI IOE LỚP 9 - NĂM HỌC 2022-2023 (CÓ LINK HÌNH, FILE AUDIO VÀ ĐÁ...
 
Advances in production technology of Grapes.pdf
Advances in production technology of Grapes.pdfAdvances in production technology of Grapes.pdf
Advances in production technology of Grapes.pdf
 
NCERT Solutions Power Sharing Class 10 Notes pdf
NCERT Solutions Power Sharing Class 10 Notes pdfNCERT Solutions Power Sharing Class 10 Notes pdf
NCERT Solutions Power Sharing Class 10 Notes pdf
 
How to Manage Notification Preferences in the Odoo 17
How to Manage Notification Preferences in the Odoo 17How to Manage Notification Preferences in the Odoo 17
How to Manage Notification Preferences in the Odoo 17
 
Danh sách HSG Bộ môn cấp trường - Cấp THPT.pdf
Danh sách HSG Bộ môn cấp trường - Cấp THPT.pdfDanh sách HSG Bộ môn cấp trường - Cấp THPT.pdf
Danh sách HSG Bộ môn cấp trường - Cấp THPT.pdf
 
Introduction to Quality Improvement Essentials
Introduction to Quality Improvement EssentialsIntroduction to Quality Improvement Essentials
Introduction to Quality Improvement Essentials
 
Application of Matrices in real life. Presentation on application of matrices
Application of Matrices in real life. Presentation on application of matricesApplication of Matrices in real life. Presentation on application of matrices
Application of Matrices in real life. Presentation on application of matrices
 
Operations Management - Book1.p - Dr. Abdulfatah A. Salem
Operations Management - Book1.p  - Dr. Abdulfatah A. SalemOperations Management - Book1.p  - Dr. Abdulfatah A. Salem
Operations Management - Book1.p - Dr. Abdulfatah A. Salem
 
Sectors of the Indian Economy - Class 10 Study Notes pdf
Sectors of the Indian Economy - Class 10 Study Notes pdfSectors of the Indian Economy - Class 10 Study Notes pdf
Sectors of the Indian Economy - Class 10 Study Notes pdf
 
Basic Civil Engg Notes_Chapter-6_Environment Pollution & Engineering
Basic Civil Engg Notes_Chapter-6_Environment Pollution & EngineeringBasic Civil Engg Notes_Chapter-6_Environment Pollution & Engineering
Basic Civil Engg Notes_Chapter-6_Environment Pollution & Engineering
 
Benefits and Challenges of Using Open Educational Resources
Benefits and Challenges of Using Open Educational ResourcesBenefits and Challenges of Using Open Educational Resources
Benefits and Challenges of Using Open Educational Resources
 
Jose-Rizal-and-Philippine-Nationalism-National-Symbol-2.pptx
Jose-Rizal-and-Philippine-Nationalism-National-Symbol-2.pptxJose-Rizal-and-Philippine-Nationalism-National-Symbol-2.pptx
Jose-Rizal-and-Philippine-Nationalism-National-Symbol-2.pptx
 
MARUTI SUZUKI- A Successful Joint Venture in India.pptx
MARUTI SUZUKI- A Successful Joint Venture in India.pptxMARUTI SUZUKI- A Successful Joint Venture in India.pptx
MARUTI SUZUKI- A Successful Joint Venture in India.pptx
 

Serial.ppt and it contains all information

  • 1. 1 The 8051 Microcontroller and Embedded Systems Chapter 10 8051 Serial Communications From the text by Mazidi & Mazidi (2000)
  • 4. 4 Serial Transfers A protocol is a set of rules agreed by both the sender and receiver on How the data is packed How many bits constitute a character When the data begins and ends Asynchronous serial data communication is widely used for character-oriented transmissions Each character is placed in between start and stop bits, this is called framing Block-oriented data transfers use the synchronous method The start bit is always one bit, but the stop bit can be one or two bits
  • 5. 5 Asynchronous • Bit timing is important since both transmitter and receiver need to be in agreement of timing. • Bit Width = 1/Baud rate or bit rate • 9600 Baud = bit width of 104uS
  • 6. 6 Setting Baud Rate • For Baud rate, OSC/12 then /32. • Timer 1 in Mode 2 is used as Baud Rate Generator. • 28,800/3 = 9600 baud • 28,800/12 = 2400 baud • 28,800/24 = 1200 baud • And so on.
  • 7. 7
  • 8. 8 SBUF • Serial buffer, SBUF is used to hold data to be transmitted on TxD, and holds received data on RxD. • Note that there are actually 2 SBUFs, but one is read only and one is write only. MOV SBUF, A MOV A, SBUF
  • 9. 9 SCON • SCON, serial control register, is used for serial control. Mode 0: In this mode the serial port function as half duplex serial port with fixed baud rate.
  • 10. 10 • REN (receive enable) SCON is a bit-addressable register When REN is high, it allows 8051 to receive data on RxD pin; If low the receiver is disable • TI (transmit interrupt) When 8051 finishes the transfer of 8-bit character It raises TI flag to indicate that it is ready to transfer another byte TI bit is raised at the beginning of the stop bit
  • 11. 11 • RI (receive interrupt) When 8051 receives data serially via RxD, it gets rid of the start and stop bits and places the byte in SBUF register It raises the RI flag bit to indicate that a byte has been received and should be picked up before it is lost RI is raised halfway through the stop bit
  • 12. 12 Programming the 8051 to transfer serially a. Initialize the timer 1 in mode 2 to perform auto reload. b. Set the baud c. Load SCON with 50H, indicating serial mode1 where 8 bits data are transmit with one start and one stop bit d. Set TR1 to start timer e. clear interrupt flag, CLR, TI f. Character byte to be transfer serially is being written into SBUF g. TI flag is monitored with the use of JNB TI, XX h. To transfer the next character, go to step e
  • 13. 13 Programming the 8051 to receive data serially a. Initialize the timer 1 in mode 2 to perform auto reload. b. Set the baud c. Load SCON with 50H, indicating serial mode1 where 8 bits data are transmit with one start and one stop bit d. Set TR1 to start timer e. clear interrupt flag, CLR, RI f. Character byte to be transfer serially is being written into SBUF g. TI flag is monitored with the use of JNB RI, XX h. To transfer the next character, go to step e
  • 14. 14 Output? MOV TMOD,#20H ;timer 1,mode 2(auto reload) MOV TH1,#-6 ;4800 baud rate MOV SCON,#50H ;8-bit, 1 stop, REN enabled SETB TR1 ;start timer 1 AGAIN: MOV SBUF,#”A” ;letter “A” to transfer HERE: JNB TI,HERE ;wait for the last bit CLR TI ;clear TI for next char SJMP AGAIN ;keep sending A
  • 15. 15 Problems 1. Write a program to transfer the letter ‘y’ serially at 9600 baud connected to P3.1 continuously. 2. Write program to take data through ports P0, P1, and P2 one after another and transfer the data serially one by one. 3. Write the program to receive the data which has been send in serial form and send it out to port 0 in parallel form. Save the data at RAM location 60H 4. Write the program to transfer the numbers 1 to 9 serially. 5. Discuss how baud in 8051 can be doubled?
  • 16. 16 Problem 1 MOV TMOD, #20H MOV TH1, #-3 MOV SCON, #50H SETB TR1 CLR TI AGAIN:MOV SBUF, #‘Y’ HERE: JNB TI, HERE CLR TI SJMP AGAIN
  • 17. 17 Problem 2 MOV TMOD, #20H MOV TH1, #-3 MOV SCON, #50H MOV P0,#0FFH ; MAKE P0 input port MOV P0,#0FFH MOV P0,#0FFH SETB TR1 CLR TI AGAIN: MOV A, P0 ACALL SEND MOV A, P1 ACALL SEND MOV A, P2 ACALL SEND SJMP AGAIN SEND: MOV SBUF, A HERE: JNB TI, HERE CLR TI RET
  • 18. 18 DOUBLING THE BAUDS RATE There are two ways to increase the baud rate of data transfer To use a higher frequency crystal To change a bit in the PCON register PCON register is an 8-bit register When 8051 is powered up, SMOD is zero We can set it to high by software and thereby double the baud rate
  • 19. 19 Baud rates for SMOD=0 Machine cycle freq. = 11.0592 MHz / 12 = 921.6 kHz and 921.6 kHz / 32 = 28,800 Hz since SMOD = 0
  • 20. 20 Baud rates for SMOD=1 Machine cycle freq. = 11.0592 MHz / 12 = 921.6 kHz and 921.6 kHz / 16 = 57,600 Hz since SMOD = 1 MOV A, PCON SETB ACC.7 MOV PCON, A