1-wire read ROM with 12F675


Closed Thread
Results 1 to 3 of 3

Hybrid View

  1. #1
    Join Date
    Oct 2007
    Posts
    2

    Default 1-wire read ROM with 12F675

    Hello,

    I'm trying to get the serial number from a DS18B20 connected to a 12F675 without any success.

    There is a 4.7K between VCC and DQ.

    Here is the data I get as an output:

    Ser# = 000000000000h
    CRC Value = 00h
    Read ROM...
    Read 64-bit device data into the 8-byte array
    Family code00h
    Ser# = 000000000000h
    CRC Value = 00h

    I am sure of the DS18B20 (it is working).

    Here is the code:

    ----------------------------------------------------
    DEFINE OSC 4

    SO CON 0 ' GPIO.0 (Pin7) Serial out
    DQ CON 1 ' GPIO.1 (Pin7) one wire data pin "DQ"
    SEARCH_ROM CON $F0

    ID VAR BYTE[8] ' Array storage variable for 64-bit ROM code

    ANSEL=0
    OUTPUT DQ

    SEROUT2 SO,16468,[13, 10, "1-wire Device Search", 10,13,10,13]

    start:
    SEROUT2 SO,16468,[ "Read ROM...",10,13]
    OWOUT DQ, 1, [$33] ' Issue Read ROM command
    SEROUT2 SO,16468,[ "Read 64-bit device data...",10,13]
    OWIN DQ, 0, [STR ID\8]' Read 64-bit device data into the 8-byte array "ID"
    SEROUT2 SO, 16468,["Family code",HEX2 ID[0],"h", 10, 13]
    SEROUT2 SO, 16468,["Ser# = ",HEX2 ID[1],HEX2 ID[2],HEX2 ID[3],HEX2 ID[4],HEX2 ID[5],HEX2 ID[6],"h", 10,13]
    SEROUT2 SO, 16468,["CRC Value = ",HEX2 ID[7],"h", 10, 13]
    pause 2000
    GOTO start

    END
    ----------------------------------------------------

    Any idea about why it is not working ?

    Thanks,
    Fabien

  2. #2
    Join Date
    Jan 2006
    Location
    Istanbul
    Posts
    1,185


    Did you find this post helpful? Yes | No

    Default

    Put all these at the beginning of your code.

    Code:
    @ DEVICE pic12F675, INTRC_OSC_NOCLKOUT 
    @ DEVICE pic12F675, WDT_ON
    @ DEVICE pic12F675, PWRT_ON
    @ DEVICE pic12F675, MCLR_OFF
    @ DEVICE pic12F675, BOD_OFF
    @ DEVICE pic12F675, CPD_OFF
    @ DEVICE pic12F675, PROTECT_OFF
    
    
    DEFINE OSCCAL_1K    1   ' osc calibration
    
    CMCON = 7               ' Disable comparators.
    VRCON.7 = 0             ' Disable voltage reference module ; no current.
    TRISIO = %000000        ' All output except for GP3.
    ADCON0.0 = 0            ' Turn off ADC module.
    ANSEL = 0               ' Digital I/O.
    "If the Earth were a single state, Istanbul would be its capital." Napoleon Bonaparte

  3. #3
    Join Date
    Oct 2007
    Posts
    2


    Did you find this post helpful? Yes | No

    Default

    I added:

    CMCON = 7 ' Disable comparators.
    VRCON.7 = 0 ' Disable voltage reference module ; no current.
    TRISIO = %000000 ' All output except for GP3.
    ADCON0.0 = 0 ' Turn off ADC module.

    ... and everything is working properly. THANKS !

    Fabien

Similar Threads

  1. My code for TV remote and MIBAM for RGB control
    By idtat in forum Code Examples
    Replies: 4
    Last Post: - 12th January 2013, 20:52
  2. Variable in array
    By Gusse in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 22nd February 2009, 19:46
  3. Serout2/serin2 Pbp Problem
    By SOMRU in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 11th December 2006, 19:55
  4. DS1820 headache
    By Calco in forum mel PIC BASIC Pro
    Replies: 11
    Last Post: - 12th August 2004, 00:28
  5. New member
    By jmgelba in forum mel PIC BASIC Pro
    Replies: 13
    Last Post: - 28th February 2004, 22:44

Members who have read this thread : 1

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts