'**************************************************************** '* Name : Temp.BAS * '* Author : Bruce Reynolds modified By Dwight Merkley * '* Notice : * '* : * '* Date : 7/28/2003 * '* Version : 1.0 * '* Notes : PIC16f690 * '* : * '**************************************************************** Reset: TrisA = %00011000 'Port A3,A5 inupts rest outputs (A3 cannot output) TrisB = %00000000 'Port B all outputs TrisC = %00000000 'Port C all outputs ansel = 0 'and turn off analog AnselH = 0 'turn of rest of analogs CM1CON0 = 0 'turn off comparators CM2CON0 = 0 'turn off comparators SSPCON.bit5 = 0 ' disable serial port, pins are I/O OPTION_REG = %10000000 '1 turn off weak pull ups INTCON = %00000000 '=========================================== 'Comm_Pin VAR PortA.4 ' One-wire Data-Pin "DQ" on PortA.4 DQ var PortA.4 ' Busy VAR BIT ' Busy Status-Bit ID VAR BYTE[8] ' Array storage variable for 64-bit ROM code DEFINE DEBUG_REGG PORTA 'set debug port to porta DEFINE DEBUG_BIT 0 'use pin a0 of porta for debug DEFINE DEBUG_BAUD 2400 'set baud rate to 2400 DEFINE DEBUG_MODE 0 'communicate in true mode '===================================================================== portC=0 'turn off LED's on breadboard Begin: PAUSE 500 ' Wait .5 second Start_Convert OWOUT DQ, 1, [$33] ' Issue Read ROM command '/////////////////////////////////////////////////////////////////////////// ' ' READ ROM [$33] [(from Maxim documentation)] ' 'This command can only be used when there is one slave on the bus. ' 'It allows the bus master to read the slave’s 64-bit ROM code without ' 'using the Search ROM procedure. If this command is used when there ' 'is more than one slave present on the bus, a data collision will ' 'occur when all the slaves attempt to respond at the same time. '/////////////////////////////////////////////////////////////////////////// ID_Loop: OWIN DQ, 0, [STR ID\8]' Read 64-bit device data into the 8-byte array "ID" debug $0D,$0A 'do a linefeed and carrage return DEBUG "64bit = ",HEX2 ID[0],HEX2 ID[1],HEX2 ID[2],HEX2 ID[3],HEX2 ID[4],HEX2 ID[5],HEX2 ID[6],HEX2 ID[7],"h",$0D,$0A DEBUG "Family Code = ",HEX2 ID[0],"h",$0D,$0A DEBUG "Ser# = ",HEX2 ID[1],HEX2 ID[2],HEX2 ID[3],HEX2 ID[4],HEX2 ID[5],HEX2 ID[6],"h",$0D,$0A DEBUG "CRC Value = ",HEX2 ID[7],"h",$0D,$0A debug ">>> the following is complete ID of device <<<",$0D,$0A debug "[$",HEX2 ID[0],",$",HEX2 ID[1],",$",HEX2 ID[2],",$",HEX2 ID[3],",$",_ HEX2 ID[4],",$",HEX2 ID[5],",$",HEX2 ID[6],",$",HEX2 ID[7],"]",$0D,$0A PAUSE 5000 ' 5-second pause, replace sensor for next read GOTO Start_Convert END