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
    inVal32 : DWORD;
    bitNo   : SINT;
    bitVal  : BOOL;
END_VAR

inVal32: 32 bit value

bitNo: 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)

Example 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 system type

PLC libraries to include (Category group)

TwinCAT v3.1.0

PC or CX (x86, x64, ARM)

Tc2_System (System)