SlideShare a Scribd company logo
1 of 27
M_Nokhodchian @ yahoo.comM_Nokhodchian @ yahoo.com MicroprocessorsMicroprocessors 1-1-11
Serial
Communication
M_Nokhodchian @ yahoo.comM_Nokhodchian @ yahoo.com MicroprocessorsMicroprocessors 1-1-22
Basics of serial communication
Parallel: expensive - short distance – fast – no modulation
Serial :cheaper– long (two different cities by modem)-slow
M_Nokhodchian @ yahoo.comM_Nokhodchian @ yahoo.com MicroprocessorsMicroprocessors 1-1-33
Basics of serial communication
M_Nokhodchian @ yahoo.comM_Nokhodchian @ yahoo.com MicroprocessorsMicroprocessors 1-1-44
Packaging Data
Start and stop bits
In asynchronous transmission
When there is no transfer the signal is high
Transmission begins with a start (low) bit
LSB first
Finally 1 stop bit (high)
Data transfer rate (baud rate) is stated in bps
M_Nokhodchian @ yahoo.comM_Nokhodchian @ yahoo.com MicroprocessorsMicroprocessors 1-1-55
RS232 Standard
 Create in 1960 and updated in 1969
 Logic 1 : -3 to -25 volt
 Logic 0 : 3 to 25 volt
 To Connect TXD to RXD and RXD to TXD
from pc to 8051 you must use max232 to
convert signal from TTL level to RS232
level
 The baud rate of the 8051 must matched
the baud rate of the pc
 PC standard baud rate (see hyper terminal
configuration)
 2400-4800-9600-14400-19200-28800-
33600-57600
1 DCD
2 RD
3 TD
4 DTR
5 GND
6 DSR
7 RTS
8 CTS
9 RI
M_Nokhodchian @ yahoo.comM_Nokhodchian @ yahoo.com MicroprocessorsMicroprocessors 1-1-66
MAX232 or MAX233
M_Nokhodchian @ yahoo.comM_Nokhodchian @ yahoo.com MicroprocessorsMicroprocessors 1-1-77
SBUF register
MOV SBUF,#’D’ ;load SBUF=44H, ASCII for ‘D’
MOV SBUF,A ;copy accumulator into SBUF
MOV A,SBUF ;copy SBUF into accumulator
M_Nokhodchian @ yahoo.comM_Nokhodchian @ yahoo.com MicroprocessorsMicroprocessors 1-1-88
Serial control (SCON) Register
SM2 : used for multi processor communication
REN : receive enable (by software enable/disable)
TB8 : transmit bit8
RB8 : receive bit 8
TI : transmit interrupt flag set by HW after send , clear by SW
RI : receive interrupt flag set by HW after received ,clear by SW
SM0 RITIRB8TB8RENSM2SM1
7 6 5 4 3 2 1 0
SM0 SM1 MODE operation transmit rate
0 0 0 shift register fixed (xtal/12)
0 1 1 8 bit UART variable (timer1)
1 0 2 9 bit UART fixed (xtal/32 or xtal/64)
1 1 3 9 bit UART variable (timer1)
SM0 : mode specifier
SM1 : mode specifier
M_Nokhodchian @ yahoo.comM_Nokhodchian @ yahoo.com MicroprocessorsMicroprocessors 1-1-99
Mode of operation
 Mode 0 :
 Serial data enters and exits through RxD
 TxD outputs the shift clock.
 8 bits are transmitted/received(LSB first)
 The baud rate is fixed a 1/12 the oscillator frequency.
 Application
 Port expansion
8051
TXD
RXD Shift register
clk
data
M_Nokhodchian @ yahoo.comM_Nokhodchian @ yahoo.com MicroprocessorsMicroprocessors 1-1-1010
Timing of send in mode 0
One machine cycle
oscillator cycle
RXD (data)
TXD (clock pulse)
MOV SCON,#0001xxxxB
Wait: JNB RI,WAIT
CLR RI
MOV A,SBUF
MOV SCON,#0001xxxxB
Wait: JNB TI,WAIT
CLR TI
MOV SBUF,A
M_Nokhodchian @ yahoo.comM_Nokhodchian @ yahoo.com MicroprocessorsMicroprocessors 1-1-1111
Mode of operation
 Mode 1
 Ten bits are transmitted (through TxD) or received (through RxD)
(A start bit (0), 8 data bits (LSB first), and a stop bit (1) )
 On receive, the stop bit goes into RB8 in SCON
 the baud rate is determined by the Timer 1 overflow rate.
 Timer1 clock is 1/32 machine cycle (MC=1/12 XTAL)
