微波EDA网,见证研发工程师的成长!
首页 > 硬件设计 > 嵌入式设计 > 单片机超声波传感器测量距离

单片机超声波传感器测量距离

时间:11-18 来源:互联网 点击:

mova,r7

jz dela1

inc r6

dela1: mov r5,#50d

djnz r5, $

djnz r7,dela1

djnz r6,dela1

pop acc

ret

end

NAME DISPLAY

?PR?_DISPLAY?display segment code

?co?_DISPLAY?display segment data

EXTRN CODE (_DELAY)

PUBLIC _DISPLAY

RSEG ?CO?_DISPLAY?DISPLAY

?_display?byte:

dispbit: ds 1

dispnum: ds 1

rseg ?pr?_display?display

_display: push acc

push dph

push dpl

push psw

inc dispnum

mov a,dispnum

cjne a,#4d,disp1

DISP1: JC DISP2

MOV DISPNUM,#00H

MOV DISPBIT,#0FEH

DISP2: MOV A,R1

ADD A,DISPNUM

MOV R0,A

MOV A,@R0

MOV DPTR,#DISPTABLE

MOVC A,@A+DPTR

MOV P0,A

MOV A,DISPNUM

CJNE A,#2D,DISP3

CLR P0.7

DISP3: MOV P2,DISPBIT

MOV R5,#00H

MOV R7,#0AH

LCALL _DELAY

MOV P0,#0FFH

MOV P2,#0FFH

MOV A,DISPBIT

RL A

MOV DISPBIT,A

POP PSW

POP DPL

POP DPH

POP ACC

RET

DISPTABLE: DB 0C0H,0F9H,0A4H,0B0H,99H,92H,82H,0F8H,80H,90H,88H,83H,0C6H,0A1H,86H,8EH,0BFH,0FFH

END

Copyright © 2017-2020 微波EDA网 版权所有

网站地图

Top