新聞中心

EEPW首頁(yè) > 嵌入式系統(tǒng) > 設(shè)計(jì)應(yīng)用 > DS18b20同PIC單片機(jī)通訊源程序

DS18b20同PIC單片機(jī)通訊源程序

作者: 時(shí)間:2014-01-09 來(lái)源:網(wǎng)絡(luò) 收藏
ORGPIC54
GOTOMAIN
ORG0
;----------------------
;----------------------------
DELAY22
MOVLWD'200';DELAY2*250=500mS
MOVWFCOUNT1
DE32MOVLWD'250';8*250=2mS
MOVWFCOUNT2
DE42NOP;1+2+1=5uS
DECFSZCOUNT2,1
GOTODE42
DECFSZCOUNT1,1
GOTODE32
RETLW0
;--------------------------------
;子程序!!!
;********************************
MAIN
MOVLW0FFH
TRISRA
LOOP
CALLCONVERT
CALLDELAY22
CALLDELAY22
CALLGET_TEMP

GOTOLOOP
;------------------------
GET_TEMP
CALLINI
MOVLW0CCH
MOVWFCOMD
CALLWR1820
MOVLW0BEH
MOVWFCOMD
CALLWR1820
CALLRE1820
MOVFTEM_DATE,W
MOVWFTEM_DATEL
CALLRE1820
MOVFTEM_DATE,W
MOVWFTEM_DATEH
RETLW0
;------------------------
CONVERT
CALLINI
MOVLW0CCH
MOVWFCOMD
CALLWR1820
MOVLW44H
MOVWFCOMD
CALLWR1820
RETLW0

;---------DS1820---------
INI
;MOVLWB'00100000'
MOVLW0
TRISRA
BSFRA,3
NOP
BCFRA,3
MOVLWD'200'
MOVWFCOUNT1
L0
DECFSZCOUNT1,1
GOTOL0
;MOVLWB'01100000'
MOVLW0FH
TRISRA
MOVLWD'30'
MOVWFCOUNT1
L1
DECFSZCOUNT1,1
GOTOL1
BTFSCRA,3
GOTOINI
L2
MOVLWD'80'
MOVWFCOUNT1
L3
DECFSZCOUNT1,1
GOTOL3
BTFSSRA,3
GOTOL0
RETLW0
;-------------------------
WR1820
MOVLW8
MOVWFCOUNT2
WR0
;MOVLWB'00100000'
MOVLW0
TRISRA
BCFRA,3
NOP
NOP
MOVLW2
MOVWFCOUNT1
WR1
DECFSZCOUNT1,1
GOTOWR1
;MOVLWB'01111111'
MOVLW0FH
BTFSCCOMD,0
BSFRA,3
BTFSCCOMD,0
TRISRA
BCFSTATUS,C
RRFCOMD,1
MOVLWD'20'
MOVWFCOUNT1
WR2
DECFSZCOUNT1,1
GOTOWR2
BSFRA,3
;MOVLWB'01100000'
MOVLW0FH
TRISRA
DECFSZCOUNT2,1
GOTOWR0
RETLW0
;--------------------------
RE1820
MOVLW8
MOVWFCOUNT2
RE0
;MOVLWB'00100000'
MOVLW0
TRISRA
BCFRA,3
MOVLW2
MOVWFCOUNT1
RE1
DECFSZCOUNT1,1
GOTORE1
;MOVLWB'01100000'
MOVLW0FH
TRISRA
NOP
BTFSSRA,3
BCFSTATUS,C
BTFSCRA,3
BSFSTATUS,C
RRFTEM_DATE,1
MOVLWD'20'
MOVWFCOUNT1
RE2
DECFSZCOUNT1,1
GOTORE2
DECFSZCOUNT2,1
GOTORE0
BSFRA,3
RETLW0
;-------------------------
;****************************
;**************************
END

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


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


單片機(jī)相關(guān)文章:單片機(jī)工作原理


通信相關(guān)文章:通信原理




評(píng)論


相關(guān)推薦

技術(shù)專區(qū)

關(guān)閉