• Timer clock can be programmed as 1/16 of machine cycle
• Transmission is initiated by any instruction that uses SBUF as
a destination register.
M_Nokhodchian @ yahoo.comM_Nokhodchian @ yahoo.com MicroprocessorsMicroprocessors 1-1-1212
Timer modes
GATE C/T M1 M0 GATE C/T M1 M0
Timer 1 Timer 0
(MSB) (LSB)
M_Nokhodchian @ yahoo.comM_Nokhodchian @ yahoo.com MicroprocessorsMicroprocessors 1-1-1313
M_Nokhodchian @ yahoo.comM_Nokhodchian @ yahoo.com MicroprocessorsMicroprocessors 1-1-1414
Programming for sending data
( in mode 1 )
4. SETB TR1
5. MOV SBUF, DATA
6. WAIT: JNB TI,WAIT
7. CLR TI
GATE C/T M1 M0 GATE C/T M1 M0
Timer 1 Timer 0
(MSB
)
(LSB)1. MOV TMOD,#20H
2. MOV TH1,# baud rate BAUD RATE VALUE IN TH VALUE IN HEX
9600 -3 FD
4800 -6 FA
2400 -12 F4
1200 -24 E8
XTAL=11.0592 MHz
3. MOV SCON,#50H
SM0 RITIRB8TB8RENSM2SM1
M_Nokhodchian @ yahoo.comM_Nokhodchian @ yahoo.com MicroprocessorsMicroprocessors 1-1-1515
Programming for sending data
( in mode 1 )
MOV TMOD,#20H ;TIMER 1 MODE 2
MOV TH1,#-3 ;9600 BAUD
MOV SCON,#50H ;REN enable
SETB TR1 ;start timer1
AGAIN: MOV SBUF, # “A”
WAIT: JNB TI,WAIT
CLR TI
SJMP AGAIN
Serial example(1)
M_Nokhodchian @ yahoo.comM_Nokhodchian @ yahoo.com MicroprocessorsMicroprocessors 1-1-1616
Programming for recieving data
( in mode 1 )
MOV TMOD,#20H ;TIMER 1 MODE 2
MOV TH1,#-3 ;9600 BAUD
MOV SCON,#50H ;REN enable
SETB TR1 ;start timer1
WAIT: JNB RI,WAIT
MOV A,SBUF
CLR RI
SJMP WAIT
Serial example(2)
M_Nokhodchian @ yahoo.comM_Nokhodchian @ yahoo.com MicroprocessorsMicroprocessors 1-1-1717
Serial example(3)
An example of sending a message.
;initialization
MOV TMOD,#20H
MOV TH1,#-12
MOV SCON,#50H
;begin to trnasmit
SETB TR1
AGAIN1: MOV A,#‘G'
CALL TRANSS
MOV A,#‘O'
CALL TRANSS
MOV A,#‘O'
CALL TRANSS
MOV A,#‘D'
CALL TRANSS
SJMP AGAIN1
;seial transmiting subroutine
TRANSS: MOV SBUF,A
AGAIN2: JNB TI,AGAIN2
CLR TI
RET
END
M_Nokhodchian @ yahoo.comM_Nokhodchian @ yahoo.com MicroprocessorsMicroprocessors 1-1-1818
Serial example(4)
ORG 0
MOV TMOD,#20H
MOV TH1,#0FAH ;4800
MOV SCON,#50H
SETB TR1
MOV DPTR,#MYDATA
LOOP: CLR A
MOVC A,@A+DPTR
JZ EXIT
ACALL SEND
INC DPTR
SJMP LOOP
;----------------------------------
SEND: MOV SBUF,A
WAIT: JNB TI,WAIT
CLR TI
RET
;----------------------------------
MYDATA: DB “THIS IS A SAMPLE TEST”,0
EXIT: END
M_Nokhodchian @ yahoo.comM_Nokhodchian @ yahoo.com MicroprocessorsMicroprocessors 1-1-1919
Mode of operation
 Mode 2 :
 Eleven bits are transmitted (through TxD), received (through RxD)
 A start bit (0)
 8 data bits (LSB first)
 A programmable 9th data bit
 and a stop bit (1)
 On transmit, the 9th bit (TB8) can be assigned 0 or 1.
 On receive, the 9the data bit goes into RB8 in SCON.
 the 9th
can be parity bit
 The baud rate is programmable to 1/32 or 1/64 the oscillator
frequency in Mode 2 by SMOD bit in PCON register
 Mode 3
 Same as mode 2
 But may have a variable baud rate generated from Timer 1.
