MEMSET

MEMSET 1:

The function MEMSET allows PLC variables in a particular memory area to be set to a particular value.

FUNCTION MEMSET : UDINT

VAR_INPUT
    destAddr : PVOID;
    fillByte : USINT;
    n        : UDINT;
END_VAR

Name

Type

Description

destAddr

PVOID

Start address of the memory area that is to be set.

fillByte

USINT

Value of the filler byte.

n

UDINT

Number of bytes to be set.

The function fills n bytes starting from the memory area with the start address destAddr with the values fillByte.

Return parameter

Meaning

0

Incorrect parameter values. destAddr == 0 or n == 0

> 0

If successful, the number of bytes that have been set (n).

Example of a call in FBD:

PROGRAM MAIN
VAR
    Buffer1 : ARRAY[0..3] OF BYTE;
    SetResult : UDINT;
END_VAR

MEMSET 2:

In the example, 4 bytes in Buffer1 are set to the value 0xAF.

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)