CSETBIT32
The function sets/resets the bit specified by a bit number in the 32 bit value that is passed to it and returns the resulting value.
FUNCTION CSETBIT32 : DWORD
VAR_INPUT
inVal32 :DWORD;
bitNo :SINT;
bitVal :BOOL;
END_VAR
inVal32: The 32-bit value that is to be modified;
bitNo: The number of the bit that is to be set/reset (0-31). This number is internally converted to a modulo 32 value prior to execution;
bitVal: The new value of the set/reset bit (TRUE = 1, FALSE = 0);
Example of calling the function in FBD:
This sets bit 15 of the input value '16#8000000' to 1. The result is the (hex) value '80008000'.
Requirements
Development environment | Target system type | PLC libraries to include |
---|---|---|
TwinCAT v2.7.0 | PC or CX (x86) | PLCSystem.Lib |
TwinCAT v2.8.0 | PC or CX (x86) | TcSystem.Lib |
TwinCAT v2.10.0 Build >= 1301 | CX (ARM) | TcSystem.Lib |