CONFIG 1WIRE/de

(Difference between revisions)
Jump to: navigation, search
(Beschreibung)
m (Extended)
Line 59: Line 59:
 
= <span class="f_Header">Extended</span> =
 
= <span class="f_Header">Extended</span> =
  
The extended option is only needed when you use multiple busses/pins and if these are pins mix normal and extended addresses.
+
Die Extended Option wird nur bei mehreren Bussen/Pins gebraucht, und wenn diese Pins normale und erweiterte Adressen mischen.
 +
<br>The extended option is only needed when you use multiple busses/pins and if these are pins mix normal and extended addresses.
  
 +
Hier die Aufklärung: Als der 1-wire-Code 1995 geschrieben wurde, waren alle Portadressen normale I/O Adressen. Also Adressen, die in den I/O Bereich bis &H60 passten. &nbsp; Um Code zu sparen, wurde Register R31 in der Bibliothek gelöscht und das Portregister in R30 übergeben.
 
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 < &H60). &nbsp;To save code, register R31 was cleared in the library and the port register was passed in R30.
 
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 < &H60). &nbsp;To save code, register R31 was cleared in the library and the port register was passed in R30.
 
+
Als Atmel die erweiterten I/O Register mit Adressen > &HFF einführte, war es möglich, R31 auf einen festen Wert zu setzen, wenn der User-Port eine erweiterte I/O Adresse hatte.
 
When Atmel introduced the extended I/O registers with address >&HFF, it was possible to set R31 to a fixed value when the user port was an extended I/O address.
 
When Atmel introduced the extended I/O registers with address >&HFF, it was possible to set R31 to a fixed value when the user port was an extended I/O address.
  
 +
Aber wenn die Adressen gemischt werden sollen, gibt es nur den Weg, die Word-Adresse des I/O Registers der Bibliothek zu übergeben.
 
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.
 
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.
  
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.
+
Und genau das macht EXTENDED = 1. Es braucht dadurch mehr Code. Diese Option wurde für einen Nutzer geschrieben, der seine Leiterplatten schon fertig hatte. Wir raten, den gleichen Port zu benutzen, wenn mehrere Pins gebraucht werden.
  
 
<span style="font-family: Arial;">&nbsp;</span>
 
<span style="font-family: Arial;">&nbsp;</span>

Revision as of 19:18, 1 March 2013

Contents

Funktion

Konfiguriert den Pin zur Benutzung mit 1-Wire und überschreibt die Compiler-Einstellung.

 

 

Syntax

CONFIG 1WIRE = pin [, extended=0|1]

 

 

Beschreibung

Pin

Der Port Pin wie z.B. PORTB.0

extended

Eine optionale Konstante, welche 0 oder 1 sein muss.

 

Der CONFIG 1WIRE Befehl überschreibt die Compiler-Einstellungen und sollte bevorzugt werden, da auf diesem Weg die Einstellung im Quellcode gespeichert wird. Es kann nur ein Pin für 1wire angegeben werden, da mehrere 1-Wire Gräte an einem Bus betrieben werden können.

 

Man kann auch mehrere Pins und damit mehrere Busse benutzen. Für diesen Fall benötigen alle 1-Wire Befehle und Funktionen die Angabe des Ports und des Pins.

 

Die 1-Wire Kommandos und Funktionen setzen automatisch das Datenrichtungsregister und das Portregister in den richtigen Zustand.

 

Es ist wichtig, dass am 1-wire-Bus ein Pullup-Widerstand von 4,7 Kiloohm vorhanden ist. Der interne Pullup-Widerstand des AVRs ist nicht geeignet.

 

Einige 1-Wire-Chips benötigen eine extra 5V-versorgung. 1-Wire ist nur ein Werbe-Begriff, die GND-Leitung wird trotzdem noch benötigt. Das Mindeste sind also 2 Leitungen, typischerweise werden 3 gebraucht.

 

Extended

Die Extended Option wird nur bei mehreren Bussen/Pins gebraucht, und wenn diese Pins normale und erweiterte Adressen mischen.
The extended option is only needed when you use multiple busses/pins and if these are pins mix normal and extended addresses.

Hier die Aufklärung: Als der 1-wire-Code 1995 geschrieben wurde, waren alle Portadressen normale I/O Adressen. Also Adressen, die in den I/O Bereich bis &H60 passten.   Um Code zu sparen, wurde Register R31 in der Bibliothek gelöscht und das Portregister in R30 übergeben. 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 < &H60).  To save code, register R31 was cleared in the library and the port register was passed in R30. Als Atmel die erweiterten I/O Register mit Adressen > &HFF einführte, war es möglich, R31 auf einen festen Wert zu setzen, wenn der User-Port eine erweiterte I/O Adresse hatte. When Atmel introduced the extended I/O registers with address >&HFF, it was possible to set R31 to a fixed value when the user port was an extended I/O address.

Aber wenn die Adressen gemischt werden sollen, gibt es nur den Weg, die Word-Adresse des I/O Registers der Bibliothek zu übergeben. 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.

Und genau das macht EXTENDED = 1. Es braucht dadurch mehr Code. Diese Option wurde für einen Nutzer geschrieben, der seine Leiterplatten schon fertig hatte. Wir raten, den gleichen Port zu benutzen, wenn mehrere Pins gebraucht werden.

 

 

