CSETBIT32

CSETBIT32 1:

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

VAR_INPUT
    inVal32         :DWORD;
    bitNo           :SINT;
    bitVal          :BOOL;
END_VAR

inVal32: a 32-bit value;

bitNo:  the number of the bit to be set or reset (0-31). This number is internally converted to a modulo 32 value prior to execution;

bitVal:  value to which the bit is to be set or reset (TRUE = 1, FALSE = 0);

 

Sample of calling the function in FBD:

CSETBIT32 2:
Bit 15 in the input value '16#80000000' is set to 1. The result ( 16#80008000 ) is assigned to the variable CSetBitResultVal.

Requirements

Development environment

Target platform

PLC libraries to include

TwinCAT v2.7.0 and above

BCxxxx (165)

Standard.Lb6, PlcSystemBC.Lb6, TcPlcUtilitiesBC.Lb6