<?xml version="1.0"?>
<?xml-stylesheet type="text/css" href="http://wiki.mcselec.com/bavr/skins/common/feed.css?303"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
		<id>http://wiki.mcselec.com/bavr/index.php?action=history&amp;feed=atom&amp;title=CONFIG_1WIRE</id>
		<title>CONFIG 1WIRE - Revision history</title>
		<link rel="self" type="application/atom+xml" href="http://wiki.mcselec.com/bavr/index.php?action=history&amp;feed=atom&amp;title=CONFIG_1WIRE"/>
		<link rel="alternate" type="text/html" href="http://wiki.mcselec.com/bavr/index.php?title=CONFIG_1WIRE&amp;action=history"/>
		<updated>2026-05-30T00:04:22Z</updated>
		<subtitle>Revision history for this page on the wiki</subtitle>
		<generator>MediaWiki 1.18.6</generator>

	<entry>
		<id>http://wiki.mcselec.com/bavr/index.php?title=CONFIG_1WIRE&amp;diff=4646&amp;oldid=prev</id>
		<title>Admin at 19:28, 24 August 2013</title>
		<link rel="alternate" type="text/html" href="http://wiki.mcselec.com/bavr/index.php?title=CONFIG_1WIRE&amp;diff=4646&amp;oldid=prev"/>
				<updated>2013-08-24T19:28:47Z</updated>
		
		<summary type="html">&lt;p&gt;&lt;/p&gt;