M_Nokhodchian @ yahoo.comM_Nokhodchian @ yahoo.com MicroprocessorsMicroprocessors 1-1-2020
Mode of operation
M_Nokhodchian @ yahoo.comM_Nokhodchian @ yahoo.com MicroprocessorsMicroprocessors 1-1-2121
What is SMOD
 Bit 7 of PCON register
 If SMOD=1 double baud rate
 PCON is not bit addressable
 How to set SMOD
Mov a, pcon
Setb acc.7
Mov pcon,a
M_Nokhodchian @ yahoo.comM_Nokhodchian @ yahoo.com MicroprocessorsMicroprocessors 1-1-2222
Power control register
M_Nokhodchian @ yahoo.comM_Nokhodchian @ yahoo.com MicroprocessorsMicroprocessors 1-1-2323
Power control
A standard for applications where power
consumption is critical
two power reducing modes
 Idle
 Power down
M_Nokhodchian @ yahoo.comM_Nokhodchian @ yahoo.com MicroprocessorsMicroprocessors 1-1-2424
Idle mode
 An instruction that sets PCON.0 causes Idle mode
 Last instruction executed before going into the Idle mode
 the internal CPU clock is gated off
 Interrupt, Timer, and Serial Port functions act normally.
 All of registers , ports and internal RAM maintain their data
during Idle
 ALE and PSEN hold at logic high levels
 Any interrupt
 will cause PCON.0 to be cleared by HW (terminate Idle mode)
 then execute ISR
 with RETI return and execute next instruction after Idle
instruction.
 RST signal clears the IDL bit directly
M_Nokhodchian @ yahoo.comM_Nokhodchian @ yahoo.com MicroprocessorsMicroprocessors 1-1-2525
Power-Down Mode
 An instruction that sets PCON.1 causes power dowm
mode
 Last instruction executed before going into the power
down mode
 the on-chip oscillator is stopped.
 all functions are stopped,the contents of the on-chip
RAM and Special Function Registers are maintained.
 The ALE and PSEN output are held low
 The reset that terminates Power Down
M_Nokhodchian @ yahoo.comM_Nokhodchian @ yahoo.com MicroprocessorsMicroprocessors 1-1-2626
Power control example
Org 0000h
Ljmp main
Org 0003h
Orl pcon,#02h ;power down mode
Reti
Org 0030h
Main:
……
……
……
Orl pcon,#01h ;Idle mode
end
M_Nokhodchian @ yahoo.comM_Nokhodchian @ yahoo.com MicroprocessorsMicroprocessors 1-1-2727
example

More Related Content

What's hot (20)

Gsm modem interfacing with pic microcontroller
Gsm modem interfacing with pic microcontrollerGsm modem interfacing with pic microcontroller
Gsm modem interfacing with pic microcontroller
 
Gsm presentation
Gsm presentationGsm presentation
Gsm presentation
 
Chap10
Chap10Chap10
Chap10
 
Xcap post processing tool
Xcap post processing toolXcap post processing tool
Xcap post processing tool
 
Eigrp
EigrpEigrp
Eigrp
 
Linux 802.11 subsystem and brcmsmac WLAN driver
Linux 802.11 subsystem and brcmsmac WLAN driverLinux 802.11 subsystem and brcmsmac WLAN driver
Linux 802.11 subsystem and brcmsmac WLAN driver
 
Unit no 05
Unit no 05Unit no 05
Unit no 05
 
伺服馬達控制
伺服馬達控制伺服馬達控制
伺服馬達控制
 
ucttirm
ucttirmucttirm
ucttirm
 
Fx3 ge
Fx3 geFx3 ge
Fx3 ge
 
How to Configure Routing Information Protocol (RIP)
How to Configure Routing Information Protocol (RIP)How to Configure Routing Information Protocol (RIP)
How to Configure Routing Information Protocol (RIP)
 
SGSN- serving gprs support node - Platform - HW, SW and CLI
SGSN- serving gprs support node  - Platform - HW, SW and CLI SGSN- serving gprs support node  - Platform - HW, SW and CLI
SGSN- serving gprs support node - Platform - HW, SW and CLI
 
Seminar
SeminarSeminar
Seminar
 
Ccna3 module 9 exams
Ccna3 module 9 examsCcna3 module 9 exams
Ccna3 module 9 exams
 
Fx2 n spec
Fx2 n specFx2 n spec
Fx2 n spec
 
Mini plc-programmable logic controller
Mini plc-programmable logic controllerMini plc-programmable logic controller
Mini plc-programmable logic controller
 
Introduction to Nokia RNC
Introduction to Nokia RNCIntroduction to Nokia RNC
Introduction to Nokia RNC
 
Q series brochure_2008-03
Q series brochure_2008-03Q series brochure_2008-03
Q series brochure_2008-03
 
Step by step to install tn6 p
Step by step to install tn6 pStep by step to install tn6 p
Step by step to install tn6 p
 
