In CoDeSys v2.3 on an IFM CR0403, initialize a BYTE array with base-prefixed literals and the array repetition form. The reported Erroneous initial value occurs when values such as 11111111 are entered without the binary prefix or when the initializer does not match the required aggregate syntax.
Use valid BYTE literal syntax
Write binary values as 2#11111111 and hexadecimal values as 16#FF. Keep the radix prefix, #, and digits together. A bare 11111111 is a decimal literal, not an eight-bit binary pattern.
VAR
RX65265 : ARRAY [1..8] OF BYTE := [8(2#11111111)];
END_VAR
Repeat and combine array initializers
The form count(value) repeats one value inside the initializer. The following declarations each supply exactly eight BYTE elements.
| Declaration | Result |
|---|---|
[8(2#11111111)] |
Eight elements containing the binary value 11111111
|
[16#D6, 16#5F, 6(16#FF)] |
Two explicit hexadecimal elements followed by six repeated elements |
[16#0C, 7(16#FF)] |
One explicit mask element followed by seven repeated elements |
VAR
RX65265 : ARRAY [1..8] OF BYTE :=
[16#D6, 16#5F, 6(16#FF)];
MASK : ARRAY [1..8] OF BYTE :=
[16#0C, 7(16#FF)];
PBHEX : ARRAY [1..8] OF BYTE;
END_VAR
Separate initialization from runtime processing
Place an initial value after := in the declaration. The evidence confirms declaration-time aggregate syntax but does not establish that CoDeSys v2.3 accepts a whole-array executable assignment or the expression PBHEX := RX65265 AND MASK. If that expression fails, apply AND between corresponding BYTE elements rather than treating both arrays as scalar operands.
Build and verify the mask
- Declare each array with the same index range,
[1..8]. - Build using a compact radix literal such as
16#FFor2#11111111. - Confirm that every initializer expands to eight values.
- Verify the received CAN data and masked output element by element. For each position, the intended relationship is
PBHEX[index] := RX65265[index] AND MASK[index].
FAQ
Why does CoDeSys report Erroneous initial value for 11111111?
11111111 lacks a binary radix prefix. Use 2#11111111 for the intended BYTE bit pattern.
How do I initialize all eight BYTE array elements to FF?
Declare the array with := [8(16#FF)]. The repetition count expands the value across all eight positions.
How do I initialize two values and fill the remaining six bytes?
Use := [16#D6, 16#5F, 6(16#FF)]. The two explicit elements plus six repeated elements match the ARRAY [1..8] range.