&lt;table class='diff diff-contentalign-left'&gt;
			&lt;col class='diff-marker' /&gt;
			&lt;col class='diff-content' /&gt;
			&lt;col class='diff-marker' /&gt;
			&lt;col class='diff-content' /&gt;
		&lt;tr valign='top'&gt;
		&lt;td colspan='2' style=&quot;background-color: white; color:black;&quot;&gt;← Older revision&lt;/td&gt;
		&lt;td colspan='2' style=&quot;background-color: white; color:black;&quot;&gt;Revision as of 19:28, 24 August 2013&lt;/td&gt;
		&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 69:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 69:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;And that is exactly what EXTENDED=1 will do. It will use more code. This support was written for a customer that already made his PCB's. We do advise to use the same port when you use multiple pins.&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;And that is exactly what EXTENDED=1 will do. It will use more code. This support was written for a customer that already made his PCB's. We do advise to use the same port when you use multiple pins.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt;&amp;#160;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;background: #cfc; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;color: red; font-weight: bold; text-decoration: none;&quot;&gt;&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt;&amp;#160;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;background: #cfc; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;color: red; font-weight: bold; text-decoration: none;&quot;&gt;&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt;&amp;#160;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;background: #cfc; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;color: red; font-weight: bold; text-decoration: none;&quot;&gt;&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt;&amp;#160;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;background: #cfc; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;color: red; font-weight: bold; text-decoration: none;&quot;&gt;= &amp;lt;span class=&amp;quot;f_Header&amp;quot;&amp;gt;ATMEGA128 PORTF&amp;lt;/span&amp;gt; =&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt;&amp;#160;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;background: #cfc; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;color: red; font-weight: bold; text-decoration: none;&quot;&gt;&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt;&amp;#160;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;background: #cfc; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;color: red; font-weight: bold; text-decoration: none;&quot;&gt;The ATMEGA128 PORTF is split up. Normally, the DDR, PIN and PORT registers are in the same order.&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt;&amp;#160;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;background: #cfc; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;color: red; font-weight: bold; text-decoration: none;&quot;&gt;&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt;&amp;#160;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;background: #cfc; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;color: red; font-weight: bold; text-decoration: none;&quot;&gt;&amp;lt;span style=&amp;quot;font-family: Arial;&amp;quot;&amp;gt;For example : PORTB &amp;amp;nbsp; &amp;amp;nbsp; &amp;amp;nbsp; &amp;amp;nbsp;= &amp;amp;H18 , DDRB &amp;amp;nbsp; &amp;amp;nbsp; &amp;amp;nbsp; &amp;amp;nbsp;= &amp;amp;H17 and PINB = &amp;amp;H16&amp;lt;/span&amp;gt;&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt;&amp;#160;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;background: #cfc; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;color: red; font-weight: bold; text-decoration: none;&quot;&gt;&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt;&amp;#160;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;background: #cfc; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;color: red; font-weight: bold; text-decoration: none;&quot;&gt;&amp;lt;span style=&amp;quot;font-family: Arial;&amp;quot;&amp;gt;But PORTF in the MEGA128 is different : &amp;amp;nbsp;PINF &amp;amp;nbsp; &amp;amp;nbsp; &amp;amp;nbsp; &amp;amp;nbsp;= &amp;amp;H00 &amp;amp;nbsp;, PORTF = &amp;amp;H62 , DDRF = &amp;amp;H61&amp;lt;/span&amp;gt;&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt;&amp;#160;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;background: #cfc; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;color: red; font-weight: bold; text-decoration: none;&quot;&gt;&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt;&amp;#160;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;background: #cfc; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;color: red; font-weight: bold; text-decoration: none;&quot;&gt;&amp;lt;span style=&amp;quot;font-family: Arial;&amp;quot;&amp;gt;You need a special library named&amp;amp;nbsp;&amp;lt;/span&amp;gt;&amp;lt;span style=&amp;quot;font-family: Arial; font-weight: bold;&amp;quot;&amp;gt;M128-1wire-PortF.lib&amp;amp;nbsp;&amp;lt;/span&amp;gt;&amp;lt;span style=&amp;quot;font-family: Arial;&amp;quot;&amp;gt;for this processor and port. This library is fixed to portF&amp;lt;/span&amp;gt;&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&amp;lt;span style=&amp;quot;font-family: Arial;&amp;quot;&amp;gt;&amp;amp;nbsp;&amp;lt;/span&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&amp;lt;span style=&amp;quot;font-family: Arial;&amp;quot;&amp;gt;&amp;amp;nbsp;&amp;lt;/span&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;</summary>
		<author><name>Admin</name></author>	</entry>

	<entry>
		<id>http://wiki.mcselec.com/bavr/index.php?title=CONFIG_1WIRE&amp;diff=423&amp;oldid=prev</id>
		<title>Admin: Created page with &quot;= &lt;span class=&quot;f_Header&quot;&gt;Action&lt;/span&gt; =  Configure the pin to use for 1WIRE statements and override the compiler setting.  &lt;span style=&quot;font-family: Arial;&quot;&gt;&amp;nbsp;&lt;/span&gt;  &lt;s...&quot;</title>
		<link rel="alternate" type="text/html" href="http://wiki.mcselec.com/bavr/index.php?title=CONFIG_1WIRE&amp;diff=423&amp;oldid=prev"/>
				<updated>2013-02-07T18:24:17Z</updated>
		
		<summary type="html">&lt;p&gt;Created page with &amp;quot;= &amp;lt;span class=&amp;quot;f_Header&amp;quot;&amp;gt;Action&amp;lt;/span&amp;gt; =  Configure the pin to use for 1WIRE statements and override the compiler setting.  &amp;lt;span style=&amp;quot;font-family: Arial;&amp;quot;&amp;gt; &amp;lt;/span&amp;gt;  &amp;lt;s...&amp;quot;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;= &amp;lt;span class=&amp;quot;f_Header&amp;quot;&amp;gt;Action&amp;lt;/span&amp;gt; =&lt;br /&gt;
