Action
Toggles the state of an output pin or bit variable.
Syntax
TOGGLE pin
Remarks
pin |
Any port pin like PORTB.0 or bit variable. A port pin must be configured as an output pin before TOGGLE can be used. |
With TOGGLE you can simply invert the output state of a port pin.
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.
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.
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.
See also
ASM
NONE
Partial Example
Dim Var As Byte
Config Pinb.0 = Output ' portB.0 is an output now
Do
Toggle Portb.0 'toggle state
Waitms 1000 'wait for 1 sec
Loop