Searching \ for '[piclist] 1-wire sample code or tips?' in subject line. ()
Make payments with PayPal - it's fast, free and secure! Help us get a faster server
FAQ page: www.piclist.com/techref/microchip/devices.htm?key=pic
Search entire site for: '[piclist] 1-wire sample code or tips?'.

Exact match. Not showing close matches.
PICList Thread
'[piclist] 1-wire sample code or tips?'
1999\04\30@174049 by Lieven

picon face
I'm working on a PIC project that talks to a Dallas 1-wire part.
Unfortunately, I can't seem to get it to talk to me.  Attaching
a scope shows a presence pulse but no response to my (seemingly
properly formed and timed, per my interpretation of the 1-wire
spec) transmission.

I'm surprised to say that neither the Dallas Semiconductor site,
nor the Microchip site, nor anyplace else I've searched on the
web, have any code samples for an iButton or 1-wire interface.

Can anyone point me to a site, or send me an example?  C, assembly,
even pseudocode would be handy so I could confirm that my bit-level
signaling is correct.  My project uses the deluxe 17C7xx series,
but I'm familiar with the lower end processors as well.

Thanks,
Lieven


'[piclist] 1-wire sample code or tips?'
1999\05\01@011714 by roblid
flavicon
face
Have you seen this? Don't know if that'll help
http://www.dalsemi.com/TechBriefs/tb1.html

Regards,

Guy Robinson

1999\05\01@083611 by goflo

flavicon
face
Check your DS1820 pinout -  The part acts as you describe
when power & gnd are reversed. Note that the TO-39 pinout
in the data sheet is a TOP view.

Guess how I figured this out...  :)

Regards, Jack

Lieven wrote:
{Quote hidden}

1999\05\01@094433 by Bob Drzyzgula

flavicon
face
Lieven,

In addition to Dallas' excellent tech brief mentioned by
Guy Robinson, you might check the following sites, both
of which contain information about and/or code samples
for interfacing the 1-wire devices with a PIC.

www.ccc.nottingham.ac.uk/~cczsteve/pic84.html
http://www.phanderson.com/

The following site offers a PC-based 1-wire to serial
port system; the proprietor is PIC-friendly (he offers
Linux-based PIC programming software) and may have some
tips for what you are trying to do as well:

http://www.nexuscomputing.com/

Also, the following app note contains 8051 assembly
source code for driving a 1-wire bus off a serial port,
which would be more helpful if you were using an 8051 :-)
but at least is a code sample from Dallas... It also
contains source in C and Pascal for driving a 1-wire bus
with an 8250-style UART.

http://www.dalsemi.com/DocControl/PDFs/app74.pdf

--Bob

On Fri, Apr 30, 1999 at 02:30:34PM -0700, Lieven wrote:
{Quote hidden}

--
============================================================
Bob Drzyzgula                             It's not a problem
spam_OUTbobTakeThisOuTspamdrzyzgula.org                until something bad happens
============================================================

1999\05\03@020937 by Dr. Imre Bartfai

flavicon
face
part 0 4730 bytes content-type:TEXT/PLAIN; charset=US-ASCII; name="ibutton.src"On Fri, 30 Apr 1999, Lieven wrote:

> I'm working on a PIC project that talks to a Dallas 1-wire part.
> Unfortunately, I can't seem to get it to talk to me.  Attaching
> a scope shows a presence pulse but no response to my (seemingly
> properly formed and timed, per my interpretation of the 1-wire
> spec) transmission.
>
> I'm surprised to say that neither the Dallas Semiconductor site,
> nor the Microchip site, nor anyplace else I've searched on the
> web, have any code samples for an iButton or 1-wire interface.
>
> Can anyone point me to a site, or send me an example?  C, assembly,
> even pseudocode would be handy so I could confirm that my bit-level
> signaling is correct.  My project uses the deluxe 17C7xx series,
> but I'm familiar with the lower end processors as well.
>
> Thanks,
> Lieven
>
>

Content-Type: TEXT/PLAIN; charset=US-ASCII; name="ibutton.src"
Content-ID: <.....Pine.LNX.3.96.990503081050.221BKILLspamspam@spam@prof.pmmf.hu>> Content-Description:

;---------------------------------------------------

; This code fragment handles the Dallas iButton(TM)

;---------------------------------------------------

;

;Line must be equated as a pin

iButOrg        =        $

       Org        iBData

Cnt        DS        1                ; counter

TCnt        DS        1                ; delay counter        

SSave        DS        1                ; STATUS save cell

FamCod        DS        1                ; Family code   \

SerNo        DS        6                ; serial number } do not separate!

CRC        DS        1                ; CRC value        /

Cmd        DS        1                ; command/data cell

Acc        DS        1                ; virtual accumulator

CSave        EQU        SSave.0



iBEnd        EQU        $



       Org        iButOrg

       

