SlideShare a Scribd company logo
1 of 4
ORG 00H // origin
MOV DPTR,#LUT // moves the address of LUT to DPTR
MOV P1,#00000000B // sets P1 as output port
MOV P0,#00000000B // sets P0 as output port
CLR P3.0 // sets P3.0 as output for sending trigger
SETB P3.1 // sets P3.1 as input for receiving echo
MOV TMOD,#00100000B // sets timer1 as mode 2 auto reload timer
MAIN: MOV TL1,#207D // loads the initial value to start counting from
MOV TH1,#207D // loads the reload value
MOV A,#00000000B // clears accumulator
SETB P3.0 // starts the trigger pulse
ACALL DELAY1 // gives 10uS width for the trigger pulse
CLR P3.0 // ends the trigger pulse
HERE: JNB P3.1,HERE // loops here until echo is received
BACK: SETB TR1 // starts the timer1
HERE1: JNB TF1,HERE1 // loops here until timer overflows (ie;48 count)
CLR TR1 // stops the timer
CLR TF1 // clears timer flag 1
INC A // increments A for every timer1 overflow
JB P3.1,BACK // jumps to BACK if echo is still available
MOV R4,A // saves the value of A to R4
ACALL DLOOP // calls the display loop
SJMP MAIN // jumps to MAIN loop
DELAY1: MOV R6,#2D // 10uS delay
LABEL1: DJNZ R6,LABEL1
RET
DLOOP: MOV R5,#100D // loads R5 with 100D
BACK1: MOV A,R4 // loads the value in R4 to A
MOV B,#100D // loads B with 100D
DIV AB // isolates the first digit
SETB P1.0 // activates LED display unit D1
ACALL DISPLAY // calls DISPLAY subroutine
MOV P0,A // moves digit drive pattern for 1st digit to P0
ACALL DELAY // 1mS delay
ACALL DELAY
MOV A,B // moves the remainder of 1st division to A
MOV B,#10D // loads B with 10D
DIV AB // isolates the second digit
CLR P1.0 // deactivates LED display unit D1
SETB P1.1 // activates LED display unit D2
ACALL DISPLAY
MOV P0,A // moves digit drive pattern for 2nd digit to P0
ACALL DELAY
ACALL DELAY
MOV A,B // moves the remainder of 2nd division to A
CLR P1.1 // deactivates LED display unit D2
SETB P1.2 // activates LED display unit D3
ACALL DISPLAY
MOV P0,A // moves the digit drive pattern for 3rd digit to P0
ACALL DELAY
ACALL DELAY
CLR P1.2 // deactivates LED display unit D3
DJNZ R5,BACK1 // repeats the display loop 100 times
RET
DELAY: MOV R7,#250D // 1mS delay
LABEL2: DJNZ R7,LABEL2
RET
DISPLAY: MOVC A,@A+DPTR // gets the digit drive pattern for the content in A
CPL A // complements the digit drive pattern (see Note 1)
RET
LUT: DB 3FH // look up table (LUT) starts here
DB 06H
DB 5BH
DB 4FH
DB 66H
DB 6DH
DB 7DH
DB 07H
DB 7FH
DB 6FH
END

More Related Content

What's hot

Timer programming for 8051 using embedded c
Timer programming for 8051 using embedded cTimer programming for 8051 using embedded c
Timer programming for 8051 using embedded cVikas Dongre
 
The 8051 assembly language
The 8051 assembly languageThe 8051 assembly language
The 8051 assembly languagehemant meena
 
Maicrocontroller lab basic experiments
Maicrocontroller lab basic experimentsMaicrocontroller lab basic experiments
Maicrocontroller lab basic experimentsNoor Tahasildar
 
Micro c lab7(timers)
Micro c lab7(timers)Micro c lab7(timers)
Micro c lab7(timers)Mashood
 
New text document
New text documentNew text document
New text documentzocaniveb
 
Timer programming
Timer programming Timer programming
Timer programming vijaydeepakg
 
Using Timers in PIC18F Microcontrollers
Using Timers in PIC18F MicrocontrollersUsing Timers in PIC18F Microcontrollers
Using Timers in PIC18F MicrocontrollersCorrado Santoro
 