Fx 1 n 1s
Fx 1 n 1sFx 1 n 1s
Fx 1 n 1s
 

Viewers also liked

Viewers also liked (20)

45039336 rs232
45039336 rs23245039336 rs232
45039336 rs232
 
Serial Data Communication
Serial Data CommunicationSerial Data Communication
Serial Data Communication
 
8251 usart programmable communication interface by aniket bhute
8251  usart  programmable communication interface by aniket bhute8251  usart  programmable communication interface by aniket bhute
8251 usart programmable communication interface by aniket bhute
 
Interfacing rs232
Interfacing rs232Interfacing rs232
Interfacing rs232
 
Serial Communication
Serial CommunicationSerial Communication
Serial Communication
 
Rs 232 interface
Rs 232 interfaceRs 232 interface
Rs 232 interface
 
Rs 232 y rs-485
Rs 232 y rs-485Rs 232 y rs-485
Rs 232 y rs-485
 
Communication protocols
Communication protocolsCommunication protocols
Communication protocols
 
8251 USART
8251 USART8251 USART
8251 USART
 
8251
82518251
8251
 
Data transferschemes
Data transferschemesData transferschemes
Data transferschemes
 
Communication protocols
Communication protocolsCommunication protocols
Communication protocols
 
Communication protocol presentation
Communication protocol presentationCommunication protocol presentation
Communication protocol presentation
 
RS 232
RS 232RS 232
RS 232
 
Serial Communication Interfaces
Serial Communication InterfacesSerial Communication Interfaces
Serial Communication Interfaces
 
UART
UARTUART
UART
 
8051 serial communication-UART
8051 serial communication-UART8051 serial communication-UART
8051 serial communication-UART
 
Communication protocols - Embedded Systems
Communication protocols - Embedded SystemsCommunication protocols - Embedded Systems
Communication protocols - Embedded Systems
 
Serial communication in LPC2148
Serial communication in LPC2148Serial communication in LPC2148
Serial communication in LPC2148
 
8259 Programmable Interrupt Controller by vijay
8259 Programmable Interrupt Controller by vijay8259 Programmable Interrupt Controller by vijay
8259 Programmable Interrupt Controller by vijay
 

Similar to 7 serial port

Sereial com. ppt
Sereial com. pptSereial com. ppt
Sereial com. pptgaurav5345
 
8051 serial communication1
8051 serial communication1 8051 serial communication1
8051 serial communication1 vijaydeepakg
 
8051 serial communication
8051 serial communication8051 serial communication
8051 serial communicationcanh phan
 
Serial communication
Serial communicationSerial communication
Serial communicationVikas Dongre
 
EC8691 - UNIT 5.pdf
EC8691 - UNIT 5.pdfEC8691 - UNIT 5.pdf
EC8691 - UNIT 5.pdfSPonmalar1
 
Micro c lab8(serial communication)
Micro c lab8(serial communication)Micro c lab8(serial communication)
Micro c lab8(serial communication)Mashood
 
CC2500 Wireless Trans-receiver Module
CC2500 Wireless Trans-receiver ModuleCC2500 Wireless Trans-receiver Module
CC2500 Wireless Trans-receiver ModuleAarya Technologies
 
Modem synchronization and control
Modem synchronization and controlModem synchronization and control
Modem synchronization and controlsirish2chandraa
 
Advanced motion controls dzralte 040l080
Advanced motion controls dzralte 040l080Advanced motion controls dzralte 040l080
Advanced motion controls dzralte 040l080Electromate
 
Microcontroller serial communication
Microcontroller serial communicationMicrocontroller serial communication
Microcontroller serial communicationNeeta Sawant
 
Serial Io
Serial IoSerial Io
Serial IoAisu
 
osw-1x8-multi-channel-rotary-optical-switch-data-sheet-550401.pdf
osw-1x8-multi-channel-rotary-optical-switch-data-sheet-550401.pdfosw-1x8-multi-channel-rotary-optical-switch-data-sheet-550401.pdf
osw-1x8-multi-channel-rotary-optical-switch-data-sheet-550401.pdfGLsun Mall
 
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
 
Output drops due to qo s on cisco 2960 3560 3750 switches
Output drops due to qo s on cisco 2960 3560 3750 switchesOutput drops due to qo s on cisco 2960 3560 3750 switches
Output drops due to qo s on cisco 2960 3560 3750 switchescandy tang
 
Lecture 10 (serial communication)
Lecture 10 (serial communication)Lecture 10 (serial communication)
Lecture 10 (serial communication)cairo university
 

Similar to 7 serial port (20)

Sereial com. ppt
Sereial com. pptSereial com. ppt
Sereial com. ppt
 
