Set
Syntax
Set Variable or Variable.Bit or Pin Number
or
Set
Overview
Place a variable or bit in a set state. For a variable, this means loading it with its maximum value. For a bit this means setting it to 1.
Set has another purpose… If no variable is present after the command, all user RAM within the device is set to 255 when the device first powers up, or a reset is implemented. Variables that are created with assignments, and Static variables will still hold their values because the Set command becomes a directive, and signals to the compiler to add a block of code at the beginning of the user’s program, to set the RAM before the variables are created.
Parameters
Variable can be any variable or register. Variable.Bit can be any variable and bit combination. Pin Number can only be a constant that holds a value from 0 to the amount of I/O pins on the device. A value of 0 will be PORTA.0, if present, 1 will be PORTA.1, 8 will be PORTB.0 etc…
Example 1
Set Var1.3
' Set bit 3 of Var1
Set Var1
' Load Var1 with its maximum value allowed
Set STATUS.0
' Set the carry flag high
Set Array
' Set all of an Array variable. i.e. set to its max value
Set String1
' Set all of a String variable. i.e. set to spaces (ASCII 32)
Set
' Load all user RAM with 255
Set Pin_A0
' Set PORTA.0
Notes
There is a major difference between the Set and High command. Set does not alter the TRIS register if a Port is targeted.