Ty Mike. I've tried to use the corect code sequence and I get the same result. There is my sequence :
list p=16F628A, r=DEC ; Use the PIC16F628 and decimal system
#include <p16f628a.inc> ; Include header file
errorlevel -302 ; Suppress "Register not in bank 0." message
__config _INTOSC_OSC_NOCLKOUT & _LVP_OFF & _WDT_OFF & _PWRTE_ON & _BODEN_ON
;---------------------------------------------------------
; Macros
;---------------------------------------------------------
BANK0:macro ; Select bank 0
bcf STATUS,RP0
bcf STATUS,RP1
endm
BANK1:macro ; Select bank 1
bsf STATUS,RP0
bcf STATUS,RP1
endm
;---------------------------------------------------------
; Select PORTB pin number for 1-Wire
;---------------------------------------------------------
constant DQ=0 ; Use RB0 for TMP
;--------------------------------------------------------
; These constants are standard 1-Wire ROM commands
;---------------------------------------------------------
constant SRCHROM=0xF0
constant RDROM=0x33
constant MTCHROM=0x55
constant SKPROM=0xCC
constant CONV=0x44
constant RDPAD=0xBE
;---------------------------------------------------------
; Constants used in code for 1-Wire, RS232 and Delay
;---------------------------------------------------------
cblock 0x20
IOBYTE
TMP0 ; Address 0x23
COUNT ; Keep track of bits
PDBYTE ; Presence Detect Pulse
TP ; Used for Delay routine
TP1 ; Used for Delay routine
TP2 ; Used for Delay routine
DATAL ; RS232 data
endc
org 0x000 ; Program starts at 0x000
movlw 7
movwf CMCON ; Set comperators off
;---------------------------------------------------------
; Initialize ports
;---------------------------------------------------------
movlw B'00000100' ; Set up port A (RA2 is output)
movwf PORTA
movlw B'00000100' ; RB2(TX)=1 others are 0
movwf PORTB
BANK1 ; Select Bank 1 of data memory
movlw B'11110010' ; RB7-RB4 and RB1(RX)=input, others output
movwf TRISB
;---------------------------------------------------------
; Set baud rate to communicate with PC
;---------------------------------------------------------
; Boot Baud Rate = 9600, No Parity, 1 Stop Bit
movlw 0x19 ; 0x19=9600 bps (0x0C=19200 bps)
movwf SPBRG
movlw B'00100100' ; BRGH = 1
movwf TXSTA ; Enable asynchron transmission, set BRGH
BANK0 ; Select Bank 0 of data memory
movlw B'10010000' ; Enable Asynchron reception
movwf RCSTA
;---------------------------------------------------------
; Provide a settling time for start up
;---------------------------------------------------------
clrf DATAL
SETTLE
decfsz DATAL,F
goto SETTLE
movf RCREG,W
movf RCREG,W
movf RCREG,W ; Flush receive buffer
;---------------------------------------------------------
; 1-Wire initializations
;---------------------------------------------------------
BANK1 ; Select Bank 1 of data memory
movlw 0xD7
movwf OPTION_REG
BANK0 ; Select Bank 0 of data memory
bcf INTCON,7 ; Enable all un-masked peripheral interrupts
; ---------
; MAIN LOOP
; ---------
LOOP
call START_TMP ; Call 1 wire routine
goto LOOP ; Once again
;---------------------------------------------------------
; SEND CHARACTER IN W VIA RS232 AND WAIT UNTIL FINISHED SENDING
;---------------------------------------------------------
SEND_232
movwf TXREG ; Put data in W
SEND_WAIT
BANK1 ; Select Bank 1 of data memory
WAIT_HERE
btfss TXSTA,TRMT ; Transmission is complete if 1
goto WAIT_HERE
BANK0 ; Select Bank 0 of data memory
return
;---------------------------------------------------------
; 1-Wire
;---------------------------------------------------------
#include <1-wire.inc>
;---------------------------------------------------------
START_TMP
call OW_RESET ; Reset
movlw SKPROM
call DSTXBYTE ; Send 'Skip ROM' command (0xCC)
movlw CONV
call DSTXBYTE ; Send 'Convert T' command (0x44)
call Delay ; Wait for conversion
call OW_RESET ; Reset
movlw SKPROM
call DSTXBYTE ; Send 'Skip ROM' command (0xCC)
movlw RDPAD
call DSTXBYTE ; Send 'Read Scratchpad' command (0xBE)
call DSRXBYTE ; Read Current Register MSB
movf IOBYTE,W ; The contents of IOBYTE goes to W
call SEND_232 ; Send the content of W to RS232
call DSRXBYTE ; Read Current Register LSB
movf IOBYTE,W ; The contents of IOBYTE goes to W
call SEND_232 ; Send the content of W to RS232
return
;---------------------------------------------------------
; Delay Routine
;---------------------------------------------------------
Delay
movlw 0X10
movwf TP
L2 movlw 0XFF
movwf TP1
L3 movlw 0XFF
movwf TP2
L4 decfsz TP2,F
goto L4
decfsz TP1,F
goto L3
decfsz TP,F
goto L2
return
END
Is there a problem that I conected DQ via RB0/INT pin? Otherwise I don't see where is the "bug".