Stack and subroutine
Stack and subroutineStack and subroutine
Stack and subroutinemilandhara
 
86409 interfacing the keyboard to 8051 microcontroller
86409 interfacing the keyboard to 8051 microcontroller86409 interfacing the keyboard to 8051 microcontroller
86409 interfacing the keyboard to 8051 microcontrollerbheemsain
 

What's hot (14)

Timer programming for 8051 using embedded c
Timer programming for 8051 using embedded cTimer programming for 8051 using embedded c
Timer programming for 8051 using embedded c
 
The 8051 assembly language
The 8051 assembly languageThe 8051 assembly language
The 8051 assembly language
 
Mic practicals
Mic practicalsMic practicals
Mic practicals
 
Maicrocontroller lab basic experiments
Maicrocontroller lab basic experimentsMaicrocontroller lab basic experiments
Maicrocontroller lab basic experiments
 
8051 timers--2
   8051 timers--2   8051 timers--2
8051 timers--2
 
Micro c lab7(timers)
Micro c lab7(timers)Micro c lab7(timers)
Micro c lab7(timers)
 
8051 Timer
8051 Timer8051 Timer
8051 Timer
 
New text document
New text documentNew text document
New text document
 
Timer programming
Timer programming Timer programming
Timer programming
 
Using Timers in PIC18F Microcontrollers
Using Timers in PIC18F MicrocontrollersUsing Timers in PIC18F Microcontrollers
Using Timers in PIC18F Microcontrollers
 
Timers
TimersTimers
Timers
 
8051 ch9-950217
8051 ch9-9502178051 ch9-950217
8051 ch9-950217
 
Stack and subroutine
Stack and subroutineStack and subroutine
Stack and subroutine
 
86409 interfacing the keyboard to 8051 microcontroller
86409 interfacing the keyboard to 8051 microcontroller86409 interfacing the keyboard to 8051 microcontroller
86409 interfacing the keyboard to 8051 microcontroller
 

Viewers also liked

China dingxing desiccant factory assessment report
China dingxing desiccant factory assessment reportChina dingxing desiccant factory assessment report
China dingxing desiccant factory assessment reportScott Zhong
 
Brasil - inundações e deslizamentos 2011
Brasil - inundações e deslizamentos 2011Brasil - inundações e deslizamentos 2011
Brasil - inundações e deslizamentos 2011Carlos Gomes
 
Annu E-License (1)
Annu E-License (1)Annu E-License (1)
Annu E-License (1)Annu Manosh
 
How to Get the Younger Generation Involved - NAIOP Chapter Leadership & Legis...
How to Get the Younger Generation Involved - NAIOP Chapter Leadership & Legis...How to Get the Younger Generation Involved - NAIOP Chapter Leadership & Legis...
How to Get the Younger Generation Involved - NAIOP Chapter Leadership & Legis...Katie Olbrich
 
ก้าวแรกส่งานบริการ
ก้าวแรกส่งานบริการก้าวแรกส่งานบริการ
ก้าวแรกส่งานบริการSutthiluck Kaewboonrurn
 
Quality Improvement Project
Quality Improvement ProjectQuality Improvement Project
Quality Improvement ProjectKristen Oxender
 
Use Promise, Future and some functional programing stuff without being a math...
Use Promise, Future and some functional programing stuff without being a math...Use Promise, Future and some functional programing stuff without being a math...
Use Promise, Future and some functional programing stuff without being a math...Quentin Adam
 
Hacking Ruby with Python
Hacking Ruby with PythonHacking Ruby with Python
Hacking Ruby with PythonTaisuke Yamada
 
Las estaciones del año. educapeque 2ºb. educapeque 2ºb s
Las estaciones del año. educapeque 2ºb. educapeque 2ºb sLas estaciones del año. educapeque 2ºb. educapeque 2ºb s
Las estaciones del año. educapeque 2ºb. educapeque 2ºb sMarta López
 
Micro c lab3(ssd)
Micro c lab3(ssd)Micro c lab3(ssd)
Micro c lab3(ssd)Mashood
 
preventing sqli and xss by ravi rajput in owasp meet ahmedabad
preventing sqli and xss by ravi rajput in owasp meet ahmedabadpreventing sqli and xss by ravi rajput in owasp meet ahmedabad
preventing sqli and xss by ravi rajput in owasp meet ahmedabadRavi Rajput
 
Building a Dynamic Website Using Django
Building a Dynamic Website Using DjangoBuilding a Dynamic Website Using Django
Building a Dynamic Website Using DjangoNathan Eror
 
Selenium Tips & Tricks, presented at the Tel Aviv Selenium Meetup
Selenium Tips & Tricks, presented at the Tel Aviv Selenium MeetupSelenium Tips & Tricks, presented at the Tel Aviv Selenium Meetup
Selenium Tips & Tricks, presented at the Tel Aviv Selenium MeetupDave Haeffner
 
Defcon 21 - Fear the Evil FOCA: mitm attacks using IPv6
Defcon 21 - Fear the Evil FOCA: mitm attacks using IPv6Defcon 21 - Fear the Evil FOCA: mitm attacks using IPv6
Defcon 21 - Fear the Evil FOCA: mitm attacks using IPv6Chema Alonso
 

Viewers also liked (20)

Story
StoryStory
Story
 
Creating CD Covers
Creating CD CoversCreating CD Covers
Creating CD Covers
 
China dingxing desiccant factory assessment report
China dingxing desiccant factory assessment reportChina dingxing desiccant factory assessment report
China dingxing desiccant factory assessment report
 
A life kamarzi
A life  kamarziA life  kamarzi
A life kamarzi
 
Brasil - inundações e deslizamentos 2011
Brasil - inundações e deslizamentos 2011Brasil - inundações e deslizamentos 2011
Brasil - inundações e deslizamentos 2011
 
Annu E-License (1)
Annu E-License (1)Annu E-License (1)
Annu E-License (1)
 
How to Get the Younger Generation Involved - NAIOP Chapter Leadership & Legis...
How to Get the Younger Generation Involved - NAIOP Chapter Leadership & Legis...How to Get the Younger Generation Involved - NAIOP Chapter Leadership & Legis...
How to Get the Younger Generation Involved - NAIOP Chapter Leadership & Legis...
 
ก้าวแรกส่งานบริการ
ก้าวแรกส่งานบริการก้าวแรกส่งานบริการ
ก้าวแรกส่งานบริการ
 
Quality Improvement Project
Quality Improvement ProjectQuality Improvement Project
Quality Improvement Project
 
Use Promise, Future and some functional programing stuff without being a math...
Use Promise, Future and some functional programing stuff without being a math...Use Promise, Future and some functional programing stuff without being a math...
Use Promise, Future and some functional programing stuff without being a math...
 
Middle man
Middle manMiddle man
Middle man
 
Hacking Ruby with Python
Hacking Ruby with PythonHacking Ruby with Python
Hacking Ruby with Python
 
Django Testing
Django TestingDjango Testing
Django Testing
 
Las estaciones del año. educapeque 2ºb. educapeque 2ºb s
Las estaciones del año. educapeque 2ºb. educapeque 2ºb sLas estaciones del año. educapeque 2ºb. educapeque 2ºb s
Las estaciones del año. educapeque 2ºb. educapeque 2ºb s
 
Hacking y python: Hacking de redes con Python
Hacking y python: Hacking de redes con PythonHacking y python: Hacking de redes con Python
Hacking y python: Hacking de redes con Python
 
Micro c lab3(ssd)
Micro c lab3(ssd)Micro c lab3(ssd)
Micro c lab3(ssd)
 
preventing sqli and xss by ravi rajput in owasp meet ahmedabad
preventing sqli and xss by ravi rajput in owasp meet ahmedabadpreventing sqli and xss by ravi rajput in owasp meet ahmedabad
preventing sqli and xss by ravi rajput in owasp meet ahmedabad
 
Building a Dynamic Website Using Django
Building a Dynamic Website Using DjangoBuilding a Dynamic Website Using Django
Building a Dynamic Website Using Django
 
