新聞中心

EEPW首頁(yè) > 嵌入式系統(tǒng) > 設(shè)計(jì)應(yīng)用 > 基于單片機(jī)的超聲波測(cè)距儀LED顯示電路的設(shè)計(jì)

基于單片機(jī)的超聲波測(cè)距儀LED顯示電路的設(shè)計(jì)

作者: 時(shí)間:2010-04-02 來(lái)源:網(wǎng)絡(luò) 收藏

;*** ****距離計(jì)算程序**********

WORK: PUSH ACC

PUSH PSW

PUSH B

MOV PSW,#18H

MOV R3,45H

MOV R2,44H

MOV R1,00D

MOV R0,17D

LCALL MUL2BY2

MOV R3,#03H

MOV R2,0E8H

LCALL DIV4BY2

LCALL DIV4BY2

MOV 40H,R4

MOV A,40H

JNZ JJ0

MOV 40H,#0AH

JJ0: MOV A, R0

MOV R4, A

MOV A, R1

MOV R5, A

MOV R3, 00D

MOV R2, #100D

LCALL DIV4BY2

MOV 41H,R4

MOV A,41H

JNZ JJ1

MOV A,40H

SUBB A,#0AH

JNZ JJ1

MOV 41H,#0AH

JJ1: MOV A,R0

MOV R4,A

MOV A,R1

MOV R5,A

MOV R3,#00D

MOV R2,10D

LCALL DIV4BY2

MOV 42H,R4

JNZ JJ2

MOV A,41H

SUBB A,#0AH

JNZ JJ2

MOV 42H,#0AH

JJ2: MOV 43H,R0

POP B

POP PSW

POP ACC

RET

MUL2BY2:CLR A

MOV R7,A

MOV R6,A

MOV R5,A

MOV R4,A

MOV 46H,#10H

MULLOOP1:CLR C

MOV A,R4

RLC A

MOV R4,A

MOV A,R5

RLC A

MOV R5,A

MOV A,R6

RLC A

MOV R6,A

MOV A,R7

RLC A

MOV R7,A

MOV A,R0

RLC A

MOV R0,A

MOV A,R1

RLC A

MOV R1,A

JNC MULLOOP2

MOV A,R4

ADD A,R2

MOV R4,A

MOV A,R5

ADDC A,R3

MOV R5,A

MOV A,R6

ADDC A,#00H

MOV R6,A

MOV A,R7

ADDC A,#00H

MOV R7,A

MULLOOP2:DJNZ 46H,MULLOOP1

RET

DIV4BY2:MOV 46H,#20H

MOV R0,#00H

MOV R1,#00H

DIVLOOP1:MOV A,R4

RLC A

MOV R4,A

MOV A,R5

RLC A

MOV R5,A

MOV A,R6

RLC A

MOV R6,A

MOV A,R7

RLC A

MOV R7,A

MOV A,R0

RLC A

MOV R0,A

MOV A,R1

RLC A

MOV R1,A

CLR C

MOV A,R0

SUBB A,R3

JC DIVLOOP2

MOV R0,B

MOV R1,A

DIVLOOP2:CPL C

DJNZ 46H,DIVLOOP1

MOV A,R4

RLC A

MOV R4,A

MOV A,R5

RLC A

MOV R5,A

MOV A,R6

RLC A

MOV R6,A

MOV A,R7

RLC A

MOV R7,A

RET

END PIXTEL_MMI_EBOOK_2005>9 /PIXTEL_MMI_EBOOK_2005>

51單片機(jī)相關(guān)文章:51單片機(jī)教程


晶振相關(guān)文章:晶振原理

上一頁(yè) 1 2 3 4 下一頁(yè)

評(píng)論


相關(guān)推薦

技術(shù)專(zhuān)區(qū)

關(guān)閉