使用PIC读写1-wire EEPROM DS2430的实例
--------------------------------------------------------- TxHi: ;;--------------------------------------------------------------------------- SetL ;--------------------------- banksel PIR1
TxL
call SetLo
call delay60us ; min 60 us
call SetHi
nop ; recovery time min 1us
nop
return
;-----------------------------------------------------------
; tx hi
;-----------------------------------------------------------
call SetLo ;1ustlow115us
nop
call SetHi
call delay60us
nop
nop ;recovery time min 1us
return
;; toggle the RC0 as input and the bus was pulled up by externl resistor
;; application default PCDir.Bit0 to output
;;---------------------------------------------------------------------------
SetHi:
bsf PBDir,Bit2
movf PBDir,w
; bsf bank1
banksel TRISB
movwf TRISB
return
;;----------------------------------------------------------------------------
;; clear register file RC0
;;----------------------------------------------------------------------------
banksel PORTB
bcf PORTB,Bit2 ; data lo
bcf PBDir,Bit2 ; direction out
movf PBDir,W
banksel TRISB
movwf TRISB
return
;---------------------------
; fix delay 60 us
; 0xffff - 8 = 0xfff7
;---------------------------
delay60us
banksel PIR1
bcf PIR1,TMR1IF
movlw H'EE'
movwf TMR1L
movlw H'FF'
movwf TMR1H
bsf T1CON,TMR1ON
btfss PIR1,TMR1IF
goto $-1
bcf T1CON,TMR1ON
bcf PIR1,TMR1IF
return
; fix delay 500 us
; 0xffff - 0x3e = 0xffc1
;---------------------------
delay500us
bcf PIR1,TMR1IF
movlw H'C0'
movwf TMR1L
movlw H'FF'
movwf TMR1H
bsf T1CON,TMR1ON
btfss PIR1,TMR1IF
goto $-1
bcf T1CON,TMR1ON
bcf PIR1,TMR1IF
return
;---------------------------
; fix delay 100 ms
; 0xffff - 30d4 = 0xcf26
;---------------------------
delay100ms
banksel PIR1
bcf PIR1,TMR1IF
movlw H'26'
movwf TMR1L
movlw H'CF'
movwf TMR1H
bsf T1CON,TMR1ON
btfss PIR1,TMR1IF
goto $-1
bcf T1CON,TMR1ON
bcf PIR1,TMR1IF
return
org H'800'
VendorTable
movf Offset,W ; Save offset in Temp
andlw H'ff'
addwf PCL,f ; PCL = PCL+Offset
dt MiCallChip,0
end
DS2430 实例 EEPROM 1-wire PIC 读写 使用 相关文章:
- 使用PIC读写1-wire EEPROM DS2430的实例程序(08-12)
- 国外现场总线应用实例两则(12-21)
- 三菱PLC编程技巧及实例图解(12-19)
- 单片机的七个创意设计实例(从易到难),附电路图、源代码、演示视频(06-11)
- PCI驱动程序开发实例(02-21)
- 51单片机做信号发生器实例编程(01-16)