8051 serial communication1
8051 serial communication1 8051 serial communication1
8051 serial communication1
 
8051 serial communication
8051 serial communication8051 serial communication
8051 serial communication
 
Serial communication
Serial communicationSerial communication
Serial communication
 
EC8691 - UNIT 5.pdf
EC8691 - UNIT 5.pdfEC8691 - UNIT 5.pdf
EC8691 - UNIT 5.pdf
 
8051
80518051
8051
 
Micro c lab8(serial communication)
Micro c lab8(serial communication)Micro c lab8(serial communication)
Micro c lab8(serial communication)
 
Product catlog
Product catlogProduct catlog
Product catlog
 
CC2500 Wireless Trans-receiver Module
CC2500 Wireless Trans-receiver ModuleCC2500 Wireless Trans-receiver Module
CC2500 Wireless Trans-receiver Module
 
Modem synchronization and control
Modem synchronization and controlModem synchronization and control
Modem synchronization and control
 
Advanced motion controls dzralte 040l080
Advanced motion controls dzralte 040l080Advanced motion controls dzralte 040l080
Advanced motion controls dzralte 040l080
 
Microcontroller serial communication
Microcontroller serial communicationMicrocontroller serial communication
Microcontroller serial communication
 
Serial Io
Serial IoSerial Io
Serial Io
 
SDH and TDM telecom
SDH and TDM telecomSDH and TDM telecom
SDH and TDM telecom
 
0.pptx
0.pptx0.pptx
0.pptx
 
osw-1x8-multi-channel-rotary-optical-switch-data-sheet-550401.pdf
osw-1x8-multi-channel-rotary-optical-switch-data-sheet-550401.pdfosw-1x8-multi-channel-rotary-optical-switch-data-sheet-550401.pdf
osw-1x8-multi-channel-rotary-optical-switch-data-sheet-550401.pdf
 
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
 
Output drops due to qo s on cisco 2960 3560 3750 switches
Output drops due to qo s on cisco 2960 3560 3750 switchesOutput drops due to qo s on cisco 2960 3560 3750 switches
Output drops due to qo s on cisco 2960 3560 3750 switches
 
Commisioning.pptx
Commisioning.pptxCommisioning.pptx
Commisioning.pptx
 
Lecture 10 (serial communication)
Lecture 10 (serial communication)Lecture 10 (serial communication)
Lecture 10 (serial communication)
 

More from Samarth Patel

More from Samarth Patel (8)

daad
daaddaad
daad
 
Gmat handbook
Gmat handbookGmat handbook
Gmat handbook
 
Plc tutorial
Plc tutorialPlc tutorial
Plc tutorial
 
Basic plc
Basic plcBasic plc
Basic plc
 
Seminar on serial communication
Seminar on serial communicationSeminar on serial communication
Seminar on serial communication
 
Week10 ben-control
Week10 ben-controlWeek10 ben-control
Week10 ben-control
 
Length measurement
Length measurementLength measurement
Length measurement
 
Voltammetry
VoltammetryVoltammetry
Voltammetry
 

Recently uploaded

Exploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with MilvusExploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with MilvusZilliz
 
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdfRising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdfOrbitshub
 
Spring Boot vs Quarkus the ultimate battle - DevoxxUK
Spring Boot vs Quarkus the ultimate battle - DevoxxUKSpring Boot vs Quarkus the ultimate battle - DevoxxUK
Spring Boot vs Quarkus the ultimate battle - DevoxxUKJago de Vreede
 
JohnPollard-hybrid-app-RailsConf2024.pptx
JohnPollard-hybrid-app-RailsConf2024.pptxJohnPollard-hybrid-app-RailsConf2024.pptx
JohnPollard-hybrid-app-RailsConf2024.pptxJohnPollard37
 
