TOGGLE/de

(Difference between revisions)
Jump to: navigation, search
(Remarks)
Line 25: Line 25:
  
 
| valign="top" width="100%" style="width: 544px; border: 1px solid rgb(0, 0, 0);" |  
 
| valign="top" width="100%" style="width: 544px; border: 1px solid rgb(0, 0, 0);" |  
Any port pin like PORTB.0 or boolean variable. A port pin must be configured as an output pin before TOGGLE will have effect.
+
Ein beliebiger Port-Pin wie z.B. PORTB.0 oder eine Bit-Variable. Der Port-Pin muss als Output konfiguriert sein.
  
 
|- style="vertical-align: top;"
 
|- style="vertical-align: top;"
Line 32: Line 32:
  
 
| valign="top" width="100%" style="width: 544px; border: 1px solid rgb(0, 0, 0);" |  
 
| valign="top" width="100%" style="width: 544px; border: 1px solid rgb(0, 0, 0);" |  
A numeric variable like byte, word, integer or long. When you invert a byte, all bits of that byte will be inverted.
+
Eine numerische Variable wie Byte, Word, Integer oder Long. Jedes einzelne Bit wird invertiert.
  
 
|}
 
|}
Line 38: Line 38:
 
<span style="font-family: Arial;">&nbsp;</span>
 
<span style="font-family: Arial;">&nbsp;</span>
  
With TOGGLE you can simply invert the output state of a port pin.
+
Mit TOGGLE können Sie einfach den Zustand eines Ausgangs-Pins invertieren.
  
When the pin is driving a relay for example and the relay is OFF, one TOGGLE statement will turn the relays ON. Another TOGGLE will turn the relays OFF again.
+
Wenn an einem Pin beispielsweise ein Relais angeschlossen ist und das Relais ist AUS dann schaltet ein TOGGLE Befehl das Relais AN. Ein weiterer TOGGLE schaltet das Relais wieder AUS.
  
 
&nbsp;
 
&nbsp;
  
When TOGGLE is used with a variable of the type Byte, Word, Integer or Long, all bits in the variable are toggled. It has the same effect as using the EXOR boolean operand with $FF, $FFFF or $FFFFFFFF
+
Wenn TOGGLE mit einer Variablen des Typs Byte, Word, Integer oder Long verwendet wird dann wird jedes Bit der Variablen invertiert. Das hat den gleichen Effekt als würde man die XOR Operation mit $FF, $FFFF beziehungsweise $FFFFFFFF benutzen.
 +
 +
Beispiel:
  
Example:
+
Toggle Var_byte hat den selben Effekt wie
 
+
Toggle Var_byte has the same effect as
+
  
 
Var_byte = Var_byte XOR &HFF
 
Var_byte = Var_byte XOR &HFF
Line 54: Line 54:
 
&nbsp;
 
&nbsp;
  
New AVR chips have an enhanced port architecture which allow a toggle of the PORT by setting the PIN register to 1. The DAT files have a setting under the [DEVICE] section named NEWPORT.
+
Neuere AVR-Mikrocontroller haben eine erweiterte Port-Architektur welche es erlaubt, einen Port-Pin zu toggeln indem eine 1 in das PIN-Register geschrieben wird. Die DAT-Dateien haben in der [DEVICE] Sektion einen Eintrag NEWPORT.
  
When the value is 1, the PIN register will be set to toggle the PORT pin. When the NEWPORT value is set to 0, an XOR will be used to toggle the port pin.
+
Wenn der Wert 1 ist dann wird das PIN-Register gesetzt um den Port-Pin toggeln. Wenn der NEWPORT-Wert 0 ist dann wird wird XOR zum Toggeln des Port-Pins benutzt.
  
 
&nbsp;
 
&nbsp;
  
TOGGLE can also be used on numeric variables. It will invert all bits in the variable. It has the same effect as NOT.
+
TOGGLE kann auch für numerische Variablen benutzt werden. Es wird dann jedes Bit der Variablen invertiert. Das hat denselben Effekt wie NOT.
  
var = NOT var ' invert all bits
+
var = NOT var ' Jedes Bit invertieren
  
 
<span style="font-family: Arial;">&nbsp;</span>
 
