您现在的位置: 主页 > 嵌入式开发入门到精通 > 单片机技术进阶 > pic12C508超声波测距仪程序 -
本文所属标签:
为本文创立个标签吧:

pic12C508超声波测距仪程序 -

来源: 网络用户发布,如有版权联系网管删除 2018-09-07 

[导读]
;超声波测距仪;InternalOsc,WDTEnabLEDincludeloopequ10h dlyCTRequ11htone_cntequ12h;反射周期计数periodequ13h;tmr0溢出时间org0MOVwfOSCCALMOVlwb’10001001’option;1:2WDTONMOVlwb’00001101’tr

;超声波测距仪
;InternalOsc,WDTEnabLED

include

loopequ10h

本文引用地址: http://www.21ic.com/app/mcu/201807/765581.htm

dlyCTRequ11h
tone_cntequ12h;反射周期计数
periodequ13h;tmr0溢出时间


org0
MOVwfOSCCAL
MOVlwb’10001001’
option;1:2WDTON
MOVlwb’00001101’
trisGPIO
MOVwf0
bcfGPIO,1;输出脉冲

;===================================
mainclrwdt
btfssGPIO,0;等待触发信号
gotomain
m2clrwdt
btfscGPIO,0
gotom2

callburst;发送超声波
bsfGPIO,1;开始输出定时脉冲
m1btfscGPIO,2
gotom1
bcfGPIO,1;结束输出定时脉冲
gotomain

;===================================
burstclrfloop
MOVlw8
MOVwfloop

burst1MOVlwb’00010000’
MOVwfGPIO

MOVlw3
MOVwfdlyctr
burst2decfszdlyctr,f
gotoburst2;12uS

MOVlwb’00010100’
MOVwfGPIO
MOVlw2;(2*3inst*1uS)-1uS=5uS
MOVwfdlyctr;5uS+(8*1uS)=13uS
burst3decfszdlyctr,f
gotoburst3

nop
decfszloop,f
gotoburst1
MOVlw0x00
MOVwfGPIO
retlw0

;================================
toneclrfTMR0
t1btfscGPIO,2
gotot1
MOVfwTMR0
clrfTMR0
MOVwfperiod

MOVlw21;if(period>22&&period<30)
subwfperiod,w
btfssSTATUS,C
gotot2
MOVlw30
subwfperiod,f
btfscSTATUS,C
gotot2
decfsztone_cnt,f;25uSperiodOK,so
gotot1;ifnotyet3ofthem,keeplooking
retlw0;else-success-return

t2MOVlw3
MOVwftone_cnt
gotot1

;=====================================
end




              查看评论 回复

游客   2018-10-08 23:10:21
空格都没有了,不够我还是可以看个大概
1楼 回复本楼


 

"pic12C508超声波测距仪程序 -"的相关文章

网站地图

围观()