iButton Call        _Init                ; reset prom

       Or        W,#0                ; check for zero

       SZ                        ; skip if good

       Ret                        ; otherwise return

       Mov        W,#0Fh                ; Read ROM command

       Call        _SndCmd

       Call        _GetByt                ; receive byte

       Mov        FamCod,Cmd        ; save family code

       Mov        Cnt,#6                ; length of serial number

       Mov        FSR,#SerNo        ; serial number address

:loop        Call        _GetByt                ; Receive SerNo

       Mov        INDF,Cmd        ; received value

       Inc        FSR

       DJNZ        Cnt,:loop

       Call        _GetByt                ; receive CRC

       Mov        FSR,#FamCod

       Mov        Cnt,#7                ; length

       Call        CRC8

;------        now xchg CRC & Cmd

       Mov        W,CRC

       XOr        W,Cmd                ; here change Cmd with W

       XOr        Cmd,W

       XOr        W,Cmd

       Mov        CRC,W

;------

       

       CSE        CRC,Cmd                ; received==calculated

       Retw        2

       Retw        0                ; good



_Init        SetB        RP0                ; select Bank #1

       ClrB        Line                ; turn line to output

       ClrB        RP0                ; Bank #0 again

       ClrB        Line                ; master reset

       Call        _Trst                ; 500 usec delay

       SetB        RP0                ; Bank #1 again

       SetB        Line                ; turn line to input

       ClrB        RP0                ; now Bank #0 again

       Call        _Tpdh                ; recovery

       Clr        Cnt                ; clear counter

:pres        Call        _T12u                ; wait 15 usec

       JB        Line,:eoi        ; if high again, end of init

       Inc        Cnt                ; count length of presence pulse

       CJAE        Cnt,#20,:bad        ; too long: shortcut

       Jmp        :pres

:eoi        CJB        Cnt,#1,:bad

       Retw        0                ; iButton found

:bad        Retw        1                ; iButton not found



_T12u        Mov        W,#3                ; for 1 usec / instruction!

:loop        Add        W,#255

       JNZ        :loop

       Ret



_Tpdh        Mov        TCnt,#2                ; about 30 usec

       Jmp        _Trst:loop



_Trst        Mov        TCnt,#31        ; about 500 usec

:loop        Call        _T12u

       DJNZ        TCnt,:loop

       Ret



_SndCmd        Mov        Cmd,W                ; store command

       Mov        Cnt,#8                ; # of bits

:loop        Rr        Cmd                ; LSB first

       Call        _SendC

       DJNZ        Cnt,:loop

       Ret



_SendC        Mov        SSave,STATUS

       SetB        RP0                ; select Bank #1

       ClrB        Line                ; turn line to output

       ClrB        RP0                ; Bank #0 again

       ClrB        Line                ; low pulse

       Mov        W,#1                ; short pulse

       Call        _T12u:loop        ; tlow1

       JNB        CSave,:Slot

       SetB        RP0                ; Bank #1

       SetB        Line                ; turn to input

       ClrB        RP0

:Slot        Call        _Tpdh                ; sampling window

       Call        _Tpdh                ; sampling window

       JB        CSave,:ret        ; return if 1

       SetB        RP0                ; Bank #1

       SetB        Line                ; turn to input

       ClrB        RP0                ; Bank #0 again

:ret        Ret



_GetByt        Mov        Cmd,#128        ; hibit as exit condition

:loop        SetB        RP0                ; select Bank #1

       ClrB        Line                ; turn line to output

       ClrB        RP0                ; Bank #0 again

       ClrB        Line                ; low pulse

       Mov        W,#1                ; short pulse

       Call        _T12u:loop        ; tlow1

       SetB        RP0                ; Bank #1

       SetB        Line                ; turn to input

       ClrB        RP0                ; Bank #0 again

       Mov        W,#1                ; short pulse

       Call        _T12u:loop        ; tRDV

       MovB        C,Line                ; line state

       Rr        Cmd                ; put received bit

       Mov        SSave,Status        ; save status register

       Mov        TCnt,#4                ; tSLOT

       Call        _Trst:loop        ; time

       JNB        CSave,:loop        ; hibit not reached yet?

       Ret

       

CRC8        Clr        CRC                ; clear initial CRC

:loop        Mov        W,INDF                ; fetch the byte

       Call        CRC8up                ; update CRC

       Inc        FSR                ; next pointer

       DJNZ        Cnt,:loop

       Ret

       

CRC8up        Mov        SSave,W                ; save bits to be shifted

       Mov        TCnt,#8                ; set shift=8bits

       Mov        W,SSave                ;; restore result

:loop        XOr        W,CRC                ; calculate CRC

       Mov        Acc,W                ;; last CRC value

       RR        Acc                ; move it to carry

       JNC        :Zero                ; skip if data=0

       XOr        CRC,#18h        ; update the CRC value

:Zero        RR        CRC                ; position the new CRC

       RR        SSave                ; position the next bit

       Mov        W,SSave                ; use the remaining bits

       DJNZ        TCnt,:loop

       Ret

       

More... (looser matching)
- Last day of these posts
- In 1999 , 2000 only
- Today
- New search...