← Bit Manipulation

Apply Bit Mask

easy

Passes only the input bits selected by a mask; every unselected output bit is zero.

What it teaches

Think of the mask as a stencil over the input word: a 1 lets that input bit through, while a 0 blocks it. Example: in Binary, input 170 ends in 1010_1010 and mask 165 in 1010_0101, so the result ends in 1010_0000, which is 160; every digit before those is 0. The everyday job is extraction: mask a packed status word and you are left holding just the field you care about — the fault code, the mode bits — with everything else stripped to zero.

Parameters

TagDirectionTypeDefaultDescription
In_WordInputDINT170Word whose selected bits pass through
Cfg_MaskInputDINT165A 1 passes the matching input bit; a 0 blocks it
Out_MaskedOutputDINT0Input word with every unselected bit cleared

Required behavior