&lt;br /&gt;
Configure the pin to use for 1WIRE statements and override the compiler setting.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;span style=&amp;quot;font-family: Arial;&amp;quot;&amp;gt;&amp;amp;nbsp;&amp;lt;/span&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;span style=&amp;quot;font-family: Arial;&amp;quot;&amp;gt;&amp;amp;nbsp;&amp;lt;/span&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= &amp;lt;span class=&amp;quot;f_Header&amp;quot;&amp;gt;Syntax&amp;lt;/span&amp;gt; =&lt;br /&gt;
&lt;br /&gt;
&amp;lt;span class=&amp;quot;f_Syntax&amp;quot;&amp;gt;CONFIG 1WIRE&amp;lt;/span&amp;gt;&amp;amp;nbsp;= pin [, extended=0|1]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;span style=&amp;quot;font-family: Arial;&amp;quot;&amp;gt;&amp;amp;nbsp;&amp;lt;/span&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;span style=&amp;quot;font-family: Arial;&amp;quot;&amp;gt;&amp;amp;nbsp;&amp;lt;/span&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= &amp;lt;span class=&amp;quot;f_Header&amp;quot;&amp;gt;Remarks&amp;lt;/span&amp;gt; =&lt;br /&gt;
&amp;lt;div style=&amp;quot;padding: 0px; margin: 0px 0px 0px 4px;&amp;quot;&amp;gt;&lt;br /&gt;
{| width=&amp;quot;485&amp;quot; cellspacing=&amp;quot;0&amp;quot; cellpadding=&amp;quot;1&amp;quot; border=&amp;quot;1&amp;quot; style=&amp;quot;border: 2px solid rgb(0, 0, 0); border-spacing: 0px; border-collapse: collapse;&amp;quot;&lt;br /&gt;
|- style=&amp;quot;vertical-align: top;&amp;quot;&lt;br /&gt;
| valign=&amp;quot;top&amp;quot; width=&amp;quot;20%&amp;quot; style=&amp;quot;width: 94px; border: 1px solid rgb(0, 0, 0);&amp;quot; | &lt;br /&gt;
Pin&lt;br /&gt;
&lt;br /&gt;
| valign=&amp;quot;top&amp;quot; width=&amp;quot;106%&amp;quot; style=&amp;quot;width: 382px; border: 1px solid rgb(0, 0, 0);&amp;quot; | &lt;br /&gt;
The port pin to use such as PORTB.0&lt;br /&gt;
&lt;br /&gt;
|- style=&amp;quot;vertical-align: top;&amp;quot;&lt;br /&gt;
| valign=&amp;quot;top&amp;quot; width=&amp;quot;20%&amp;quot; style=&amp;quot;width: 94px; border: 1px solid rgb(0, 0, 0);&amp;quot; | &lt;br /&gt;
extended&lt;br /&gt;
&lt;br /&gt;
| valign=&amp;quot;top&amp;quot; width=&amp;quot;106%&amp;quot; style=&amp;quot;width: 382px; border: 1px solid rgb(0, 0, 0);&amp;quot; | &lt;br /&gt;
An optional constant value which need to be 0 or 1.&lt;br /&gt;
&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;span style=&amp;quot;font-family: Arial;&amp;quot;&amp;gt;&amp;amp;nbsp;&amp;lt;/span&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The CONFIG 1WIRE statement overrides the compiler setting. It is the preferred that you use it. This way the setting is stored in your source code.&lt;br /&gt;
&lt;br /&gt;
You can configure only one pin for the 1WIRE statements because the idea is that you can attach multiple 1WIRE devices to the 1WIRE bus.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;span style=&amp;quot;font-family: Arial;&amp;quot;&amp;gt;&amp;amp;nbsp;&amp;lt;/span&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You can however use multiple pins and thus multiple busses. All 1wire commands and functions need the port and pin in that case.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;span style=&amp;quot;font-family: Arial;&amp;quot;&amp;gt;&amp;amp;nbsp;&amp;lt;/span&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The 1wire commands and function will automatically set the DDR and PORT register bits to the proper state. You do not need to bring the pins into the right state yourself.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;span style=&amp;quot;font-family: Arial;&amp;quot;&amp;gt;&amp;amp;nbsp;&amp;lt;/span&amp;gt;&lt;br /&gt;
&lt;br /&gt;
It is important that you use a pull up resistor of 4K7 ohm on the 1wire pin. The pull up resistor of the AVR is not sufficient.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;span style=&amp;quot;font-family: Arial;&amp;quot;&amp;gt;&amp;amp;nbsp;&amp;lt;/span&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Also notice that some 1wire chips also need +5V. 1 wire is just marketing since you need GND anyway. The least is 2 wires and typical you need 3 wires.&lt;br /&gt;
&lt;br /&gt;
&amp;amp;nbsp;&lt;br /&gt;
&lt;br /&gt;
= &amp;lt;span class=&amp;quot;f_Header&amp;quot;&amp;gt;Extended&amp;lt;/span&amp;gt; =&lt;br /&gt;
&lt;br /&gt;
The extended option is only needed when you use multiple busses/pins and if these are pins mix normal and extended addresses.&lt;br /&gt;
&lt;br /&gt;
Let's clear that up. When the 1wire code was written in 1995 all the port addresses were normal I/O addresses. These are addresses that fit in the I/O space (address &amp;lt; &amp;amp;H60). &amp;amp;nbsp;To save code, register R31 was cleared in the library and the port register was passed in R30.&lt;br /&gt;
&lt;br /&gt;
When Atmel introduced the extended I/O registers with address &amp;gt;&amp;amp;HFF, it was possible to set R31 to a fixed value when the user port was an extended I/O address.&lt;br /&gt;
&lt;br /&gt;
But when you want to mix the addresses, there is no other way then to pass the word address of the I/O register to the library code.&lt;br /&gt;
&lt;br /&gt;
And that is exactly what EXTENDED=1 will do. It will use more code. This support was written for a customer that already made his PCB's. We do advise to use the same port when you use multiple pins.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;span style=&amp;quot;font-family: Arial;&amp;quot;&amp;gt;&amp;amp;nbsp;&amp;lt;/span&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;span style=&amp;quot;font-family: Arial;&amp;quot;&amp;gt;&amp;amp;nbsp;&amp;lt;/span&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= &amp;lt;span class=&amp;quot;f_Header&amp;quot;&amp;gt;See also&amp;lt;/span&amp;gt; =&lt;br /&gt;
&lt;br /&gt;
[[1WRESET]]&amp;amp;nbsp;,&amp;amp;nbsp;[[1WREAD]]&amp;amp;nbsp;,&amp;amp;nbsp;[[1WWRITE]]&amp;amp;nbsp;,&amp;amp;nbsp;[[1WIRECOUNT|1WIRECOUNT&amp;amp;nbsp;]],&amp;amp;nbsp;[[1WRESET]]&amp;amp;nbsp;,&amp;amp;nbsp;[[1WSEARCHFIRST]]&amp;amp;nbsp;,&amp;amp;nbsp;[[1WSEARCHNEXT]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;span style=&amp;quot;font-family: Arial;&amp;quot;&amp;gt;&amp;amp;nbsp;&amp;lt;/span&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;span style=&amp;quot;font-family: Arial;&amp;quot;&amp;gt;&amp;amp;nbsp;&amp;lt;/span&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= &amp;lt;span class=&amp;quot;f_Header&amp;quot;&amp;gt;Example&amp;lt;/span&amp;gt; =&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br/&amp;gt;&amp;lt;source lang=&amp;quot;bascomavr&amp;quot;&amp;gt;&lt;br /&gt;
'--------------------------------------------------------------------------------&lt;br /&gt;
'name : 1wire.bas&lt;br /&gt;
'copyright : (c) 1995-2005, MCS Electronics&lt;br /&gt;
'purpose : demonstrates 1wreset, 1wwrite and 1wread()&lt;br /&gt;
'micro : Mega48&lt;br /&gt;
'suited for demo : yes&lt;br /&gt;
'commercial addon needed : no&lt;br /&gt;
' pull-up of 4K7 required to VCC from Portb.2&lt;br /&gt;
' DS2401 serial button connected to Portb.2&lt;br /&gt;
'--------------------------------------------------------------------------------&lt;br /&gt;
 &lt;br /&gt;
$regfile = &amp;quot;m48def.dat&amp;quot;&lt;br /&gt;
$crystal = 8000000&lt;br /&gt;
 &lt;br /&gt;
$hwstack = 32 ' default use 32 for the hardware stack&lt;br /&gt;
$swstack = 10 'default use 10 for the SW stack&lt;br /&gt;
$framesize = 40 'default use 40 for the frame space&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
Config Com1 = Dummy , Synchrone = 0 , Parity = None , Stopbits = 1 , Databits = 8 , Clockpol = 0&lt;br /&gt;
 &lt;br /&gt;
'when only bytes are used, use the following lib for smaller code&lt;br /&gt;
$lib &amp;quot;mcsbyte.lib&amp;quot;&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
Config 1wire = Portb.0 'use this pin&lt;br /&gt;
'On the STK200 jumper B.0 must be inserted&lt;br /&gt;
Dim Ar(8) As Byte , A As Byte , I As Byte&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
Do&lt;br /&gt;
Wait 1&lt;br /&gt;
1wreset 'reset the device&lt;br /&gt;
Print Err 'print error 1 if error&lt;br /&gt;
1wwrite &amp;amp;H33 'read ROM command&lt;br /&gt;
For I = 1 To 8&lt;br /&gt;
 Ar(i) = 1wread() 'place into array&lt;br /&gt;
Next&lt;br /&gt;
 &lt;br /&gt;
'You could also read 8 bytes a time by unremarking the next line&lt;br /&gt;
'and by deleting the for next above&lt;br /&gt;
'Ar(1) = 1wread(8) 'read 8 bytes&lt;br /&gt;
 &lt;br /&gt;
For I = 1 To 8&lt;br /&gt;
 Print Hex(ar(i)); 'print output&lt;br /&gt;
Next&lt;br /&gt;
Print 'linefeed&lt;br /&gt;
Loop&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
'NOTE THAT WHEN YOU COMPILE THIS SAMPLE THE CODE WILL RUN TO THIS POINT&lt;br /&gt;
'THIS because of the DO LOOP that is never terminated!!!&lt;br /&gt;
 &lt;br /&gt;
'New is the possibility to use more than one 1 wire bus&lt;br /&gt;
'The following syntax must be used:&lt;br /&gt;
For I = 1 To 8&lt;br /&gt;
Ar(i) = 0 'clear array to see that it works&lt;br /&gt;
Next&lt;br /&gt;
 &lt;br /&gt;
1wreset Pinb , 2 'use this port and pin for the second device&lt;br /&gt;
1wwrite &amp;amp;H33 , 1 , Pinb , 2 'note that now the number of bytes must be specified!&lt;br /&gt;
'1wwrite Ar(1) , 5,pinb,2&lt;br /&gt;
 &lt;br /&gt;
'reading is also different&lt;br /&gt;
Ar(1) = 1wread(8 , Pinb , 2) 'read 8 bytes from portB on pin 2&lt;br /&gt;
 &lt;br /&gt;
For I = 1 To 8&lt;br /&gt;
Print Hex(ar(i));&lt;br /&gt;
Next&lt;br /&gt;
 &lt;br /&gt;
'you could create a loop with a variable for the bit number !&lt;br /&gt;
For I = 0 To 3 'for pin 0-3&lt;br /&gt;
1wreset Pinb , I&lt;br /&gt;
1wwrite &amp;amp;H33 , 1 , Pinb , I&lt;br /&gt;
Ar(1) = 1wread(8 , Pinb , I)&lt;br /&gt;
For A = 1 To 8&lt;br /&gt;
 Print Hex(ar(a));&lt;br /&gt;
Next&lt;br /&gt;
Print&lt;br /&gt;
Next&lt;br /&gt;
End&lt;br /&gt;
 &lt;br /&gt;
Xmega Example&lt;br /&gt;
'--------------------------------------------------------------------------------&lt;br /&gt;
'name : XM128-1wire.bas&lt;br /&gt;
'copyright : (c) 1995-2010, MCS Electronics&lt;br /&gt;
'purpose : demonstrates 1wreset, 1wwrite and 1wread()&lt;br /&gt;
'micro : Xm128A1&lt;br /&gt;
'suited for demo : no&lt;br /&gt;
'commercial addon needed : no&lt;br /&gt;
' pull-up of 4K7 required to VCC from Portb.0&lt;br /&gt;
' DS2401 serial button connected to Portb.0&lt;br /&gt;
'--------------------------------------------------------------------------------&lt;br /&gt;
$regfile = &amp;quot;xm128a1def.dat&amp;quot;&lt;br /&gt;
$crystal = 32000000&lt;br /&gt;
 &lt;br /&gt;
$lib &amp;quot;xmega.lib&amp;quot; : $external _xmegafix_clear : $external _xmegafix_rol_r1014&lt;br /&gt;
 &lt;br /&gt;
$hwstack = 32 ' default use 32 for the hardware stack&lt;br /&gt;
$swstack = 32 'default use 10 for the SW stack&lt;br /&gt;
$framesize = 32 'default use 40 for the frame space&lt;br /&gt;
 &lt;br /&gt;
'First Enable The Osc Of Your Choice&lt;br /&gt;
Config Osc = Enabled , 32mhzosc = Enabled&lt;br /&gt;
 &lt;br /&gt;
'configure the systemclock&lt;br /&gt;
Config Sysclock = 32mhz , Prescalea = 1 , Prescalebc = 1_1&lt;br /&gt;
 &lt;br /&gt;
'configure UART&lt;br /&gt;
Config Com1 = 19200 , Mode = Asynchroneous , Parity = None , Stopbits = 1 , Databits = 8&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
'configure 1wire pin&lt;br /&gt;
Config 1wire = Portb.0 'use this pin&lt;br /&gt;
 &lt;br /&gt;
Dim Ar(8) As Byte , A As Byte , I As Byte&lt;br /&gt;
 &lt;br /&gt;
Print &amp;quot;start&amp;quot;&lt;br /&gt;
 &lt;br /&gt;
A = 1wirecount()&lt;br /&gt;
Print A ; &amp;quot; devices found&amp;quot;&lt;br /&gt;
 &lt;br /&gt;
'get first&lt;br /&gt;
Ar(1) = 1wsearchfirst()&lt;br /&gt;
 &lt;br /&gt;
For I = 1 To 8 'print the number&lt;br /&gt;
Print Hex(ar(i));&lt;br /&gt;
Next&lt;br /&gt;
Print&lt;br /&gt;
 &lt;br /&gt;
Do&lt;br /&gt;
 'Now search for other devices&lt;br /&gt;
 Ar(1) = 1wsearchnext() ' get next device&lt;br /&gt;
 For I = 1 To 8&lt;br /&gt;
 Print Hex(ar(i));&lt;br /&gt;
 Next&lt;br /&gt;
 Print&lt;br /&gt;
Loop Until Err = 1&lt;br /&gt;
 &lt;br /&gt;
Waitms 2000&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
Do&lt;br /&gt;
1wreset 'reset the device&lt;br /&gt;
Print Err 'print error 1 if error&lt;br /&gt;
 &lt;br /&gt;
1wwrite &amp;amp;H33 'read ROM command&lt;br /&gt;
' Ar(1) = 1wread(8) you can use this instead of the code below&lt;br /&gt;
 &lt;br /&gt;
For I = 1 To 8&lt;br /&gt;
 Ar(i) = 1wread() 'place into array&lt;br /&gt;
Next&lt;br /&gt;
 &lt;br /&gt;
For I = 1 To 8&lt;br /&gt;
 Print Hex(ar(i)); 'print output&lt;br /&gt;
Next&lt;br /&gt;
Print 'linefeed&lt;br /&gt;
Waitms 1000&lt;br /&gt;
Loop&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
End&lt;br /&gt;
&amp;lt;/source&amp;gt;&amp;lt;br/&amp;gt;{{Languages}}&lt;br /&gt;
&lt;br /&gt;
[[Category:BASCOM Language Reference]]&lt;/div&gt;</summary>
		<author><name>Admin</name></author>	</entry>

	</feed>