电子元器件原材料
采购信息平台

手机洽洽

扫一扫下载客户端
随时随地,生意尽握手中

pic12C508超声波测距仪程序

来源:华强电子网 作者:华仔 浏览:267

标签:

摘要: >;超声波测距仪 ;InternalOsc,WDTEnabLED include loopequ10h dlyCTRequ11h tone_cntequ12h;反射周期计数 periodequ13h;tmr0溢出时间 org0 MOVwfOSCCAL MOVlwb’10001001’ option;1:2WDTON MOVlwb’00001101’ trisGPIO MOVwf0 bcfGPIO,

>;超声波测距仪
;InternalOsc,WDTEnabLED

include

loopequ10h
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
型号 厂商 价格
EPCOS 爱普科斯 /
STM32F103RCT6 ST ¥461.23
STM32F103C8T6 ST ¥84
STM32F103VET6 ST ¥426.57
STM32F103RET6 ST ¥780.82
STM8S003F3P6 ST ¥10.62
STM32F103VCT6 ST ¥275.84
STM32F103CBT6 ST ¥130.66
STM32F030C8T6 ST ¥18.11
N76E003AT20 NUVOTON ¥9.67
型号/产品名 平均报价 涨跌幅
STM8S003F3P6 1.55 1.12%
74HC573D 0.64 2.86%
2N7002 3.66 400.00%
STM32F103C8T6 7.47 27.87%
1N4007 1.58 0.00%
ADM2483BRWZ 8.90 3.21%
SHT10 16.21 5.88%
STM32F103RCT6 12.56 24.44%
78L05 10.55 66.67%
LM358 118206.75 16.67%
发布求购