<span style="font-family: Arial;">&nbsp;</span>

Revision as of 02:26, 16 February 2013

Contents

Action

Invertiert den Zustand eines Output-Pins oder einer Bit-Variablen. (1 wird zu 0 und 0 wird zu 1.) Bei Anwendung auf eine numerische Variable wird jedes einzelne Bit der Variablen invertiert.

 

 

Syntax

TOGGLE pin

TOGGLE var

 

 

Remarks

pin

Ein beliebiger Port-Pin wie z.B. PORTB.0 oder eine Bit-Variable. Der Port-Pin muss als Output konfiguriert sein.

var

Eine numerische Variable wie Byte, Word, Integer oder Long. Jedes einzelne Bit wird invertiert.

 

Mit TOGGLE können Sie einfach den Zustand eines Ausgangs-Pins invertieren.

Wenn an einem Pin beispielsweise ein Relais angeschlossen ist und das Relais ist AUS dann schaltet ein TOGGLE Befehl das Relais AN. Ein weiterer TOGGLE schaltet das Relais wieder AUS.

 

Wenn TOGGLE mit einer Variablen des Typs Byte, Word, Integer oder Long verwendet wird dann wird jedes Bit der Variablen invertiert. Das hat den gleichen Effekt als würde man die XOR Operation mit $FF, $FFFF beziehungsweise $FFFFFFFF benutzen.

Beispiel:

Toggle Var_byte hat den selben Effekt wie

Var_byte = Var_byte XOR &HFF

 

Neuere AVR-Mikrocontroller haben eine erweiterte Port-Architektur welche es erlaubt, einen Port-Pin zu toggeln indem eine 1 in das PIN-Register geschrieben wird. Die DAT-Dateien haben in der [DEVICE] Sektion einen Eintrag NEWPORT.

Wenn der Wert 1 ist dann wird das PIN-Register gesetzt um den Port-Pin toggeln. Wenn der NEWPORT-Wert 0 ist dann wird wird XOR zum Toggeln des Port-Pins benutzt.

 

TOGGLE kann auch für numerische Variablen benutzt werden. Es wird dann jedes Bit der Variablen invertiert. Das hat denselben Effekt wie NOT.

var = NOT var ' Jedes Bit invertieren

 

 

See also

CONFIG PORT

 

 

 

ASM

NONE

 

 

Example


'Bascom Help, Nov 16, 2008
'ToggleNov15_2008.bas
'Program example for use in the Help-files for
' TOGGLE
 
'Program has been compiled and tested using Bascom 1.11.9.2.003
'Nard Awater, November 16, 2008
 
 
$baud = 19200
$crystal = 16000000
$regfile = "m32def.dat"
 
$hwstack = 40
$swstack = 20
$framesize = 20
 
Dim B As Byte , W As Word , I As Integer , L As Long
Led Alias Portb.0 'the anode of the LED connected to PortB.0, cathode with resistor (470 Ohm) to ground
Config Pinb.0 = Output
 
B = 0
Reset Led
'Toggle the led
Do
 Print "Led is off "
 Waitms 500
 Toggle Led
 Print "Led is on "
 Waitms 500
 Toggle Led
 Incr B
Loop Until B = 5
 
'Toggle a bit in a variable
B = &B11110000 'assign a new value: 240 in decimal
Toggle B.0
Print "B in decimal " ; B ' print it: result = 241 ; bit0 is set
Print Bin(b) ' print it: result = 11110001
Toggle B.0
Print "B in decimal " ; B ' print it: result = 240 ; bit0 is reset
Print Bin(b) ' print it: result = 11110000
 
 
W = &H000F '15 in decimal
I = &H00FF '255 in decimal
L = &H00CC00DD '13369565 in decimal
Toggle W
Print "toggled W= " ; W ' print it: result = 65520
Print Hex(w) ' print it: result = &HFFF0
 
Toggle I
Print "toggled I= " ; I ' print it: result = -256 ; two's complement !
Print Hex(i) ' print it: result = &HFF00
 
Toggle L
Print "toggled L= " ; L ' print it: result = -13369566 ; two's complement !
Print Hex(l) ' print it: result = &HFF33FF22
 
End

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