See also

1WRESET , 1WREAD , 1WWRITE , 1WIRECOUNT 1WRESET , 1WSEARCHFIRST , 1WSEARCHNEXT

 

 

Example


'--------------------------------------------------------------------------------
'name : 1wire.bas
'copyright : (c) 1995-2005, MCS Electronics
'purpose : demonstrates 1wreset, 1wwrite and 1wread()
'micro : Mega48
'suited for demo : yes
'commercial addon needed : no
' pull-up of 4K7 required to VCC from Portb.2
' DS2401 serial button connected to Portb.2
'--------------------------------------------------------------------------------
 
$regfile = "m48def.dat"
$crystal = 8000000
 
$hwstack = 32 ' default use 32 for the hardware stack
$swstack = 10 'default use 10 for the SW stack
$framesize = 40 'default use 40 for the frame space
 
 
Config Com1 = Dummy , Synchrone = 0 , Parity = None , Stopbits = 1 , Databits = 8 , Clockpol = 0
 
'when only bytes are used, use the following lib for smaller code
$lib "mcsbyte.lib"
 
 
Config 1wire = Portb.0 'use this pin
'On the STK200 jumper B.0 must be inserted
Dim Ar(8) As Byte , A As Byte , I As Byte
 
 
Do
Wait 1
1wreset 'reset the device
Print Err 'print error 1 if error
1wwrite &H33 'read ROM command
For I = 1 To 8
 Ar(i) = 1wread() 'place into array
Next
 
'You could also read 8 bytes a time by unremarking the next line
'and by deleting the for next above
'Ar(1) = 1wread(8) 'read 8 bytes
 
For I = 1 To 8
 Print Hex(ar(i)); 'print output
Next
Print 'linefeed
Loop
 
 
'NOTE THAT WHEN YOU COMPILE THIS SAMPLE THE CODE WILL RUN TO THIS POINT
'THIS because of the DO LOOP that is never terminated!!!
 
'New is the possibility to use more than one 1 wire bus
'The following syntax must be used:
For I = 1 To 8
Ar(i) = 0 'clear array to see that it works
Next
 
1wreset Pinb , 2 'use this port and pin for the second device
1wwrite &H33 , 1 , Pinb , 2 'note that now the number of bytes must be specified!
'1wwrite Ar(1) , 5,pinb,2
 
'reading is also different
Ar(1) = 1wread(8 , Pinb , 2) 'read 8 bytes from portB on pin 2
 
For I = 1 To 8
Print Hex(ar(i));
Next
 
'you could create a loop with a variable for the bit number !
For I = 0 To 3 'for pin 0-3
1wreset Pinb , I
1wwrite &H33 , 1 , Pinb , I
Ar(1) = 1wread(8 , Pinb , I)
For A = 1 To 8
 Print Hex(ar(a));
Next
Print
Next
End
 
Xmega Example
'--------------------------------------------------------------------------------
'name : XM128-1wire.bas
'copyright : (c) 1995-2010, MCS Electronics
'purpose : demonstrates 1wreset, 1wwrite and 1wread()
'micro : Xm128A1
'suited for demo : no
'commercial addon needed : no
' pull-up of 4K7 required to VCC from Portb.0
' DS2401 serial button connected to Portb.0
'--------------------------------------------------------------------------------
$regfile = "xm128a1def.dat"
$crystal = 32000000
 
$lib "xmega.lib" : $external _xmegafix_clear : $external _xmegafix_rol_r1014
 
$hwstack = 32 ' default use 32 for the hardware stack
$swstack = 32 'default use 10 for the SW stack
$framesize = 32 'default use 40 for the frame space
 
'First Enable The Osc Of Your Choice
Config Osc = Enabled , 32mhzosc = Enabled
 
'configure the systemclock
Config Sysclock = 32mhz , Prescalea = 1 , Prescalebc = 1_1
 
'configure UART
Config Com1 = 19200 , Mode = Asynchroneous , Parity = None , Stopbits = 1 , Databits = 8
 
 
'configure 1wire pin
Config 1wire = Portb.0 'use this pin
 
Dim Ar(8) As Byte , A As Byte , I As Byte
 
Print "start"
 
A = 1wirecount()
Print A ; " devices found"
 
'get first
Ar(1) = 1wsearchfirst()
 
For I = 1 To 8 'print the number
Print Hex(ar(i));
Next
Print
 
Do
 'Now search for other devices
 Ar(1) = 1wsearchnext() ' get next device
 For I = 1 To 8
 Print Hex(ar(i));
 Next
 Print
Loop Until Err = 1
 
Waitms 2000
 
 
Do
1wreset 'reset the device
Print Err 'print error 1 if error
 
1wwrite &H33 'read ROM command
' Ar(1) = 1wread(8) you can use this instead of the code below
 
For I = 1 To 8
 Ar(i) = 1wread() 'place into array
Next
 
For I = 1 To 8
 Print Hex(ar(i)); 'print output
Next
Print 'linefeed
Waitms 1000
Loop
 
 
End

Languages   English Deutsch  
Personal tools
Namespaces
Variants
Actions
Navigation
In other languages
Language