blueroomelectronics
Well-Known Member
Here's the code in Swordfish BASIC, it's basically the example that's found in the help file. I've adapted to work using the Junebugs CON4 connector (designed for 1-wire devices and more)
After programming you have to disable the programmer and enable the UART tool in the PICkit2 software. DIP switchs 1-3 off and 4,5 on.
Hook up a DS18S20 to CON4 (the flat side faces the reset button) and pressing reset displays this in the UART tool.
FAMILY $10 ($90) ($0008016029C610)
1 device(s) found
After programming you have to disable the programmer and enable the UART tool in the PICkit2 software. DIP switchs 1-3 off and 4,5 on.
Code:
// Junebug 1-Wire test (using example found in Swordfish help menu)
Device = 18F1320
Clock = 8
Config OSC = INTIO2, WDT = OFF // Use the Internal Oscillator
Include "ow.bas"
Include "convert.bas"
Include "usart.bas"
// on find event handler...
Event OnFind()
Dim Index As Byte
USART.Write("FAMILY $", HexToStr(SearchFamily,2))
USART.Write(" ($",HexToStr(SearchID(7),2),")")
USART.Write(" ($")
For Index = 6 to 0 step -1
USART.Write(HexToStr(SearchID(Index),2))
Next
USART.Write(")",13,10)
End Event
// working variables...
Dim DeviceCount As Byte
// program start...
osccon = $72
high(porta.3) // power DS18S20
SetBaudrate(br9600)
SetPin(PORTA.4)
DeviceCount = Search(owSearchROM, OnFind)
USART.Write(DecToStr(DeviceCount), " device(s) found", 13, 10)
end
Hook up a DS18S20 to CON4 (the flat side faces the reset button) and pressing reset displays this in the UART tool.
FAMILY $10 ($90) ($0008016029C610)
1 device(s) found