Selenium Tips & Tricks, presented at the Tel Aviv Selenium Meetup
Selenium Tips & Tricks, presented at the Tel Aviv Selenium MeetupSelenium Tips & Tricks, presented at the Tel Aviv Selenium Meetup
Selenium Tips & Tricks, presented at the Tel Aviv Selenium Meetup
 
Defcon 21 - Fear the Evil FOCA: mitm attacks using IPv6
Defcon 21 - Fear the Evil FOCA: mitm attacks using IPv6Defcon 21 - Fear the Evil FOCA: mitm attacks using IPv6
Defcon 21 - Fear the Evil FOCA: mitm attacks using IPv6
 

Similar to Code 8051

PWM wave generator using microcontroller
 PWM wave generator using microcontroller  PWM wave generator using microcontroller
PWM wave generator using microcontroller Swapnil2515
 
Solutionmanual8051microcontrollerbymazidi
Solutionmanual8051microcontrollerbymazidi Solutionmanual8051microcontrollerbymazidi
Solutionmanual8051microcontrollerbymazidi Ahsan Mehmood
 
Solutionmanual8051microcontrollerbymazidi 131215070701-phpapp02
Solutionmanual8051microcontrollerbymazidi 131215070701-phpapp02Solutionmanual8051microcontrollerbymazidi 131215070701-phpapp02
Solutionmanual8051microcontrollerbymazidi 131215070701-phpapp02SURYA DEEPAK
 
Applications of microcontroller(8051)
Applications of microcontroller(8051) Applications of microcontroller(8051)
Applications of microcontroller(8051) vijaydeepakg
 
WINSEM2023-24_BECE204L_TH_VL2023240505625_2024-01-29_Reference-Material-I.pptx
WINSEM2023-24_BECE204L_TH_VL2023240505625_2024-01-29_Reference-Material-I.pptxWINSEM2023-24_BECE204L_TH_VL2023240505625_2024-01-29_Reference-Material-I.pptx
WINSEM2023-24_BECE204L_TH_VL2023240505625_2024-01-29_Reference-Material-I.pptxSrinivasanUma1
 
1203 Ppi 8155
1203 Ppi 81551203 Ppi 8155
1203 Ppi 8155techbed
 
Microprocessor Week 9: Timer and Counter
Microprocessor Week 9: Timer and CounterMicroprocessor Week 9: Timer and Counter
Microprocessor Week 9: Timer and CounterArkhom Jodtang
 
Solution manual 8051 microcontroller by mazidi
Solution manual 8051 microcontroller by mazidiSolution manual 8051 microcontroller by mazidi
Solution manual 8051 microcontroller by mazidiMuhammad Abdullah
 
Analog to digital converter
Analog to digital converterAnalog to digital converter
Analog to digital converterCorrado Santoro
 
I o ports and timers of 8051
I o ports and timers of 8051I o ports and timers of 8051
I o ports and timers of 8051SARITHA REDDY
 
STL PN-DP Slave Com Log
STL PN-DP Slave Com LogSTL PN-DP Slave Com Log
STL PN-DP Slave Com LogTony Bell
 
Controlling Motors for Robot
Controlling Motors for RobotControlling Motors for Robot
Controlling Motors for RobotVarad Manglekar
 
Lab 9 D-Flip Flops: Shift Register and Sequence Counter
Lab 9 D-Flip Flops: Shift Register and Sequence CounterLab 9 D-Flip Flops: Shift Register and Sequence Counter
Lab 9 D-Flip Flops: Shift Register and Sequence CounterKatrina Little
 

Similar to Code 8051 (20)

PWM wave generator using microcontroller
 PWM wave generator using microcontroller  PWM wave generator using microcontroller
PWM wave generator using microcontroller
 
Solutionmanual8051microcontrollerbymazidi
Solutionmanual8051microcontrollerbymazidi Solutionmanual8051microcontrollerbymazidi
Solutionmanual8051microcontrollerbymazidi
 
Solutionmanual8051microcontrollerbymazidi 131215070701-phpapp02
Solutionmanual8051microcontrollerbymazidi 131215070701-phpapp02Solutionmanual8051microcontrollerbymazidi 131215070701-phpapp02
Solutionmanual8051microcontrollerbymazidi 131215070701-phpapp02
 