[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdfSandro Moreira
 
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot ModelMcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot ModelDeepika Singh
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyKhushali Kathiriya
 
AI in Action: Real World Use Cases by Anitaraj
AI in Action: Real World Use Cases by AnitarajAI in Action: Real World Use Cases by Anitaraj
AI in Action: Real World Use Cases by AnitarajAnitaRaj43
 
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWEREMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWERMadyBayot
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FMESafe Software
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherRemote DBA Services
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...DianaGray10
 
CNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In PakistanCNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In Pakistandanishmna97
 
AI+A11Y 11MAY2024 HYDERBAD GAAD 2024 - HelloA11Y (11 May 2024)
AI+A11Y 11MAY2024 HYDERBAD GAAD 2024 - HelloA11Y (11 May 2024)AI+A11Y 11MAY2024 HYDERBAD GAAD 2024 - HelloA11Y (11 May 2024)
AI+A11Y 11MAY2024 HYDERBAD GAAD 2024 - HelloA11Y (11 May 2024)Samir Dash
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodJuan lago vázquez
 
ICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesrafiqahmad00786416
 
Introduction to use of FHIR Documents in ABDM
Introduction to use of FHIR Documents in ABDMIntroduction to use of FHIR Documents in ABDM
Introduction to use of FHIR Documents in ABDMKumar Satyam
 

Recently uploaded (20)

Exploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with MilvusExploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with Milvus
 
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdfRising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
Spring Boot vs Quarkus the ultimate battle - DevoxxUK
Spring Boot vs Quarkus the ultimate battle - DevoxxUKSpring Boot vs Quarkus the ultimate battle - DevoxxUK
Spring Boot vs Quarkus the ultimate battle - DevoxxUK
 
JohnPollard-hybrid-app-RailsConf2024.pptx
JohnPollard-hybrid-app-RailsConf2024.pptxJohnPollard-hybrid-app-RailsConf2024.pptx
JohnPollard-hybrid-app-RailsConf2024.pptx
 
[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf
 
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot ModelMcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : Uncertainty
 
Understanding the FAA Part 107 License ..
Understanding the FAA Part 107 License ..Understanding the FAA Part 107 License ..
Understanding the FAA Part 107 License ..
 
AI in Action: Real World Use Cases by Anitaraj
AI in Action: Real World Use Cases by AnitarajAI in Action: Real World Use Cases by Anitaraj
AI in Action: Real World Use Cases by Anitaraj
 
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWEREMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
CNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In PakistanCNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In Pakistan
 
AI+A11Y 11MAY2024 HYDERBAD GAAD 2024 - HelloA11Y (11 May 2024)
AI+A11Y 11MAY2024 HYDERBAD GAAD 2024 - HelloA11Y (11 May 2024)AI+A11Y 11MAY2024 HYDERBAD GAAD 2024 - HelloA11Y (11 May 2024)
AI+A11Y 11MAY2024 HYDERBAD GAAD 2024 - HelloA11Y (11 May 2024)
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
 
ICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesICT role in 21st century education and its challenges
ICT role in 21st century education and its challenges
 
Introduction to use of FHIR Documents in ABDM
Introduction to use of FHIR Documents in ABDMIntroduction to use of FHIR Documents in ABDM
Introduction to use of FHIR Documents in ABDM
 

7 serial port

  • 1. M_Nokhodchian @ yahoo.comM_Nokhodchian @ yahoo.com MicroprocessorsMicroprocessors 1-1-11 Serial Communication
  • 2. M_Nokhodchian @ yahoo.comM_Nokhodchian @ yahoo.com MicroprocessorsMicroprocessors 1-1-22 Basics of serial communication Parallel: expensive - short distance – fast – no modulation Serial :cheaper– long (two different cities by modem)-slow
  • 3. M_Nokhodchian @ yahoo.comM_Nokhodchian @ yahoo.com MicroprocessorsMicroprocessors 1-1-33 Basics of serial communication
  • 4. M_Nokhodchian @ yahoo.comM_Nokhodchian @ yahoo.com MicroprocessorsMicroprocessors 1-1-44 Packaging Data Start and stop bits In asynchronous transmission When there is no transfer the signal is high Transmission begins with a start (low) bit LSB first Finally 1 stop bit (high) Data transfer rate (baud rate) is stated in bps
  • 5. M_Nokhodchian @ yahoo.comM_Nokhodchian @ yahoo.com MicroprocessorsMicroprocessors 1-1-55 RS232 Standard  Create in 1960 and updated in 1969  Logic 1 : -3 to -25 volt  Logic 0 : 3 to 25 volt  To Connect TXD to RXD and RXD to TXD from pc to 8051 you must use max232 to convert signal from TTL level to RS232 level  The baud rate of the 8051 must matched the baud rate of the pc  PC standard baud rate (see hyper terminal configuration)  2400-4800-9600-14400-19200-28800- 33600-57600 1 DCD 2 RD 3 TD 4 DTR 5 GND 6 DSR 7 RTS 8 CTS 9 RI
  • 6. M_Nokhodchian @ yahoo.comM_Nokhodchian @ yahoo.com MicroprocessorsMicroprocessors 1-1-66 MAX232 or MAX233
  • 7. M_Nokhodchian @ yahoo.comM_Nokhodchian @ yahoo.com MicroprocessorsMicroprocessors 1-1-77 SBUF register MOV SBUF,#’D’ ;load SBUF=44H, ASCII for ‘D’ MOV SBUF,A ;copy accumulator into SBUF MOV A,SBUF ;copy SBUF into accumulator
  • 8. M_Nokhodchian @ yahoo.comM_Nokhodchian @ yahoo.com MicroprocessorsMicroprocessors 1-1-88 Serial control (SCON) Register SM2 : used for multi processor communication REN : receive enable (by software enable/disable) TB8 : transmit bit8 RB8 : receive bit 8 TI : transmit interrupt flag set by HW after send , clear by SW RI : receive interrupt flag set by HW after received ,clear by SW SM0 RITIRB8TB8RENSM2SM1 7 6 5 4 3 2 1 0 SM0 SM1 MODE operation transmit rate 0 0 0 shift register fixed (xtal/12) 0 1 1 8 bit UART variable (timer1) 1 0 2 9 bit UART fixed (xtal/32 or xtal/64) 1 1 3 9 bit UART variable (timer1) SM0 : mode specifier SM1 : mode specifier
  • 9. M_Nokhodchian @ yahoo.comM_Nokhodchian @ yahoo.com MicroprocessorsMicroprocessors 1-1-99 Mode of operation  Mode 0 :  Serial data enters and exits through RxD  TxD outputs the shift clock.  8 bits are transmitted/received(LSB first)  The baud rate is fixed a 1/12 the oscillator frequency.  Application  Port expansion 8051 TXD RXD Shift register clk data
  • 10. M_Nokhodchian @ yahoo.comM_Nokhodchian @ yahoo.com MicroprocessorsMicroprocessors 1-1-1010 Timing of send in mode 0 One machine cycle oscillator cycle RXD (data) TXD (clock pulse) MOV SCON,#0001xxxxB Wait: JNB RI,WAIT CLR RI MOV A,SBUF MOV SCON,#0001xxxxB Wait: JNB TI,WAIT CLR TI MOV SBUF,A
  • 11. M_Nokhodchian @ yahoo.comM_Nokhodchian @ yahoo.com MicroprocessorsMicroprocessors 1-1-1111 Mode of operation  Mode 1  Ten bits are transmitted (through TxD) or received (through RxD) (A start bit (0), 8 data bits (LSB first), and a stop bit (1) )  On receive, the stop bit goes into RB8 in SCON  the baud rate is determined by the Timer 1 overflow rate.  Timer1 clock is 1/32 machine cycle (MC=1/12 XTAL) • Timer clock can be programmed as 1/16 of machine cycle • Transmission is initiated by any instruction that uses SBUF as a destination register.
  • 12. M_Nokhodchian @ yahoo.comM_Nokhodchian @ yahoo.com MicroprocessorsMicroprocessors 1-1-1212 Timer modes GATE C/T M1 M0 GATE C/T M1 M0 Timer 1 Timer 0 (MSB) (LSB)
  • 13. M_Nokhodchian @ yahoo.comM_Nokhodchian @ yahoo.com MicroprocessorsMicroprocessors 1-1-1313
  • 14. M_Nokhodchian @ yahoo.comM_Nokhodchian @ yahoo.com MicroprocessorsMicroprocessors 1-1-1414 Programming for sending data ( in mode 1 ) 4. SETB TR1 5. MOV SBUF, DATA 6. WAIT: JNB TI,WAIT 7. CLR TI GATE C/T M1 M0 GATE C/T M1 M0 Timer 1 Timer 0 (MSB ) (LSB)1. MOV TMOD,#20H 2. MOV TH1,# baud rate BAUD RATE VALUE IN TH VALUE IN HEX 9600 -3 FD 4800 -6 FA 2400 -12 F4 1200 -24 E8 XTAL=11.0592 MHz 3. MOV SCON,#50H SM0 RITIRB8TB8RENSM2SM1
  • 15. M_Nokhodchian @ yahoo.comM_Nokhodchian @ yahoo.com MicroprocessorsMicroprocessors 1-1-1515 Programming for sending data ( in mode 1 ) MOV TMOD,#20H ;TIMER 1 MODE 2 MOV TH1,#-3 ;9600 BAUD MOV SCON,#50H ;REN enable SETB TR1 ;start timer1 AGAIN: MOV SBUF, # “A” WAIT: JNB TI,WAIT CLR TI SJMP AGAIN Serial example(1)
  • 16. M_Nokhodchian @ yahoo.comM_Nokhodchian @ yahoo.com MicroprocessorsMicroprocessors 1-1-1616 Programming for recieving data ( in mode 1 ) MOV TMOD,#20H ;TIMER 1 MODE 2 MOV TH1,#-3 ;9600 BAUD MOV SCON,#50H ;REN enable SETB TR1 ;start timer1 WAIT: JNB RI,WAIT MOV A,SBUF CLR RI SJMP WAIT Serial example(2)
  • 17. M_Nokhodchian @ yahoo.comM_Nokhodchian @ yahoo.com MicroprocessorsMicroprocessors 1-1-1717 Serial example(3) An example of sending a message. ;initialization MOV TMOD,#20H MOV TH1,#-12 MOV SCON,#50H ;begin to trnasmit SETB TR1 AGAIN1: MOV A,#‘G' CALL TRANSS MOV A,#‘O' CALL TRANSS MOV A,#‘O' CALL TRANSS MOV A,#‘D' CALL TRANSS SJMP AGAIN1 ;seial transmiting subroutine TRANSS: MOV SBUF,A AGAIN2: JNB TI,AGAIN2 CLR TI RET END
  • 18. M_Nokhodchian @ yahoo.comM_Nokhodchian @ yahoo.com MicroprocessorsMicroprocessors 1-1-1818 Serial example(4) ORG 0 MOV TMOD,#20H MOV TH1,#0FAH ;4800 MOV SCON,#50H SETB TR1 MOV DPTR,#MYDATA LOOP: CLR A MOVC A,@A+DPTR JZ EXIT ACALL SEND INC DPTR SJMP LOOP ;---------------------------------- SEND: MOV SBUF,A WAIT: JNB TI,WAIT CLR TI RET ;---------------------------------- MYDATA: DB “THIS IS A SAMPLE TEST”,0 EXIT: END
  • 19. M_Nokhodchian @ yahoo.comM_Nokhodchian @ yahoo.com MicroprocessorsMicroprocessors 1-1-1919 Mode of operation  Mode 2 :  Eleven bits are transmitted (through TxD), received (through RxD)  A start bit (0)  8 data bits (LSB first)  A programmable 9th data bit  and a stop bit (1)  On transmit, the 9th bit (TB8) can be assigned 0 or 1.  On receive, the 9the data bit goes into RB8 in SCON.  the 9th can be parity bit  The baud rate is programmable to 1/32 or 1/64 the oscillator frequency in Mode 2 by SMOD bit in PCON register  Mode 3  Same as mode 2  But may have a variable baud rate generated from Timer 1.
  • 20. M_Nokhodchian @ yahoo.comM_Nokhodchian @ yahoo.com MicroprocessorsMicroprocessors 1-1-2020 Mode of operation
  • 21. M_Nokhodchian @ yahoo.comM_Nokhodchian @ yahoo.com MicroprocessorsMicroprocessors 1-1-2121 What is SMOD  Bit 7 of PCON register  If SMOD=1 double baud rate  PCON is not bit addressable  How to set SMOD Mov a, pcon Setb acc.7 Mov pcon,a
  • 22. M_Nokhodchian @ yahoo.comM_Nokhodchian @ yahoo.com MicroprocessorsMicroprocessors 1-1-2222 Power control register
  • 23. M_Nokhodchian @ yahoo.comM_Nokhodchian @ yahoo.com MicroprocessorsMicroprocessors 1-1-2323 Power control A standard for applications where power consumption is critical two power reducing modes  Idle  Power down
  • 24. M_Nokhodchian @ yahoo.comM_Nokhodchian @ yahoo.com MicroprocessorsMicroprocessors 1-1-2424 Idle mode  An instruction that sets PCON.0 causes Idle mode  Last instruction executed before going into the Idle mode  the internal CPU clock is gated off  Interrupt, Timer, and Serial Port functions act normally.  All of registers , ports and internal RAM maintain their data during Idle  ALE and PSEN hold at logic high levels  Any interrupt  will cause PCON.0 to be cleared by HW (terminate Idle mode)  then execute ISR  with RETI return and execute next instruction after Idle instruction.  RST signal clears the IDL bit directly
  • 25. M_Nokhodchian @ yahoo.comM_Nokhodchian @ yahoo.com MicroprocessorsMicroprocessors 1-1-2525 Power-Down Mode  An instruction that sets PCON.1 causes power dowm mode  Last instruction executed before going into the power down mode  the on-chip oscillator is stopped.  all functions are stopped,the contents of the on-chip RAM and Special Function Registers are maintained.  The ALE and PSEN output are held low  The reset that terminates Power Down
  • 26. M_Nokhodchian @ yahoo.comM_Nokhodchian @ yahoo.com MicroprocessorsMicroprocessors 1-1-2626 Power control example Org 0000h Ljmp main Org 0003h Orl pcon,#02h ;power down mode Reti Org 0030h Main: …… …… …… Orl pcon,#01h ;Idle mode end
  • 27. M_Nokhodchian @ yahoo.comM_Nokhodchian @ yahoo.com MicroprocessorsMicroprocessors 1-1-2727 example