Har fått igång den interna klocka iaf, för om jag sätter config bitarna så att ben 3 blir clk out så kan jag mäta 1 MHz där. om jag inte sättder dom så får jag inga ut, bra början

Visst ska den bara matas med ström på ben 1 och 4 ( vdd och mclr) och jord på vss? har ställt att mclr ska vara external i config bitarna, antar att det ska vara så. I princip det första jag gör i koden är att dra ett ben högt så att jag tänder en LED men inte ens det funkar

EDIT; WDT är av.
; LÄSA IBUTTON MED PIC
; *******************************************;
; List your processor here.
processor 12F629
; Include the processor header file here.
#include <p12F629.inc>
; SKRIVET FÖR 4MhZ
;---------------------------------------------------------
; Assign the TRISIO and Constants
constant DQ=0 ; Use GPIO 0, BEN 7 ALLTSÅ TILL 1-WIRE
constant LED=1 ; För att tända leden i läsaren tänds ca 10 sekunder vid ok
constant TOGGLA=2 ; Togglar en bit vid ok nyckel
constant DRA=4 ; drar en bit tills mclr
constant TESTLED=5 ; Drar en bit ca 10 sekunder
constant READROM=0x0F
;---------------------------------------------------------
; These constants are used throughout the code
cblock 0x20
IOBYTE
TMP0 ; Address 0x23
COUNT ; Keep track of bits
PDBYTE ; Presence Detect Pulse
; FLAGGA ; Flaggor för olika ändamål
LOOP1
LOOP2
endc
; #define OK FLAGGA,0
; Set the program origin for subsequent code.
org 0x00
GOTO SETUP
NOP
NOP
NOP
GOTO INTERRUPT ; PC 0x04...INTERRUPT VECTOR!
;---------------------------------------------------------
INTERRUPT
SLEEP
;---------------------------------------------------------
SETUP
BSF STATUS,RP0 ; Select Bank 1 of data memory
MOVLW 0xD7
MOVWF OPTION_REG
CALL 3FFh
MOVWF OSCCAL
; BCF STATUS,RP0 ; Select Bank 0 of data memory
;---------------------------------------------------------
BCF INTCON,7 ; STÄNGER AV INTERRUPT
;---------------------------------------------------------
BCF TRISIO,LED ;SÄTTER IN OCH UTGÅNGAR
BCF TRISIO,TOGGLA
BCF TRISIO,DRA
BCF TRISIO,TESTLED
BCF GPIO,LED ; SÄTTER LÅGT VID START // NÖDVÄNDIGT?
BCF GPIO,TOGGLA
BCF GPIO,DRA
BSF GPIO,TESTLED ; sätter hög detta är en felsöknings sak GOTO START
; *******************************************************
; Dallas Semiconductor 1-Wire MACROS
; *******************************************************
OW_HIZ MACRO
BSF STATUS,RP0 ; Select Bank 1 of data memory
BSF TRISIO, DQ ; Make DQ pin High Z /Ingång
BCF STATUS,RP0 ; Select Bank 0 of data memory
ENDM
; --------------------------------------------------------
OW_LO MACRO
BCF STATUS,RP0 ; Select Bank 0 of data memory
BCF GPIO, DQ ; Clear the DQ bit /Sätt pinne låg
BSF STATUS,RP0 ; Select Bank 1 of data memory
BCF TRISIO, DQ ; Make DQ pin an output
BCF STATUS,RP0 ; Select Bank 0 of data memory
ENDM
; --------------------------------------------------------
WAIT MACRO TIME
;Delay for TIME u s.
;Variable time must be in multiples of 5u s.
MOVLW (TIME/5)-1 ;1u s
MOVWF TMP0 ;1u s
CALL WAIT5U ;2u s
ENDM
; *******************************************************
; Dallas Semiconductor 1-Wire ROUTINES
; *******************************************************
WAIT5U
;This takes 5uS to complete
NOP ;1u s
NOP ;1u s
DECFSZ TMP0,F ;1u s or 2u s
GOTO WAIT5U ;2u s
RETLW 0 ;2u s
; --------------------------------------------------------
WAITLONG MACRO ; VÄNTA TIO SEKUNDER, NU GÅR DET INTE ATT GÖRA NÅGOT ANNAT
MOVLW H'27'
MOVWF LOOP2
STOR
DECFSZ LOOP2
GOTO HOPPA
GOTO SLUT
HOPPA
MOVLW H'FF'
MOVWF LOOP1
LITEN
WAIT .1000
DECFSZ LOOP1
GOTO LITEN
GOTO STOR
SLUT
ENDM
;-------------------------------------------------------
OW_RESET
OW_HIZ ; Start with the line high
CLRF PDBYTE ; Clear the PD byte
OW_LO
WAIT .500 ; Drive Low for 500u s
OW_HIZ
WAIT .70 ; Release line and wait 70u s for PD Pulse
BTFSS GPIO,DQ ; Read for a PD Pulse
INCF PDBYTE,F ; Set PDBYTE to 1 if get a PD Pulse?App Note 2420: 1-Wire Communication with a Microchip PICmicro Microcontroller
WAIT .400 ; Wait 400u s after PD Pulse
RETLW 0
; --------------------------------------------------------
DSRXBYTE ; Byte read is stored in IOBYTE
MOVLW .8
MOVWF COUNT ; Set COUNT equal to 8 to count the bits
DSRXLP ; KÖR PÅ TILLS VI HAR EN BYTE
OW_LO
NOP
NOP
NOP
NOP
NOP
NOP ; Bring DQ low for 6u s
OW_HIZ
NOP
NOP
NOP
NOP ; Change to HiZ and Wait 4u s
MOVF GPIO,W ; Read DQ
ANDLW 1<<DQ ; Mask off the DQ bit
ADDLW .255 ; C=1 if DQ=1: C=0 if DQ=0
RRF IOBYTE,F ; Shift C into IOBYTE
WAIT .50 ; Wait 50u s to end of time slot
DECFSZ COUNT,F ; Decrement the bit counter
GOTO DSRXLP
RETLW 0
; --------------------------------------------------------
DSTXBYTE ; Byte to send starts in W
MOVWF IOBYTE ; We send it from IOBYTE
MOVLW .8
MOVWF COUNT ; Set COUNT equal to 8 to count the bits
DSTXLP ; SÄNDER ALLA 8 BITARNA
OW_LO
NOP
NOP
NOP
NOP
NOP ; Drive the line low for 5u s
RRF IOBYTE,F ; The data byte
BTFSC STATUS,C ; Check the LSB of IOBYTE for 1 or 0
BSF GPIO,DQ ; Drive the line high if LSB is 1
WAIT .60 ; Continue driving line for 60u s
OW_HIZ ; Release the line for pullup
NOP
NOP ; Recovery time of 2u s
DECFSZ COUNT,F ; Decrement the bit counter
GOTO DSTXLP
RETLW 0
;---------------------------------------------------------
START
;---------------------------------------------------------
GET_SERIAL
CALL OW_RESET ; Send Reset Pulse and read for Presence Detect Pulse
BTFSS PDBYTE,0 ; 1 = Presence Detect Detected
GOTO START
BCF GPIO,TESTLED ; SLÄCKER DEN FÖR ATT VETA NÄR VI HAR HITTAT EN IBUTTON
MOVLW 0xA0 ;initialize pointer
MOVWF FSR ;to RAM
MOVLW READROM
CALL DSTXBYTE ; Send Read ROM Command (0x0F)
NEXT
CALL DSRXBYTE
MOVF IOBYTE,W
MOVWF INDF
INCF FSR ;inc pointer
BTFSS FSR,3
GOTO NEXT
CALL OW_RESET
; Nu ska serialen kollas,
MOVLW 0xA0 ;initialize pointer
MOVWF FSR ;to RAM
SUBLW H'CC' ; FAMILY CODE
BTFSS STATUS,Z
GOTO FEL_NYCKEL
INCF FSR
SUBLW H'00' ; SERIAL
BTFSS STATUS,Z
GOTO FEL_NYCKEL
INCF FSR
SUBLW H'00' ;SERIAL
BTFSS STATUS,Z
GOTO FEL_NYCKEL
INCF FSR
SUBLW H'0A' ;SERIAL
BTFSS STATUS,Z
GOTO FEL_NYCKEL
INCF FSR
SUBLW H'0C' ;SERIAL
BTFSS STATUS,Z
GOTO FEL_NYCKEL
INCF FSR
SUBLW H'8B' ;SERIAL
BTFSS STATUS,Z
GOTO FEL_NYCKEL
INCF FSR
SUBLW H'A2' ;SERIAL
BTFSS STATUS,Z
GOTO FEL_NYCKEL
INCF FSR
SUBLW H'01' ;CRC
BTFSS STATUS,Z
GOTO FEL_NYCKEL
GOTO NYCKEL_OK
NYCKEL_OK
BSF GPIO,DRA
BTFSS GPIO,TOGGLA ; TOGGLA BEN 5 VID OK NYCKEL
BSF GPIO,TOGGLA
BCF GPIO,TOGGLA
BSF GPIO,LED
WAITLONG ; väntar ca 10 sekudner
BCF GPIO,LED
GOTO START
FEL_NYCKEL
GOTO START
END