Applications of microcontroller(8051)
Applications of microcontroller(8051) Applications of microcontroller(8051)
Applications of microcontroller(8051)
 
WINSEM2023-24_BECE204L_TH_VL2023240505625_2024-01-29_Reference-Material-I.pptx
WINSEM2023-24_BECE204L_TH_VL2023240505625_2024-01-29_Reference-Material-I.pptxWINSEM2023-24_BECE204L_TH_VL2023240505625_2024-01-29_Reference-Material-I.pptx
WINSEM2023-24_BECE204L_TH_VL2023240505625_2024-01-29_Reference-Material-I.pptx
 
8051 FINIAL
8051 FINIAL8051 FINIAL
8051 FINIAL
 
1203 Ppi 8155
1203 Ppi 81551203 Ppi 8155
1203 Ppi 8155
 
Microprocessor Week 9: Timer and Counter
Microprocessor Week 9: Timer and CounterMicroprocessor Week 9: Timer and Counter
Microprocessor Week 9: Timer and Counter
 
Solution manual 8051 microcontroller by mazidi
Solution manual 8051 microcontroller by mazidiSolution manual 8051 microcontroller by mazidi
Solution manual 8051 microcontroller by mazidi
 
Analog to digital converter
Analog to digital converterAnalog to digital converter
Analog to digital converter
 
I o ports and timers of 8051
I o ports and timers of 8051I o ports and timers of 8051
I o ports and timers of 8051
 
STL PN-DP Slave Com Log
STL PN-DP Slave Com LogSTL PN-DP Slave Com Log
STL PN-DP Slave Com Log
 
UNIT-5.ppt
UNIT-5.pptUNIT-5.ppt
UNIT-5.ppt
 
Controlling Motors for Robot
Controlling Motors for RobotControlling Motors for Robot
Controlling Motors for Robot
 
Class9
Class9Class9
Class9
 
12 mt06ped007
12 mt06ped007 12 mt06ped007
12 mt06ped007
 
8051 ch9
8051 ch98051 ch9
8051 ch9
 
Setting pabx LG GHX
Setting pabx LG GHXSetting pabx LG GHX
Setting pabx LG GHX
 
Lab 9 D-Flip Flops: Shift Register and Sequence Counter
Lab 9 D-Flip Flops: Shift Register and Sequence CounterLab 9 D-Flip Flops: Shift Register and Sequence Counter
Lab 9 D-Flip Flops: Shift Register and Sequence Counter
 
Lec12
Lec12Lec12
Lec12
 

Recently uploaded

Artificial-Intelligence-in-Electronics (K).pptx
Artificial-Intelligence-in-Electronics (K).pptxArtificial-Intelligence-in-Electronics (K).pptx
Artificial-Intelligence-in-Electronics (K).pptxbritheesh05
 
HARMONY IN THE HUMAN BEING - Unit-II UHV-2
HARMONY IN THE HUMAN BEING - Unit-II UHV-2HARMONY IN THE HUMAN BEING - Unit-II UHV-2
HARMONY IN THE HUMAN BEING - Unit-II UHV-2RajaP95
 
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...Dr.Costas Sachpazis
 
Application of Residue Theorem to evaluate real integrations.pptx
Application of Residue Theorem to evaluate real integrations.pptxApplication of Residue Theorem to evaluate real integrations.pptx
Application of Residue Theorem to evaluate real integrations.pptx959SahilShah
 
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escortsranjana rawat
 
Past, Present and Future of Generative AI
Past, Present and Future of Generative AIPast, Present and Future of Generative AI
Past, Present and Future of Generative AIabhishek36461
 
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICSAPPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICSKurinjimalarL3
 
CCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdf
CCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdfCCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdf
CCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdfAsst.prof M.Gokilavani
 
Call Girls Delhi {Jodhpur} 9711199012 high profile service
Call Girls Delhi {Jodhpur} 9711199012 high profile serviceCall Girls Delhi {Jodhpur} 9711199012 high profile service
Call Girls Delhi {Jodhpur} 9711199012 high profile servicerehmti665
 
Software and Systems Engineering Standards: Verification and Validation of Sy...
Software and Systems Engineering Standards: Verification and Validation of Sy...Software and Systems Engineering Standards: Verification and Validation of Sy...
Software and Systems Engineering Standards: Verification and Validation of Sy...VICTOR MAESTRE RAMIREZ
 
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur EscortsHigh Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur EscortsCall Girls in Nagpur High Profile
 
main PPT.pptx of girls hostel security using rfid
main PPT.pptx of girls hostel security using rfidmain PPT.pptx of girls hostel security using rfid
main PPT.pptx of girls hostel security using rfidNikhilNagaraju
 
CCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdf
CCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdfCCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdf
CCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdfAsst.prof M.Gokilavani
 
IVE Industry Focused Event - Defence Sector 2024
IVE Industry Focused Event - Defence Sector 2024IVE Industry Focused Event - Defence Sector 2024
IVE Industry Focused Event - Defence Sector 2024Mark Billinghurst
 
power system scada applications and uses
power system scada applications and usespower system scada applications and uses
power system scada applications and usesDevarapalliHaritha
 
Sachpazis Costas: Geotechnical Engineering: A student's Perspective Introduction
Sachpazis Costas: Geotechnical Engineering: A student's Perspective IntroductionSachpazis Costas: Geotechnical Engineering: A student's Perspective Introduction
Sachpazis Costas: Geotechnical Engineering: A student's Perspective IntroductionDr.Costas Sachpazis
 
Internship report on mechanical engineering
Internship report on mechanical engineeringInternship report on mechanical engineering
Internship report on mechanical engineeringmalavadedarshan25
 
What are the advantages and disadvantages of membrane structures.pptx
What are the advantages and disadvantages of membrane structures.pptxWhat are the advantages and disadvantages of membrane structures.pptx
What are the advantages and disadvantages of membrane structures.pptxwendy cai
 
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptxDecoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptxJoão Esperancinha
 

Recently uploaded (20)

Artificial-Intelligence-in-Electronics (K).pptx
Artificial-Intelligence-in-Electronics (K).pptxArtificial-Intelligence-in-Electronics (K).pptx
Artificial-Intelligence-in-Electronics (K).pptx
 
HARMONY IN THE HUMAN BEING - Unit-II UHV-2
HARMONY IN THE HUMAN BEING - Unit-II UHV-2HARMONY IN THE HUMAN BEING - Unit-II UHV-2
HARMONY IN THE HUMAN BEING - Unit-II UHV-2
 
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
 
Application of Residue Theorem to evaluate real integrations.pptx
Application of Residue Theorem to evaluate real integrations.pptxApplication of Residue Theorem to evaluate real integrations.pptx
Application of Residue Theorem to evaluate real integrations.pptx
 
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
 
Past, Present and Future of Generative AI
Past, Present and Future of Generative AIPast, Present and Future of Generative AI
Past, Present and Future of Generative AI
 
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICSAPPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
 
CCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdf
CCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdfCCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdf
CCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdf
 
Call Girls Delhi {Jodhpur} 9711199012 high profile service
Call Girls Delhi {Jodhpur} 9711199012 high profile serviceCall Girls Delhi {Jodhpur} 9711199012 high profile service
Call Girls Delhi {Jodhpur} 9711199012 high profile service
 
Software and Systems Engineering Standards: Verification and Validation of Sy...
Software and Systems Engineering Standards: Verification and Validation of Sy...Software and Systems Engineering Standards: Verification and Validation of Sy...
Software and Systems Engineering Standards: Verification and Validation of Sy...
 
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur EscortsHigh Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
 
main PPT.pptx of girls hostel security using rfid
main PPT.pptx of girls hostel security using rfidmain PPT.pptx of girls hostel security using rfid
main PPT.pptx of girls hostel security using rfid
 
Call Us -/9953056974- Call Girls In Vikaspuri-/- Delhi NCR
Call Us -/9953056974- Call Girls In Vikaspuri-/- Delhi NCRCall Us -/9953056974- Call Girls In Vikaspuri-/- Delhi NCR
Call Us -/9953056974- Call Girls In Vikaspuri-/- Delhi NCR
 
CCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdf
CCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdfCCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdf
CCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdf
 
IVE Industry Focused Event - Defence Sector 2024
IVE Industry Focused Event - Defence Sector 2024IVE Industry Focused Event - Defence Sector 2024
IVE Industry Focused Event - Defence Sector 2024
 
power system scada applications and uses
power system scada applications and usespower system scada applications and uses
power system scada applications and uses
 
Sachpazis Costas: Geotechnical Engineering: A student's Perspective Introduction
Sachpazis Costas: Geotechnical Engineering: A student's Perspective IntroductionSachpazis Costas: Geotechnical Engineering: A student's Perspective Introduction
Sachpazis Costas: Geotechnical Engineering: A student's Perspective Introduction
 
Internship report on mechanical engineering
Internship report on mechanical engineeringInternship report on mechanical engineering
Internship report on mechanical engineering
 
What are the advantages and disadvantages of membrane structures.pptx
What are the advantages and disadvantages of membrane structures.pptxWhat are the advantages and disadvantages of membrane structures.pptx
What are the advantages and disadvantages of membrane structures.pptx
 
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptxDecoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
 

Code 8051

  • 1. ORG 00H // origin MOV DPTR,#LUT // moves the address of LUT to DPTR MOV P1,#00000000B // sets P1 as output port MOV P0,#00000000B // sets P0 as output port CLR P3.0 // sets P3.0 as output for sending trigger SETB P3.1 // sets P3.1 as input for receiving echo MOV TMOD,#00100000B // sets timer1 as mode 2 auto reload timer MAIN: MOV TL1,#207D // loads the initial value to start counting from MOV TH1,#207D // loads the reload value MOV A,#00000000B // clears accumulator SETB P3.0 // starts the trigger pulse ACALL DELAY1 // gives 10uS width for the trigger pulse CLR P3.0 // ends the trigger pulse HERE: JNB P3.1,HERE // loops here until echo is received BACK: SETB TR1 // starts the timer1 HERE1: JNB TF1,HERE1 // loops here until timer overflows (ie;48 count) CLR TR1 // stops the timer CLR TF1 // clears timer flag 1 INC A // increments A for every timer1 overflow
  • 2. JB P3.1,BACK // jumps to BACK if echo is still available MOV R4,A // saves the value of A to R4 ACALL DLOOP // calls the display loop SJMP MAIN // jumps to MAIN loop DELAY1: MOV R6,#2D // 10uS delay LABEL1: DJNZ R6,LABEL1 RET DLOOP: MOV R5,#100D // loads R5 with 100D BACK1: MOV A,R4 // loads the value in R4 to A MOV B,#100D // loads B with 100D DIV AB // isolates the first digit SETB P1.0 // activates LED display unit D1 ACALL DISPLAY // calls DISPLAY subroutine MOV P0,A // moves digit drive pattern for 1st digit to P0 ACALL DELAY // 1mS delay ACALL DELAY MOV A,B // moves the remainder of 1st division to A
  • 3. MOV B,#10D // loads B with 10D DIV AB // isolates the second digit CLR P1.0 // deactivates LED display unit D1 SETB P1.1 // activates LED display unit D2 ACALL DISPLAY MOV P0,A // moves digit drive pattern for 2nd digit to P0 ACALL DELAY ACALL DELAY MOV A,B // moves the remainder of 2nd division to A CLR P1.1 // deactivates LED display unit D2 SETB P1.2 // activates LED display unit D3 ACALL DISPLAY MOV P0,A // moves the digit drive pattern for 3rd digit to P0 ACALL DELAY ACALL DELAY CLR P1.2 // deactivates LED display unit D3 DJNZ R5,BACK1 // repeats the display loop 100 times RET
  • 4. DELAY: MOV R7,#250D // 1mS delay LABEL2: DJNZ R7,LABEL2 RET DISPLAY: MOVC A,@A+DPTR // gets the digit drive pattern for the content in A CPL A // complements the digit drive pattern (see Note 1) RET LUT: DB 3FH // look up table (LUT) starts here DB 06H DB 5BH DB 4FH DB 66H DB 6DH DB 7DH DB 07H DB 7FH DB 6FH END