onlinecomponents.com
The Inline Controller under PC WorX
7805_en_02 PHOENIX CONTACT 3-13
Figure 3-9 Alignment - padding bytes in data gaps
Struct1 receives a padding byte after the ByteElement so that the WordElement is at a
WORD address (address that can be divided by 2 leaving no remainder). The alignment of
the overall structure is based on the data type used with maximum alignment. In this case
the WordElement specifies the alignment.
The size of Struct2 is calculated based on the elements used and the resulting alignment.
The corresponding number of padding bytes is inserted so that the size of the data type with
the value of the alignment can be divided by 2 leaving no remainder (data type size modulo
alignment = 0).
Struct3 does not receive any padding bytes as the maximum alignment corresponds to one
byte.
Due to the padding bytes that belong to the Struct2 structure, the Struct3 structure starts at
an even address in Struct4.
Array1 receives 2 padding bytes, which corresponds to two consecutive Struct2 structures.
ByteElement
Padding Byte
WordElement
ByteElement
Padding Byte
WordElement
ByteElement1
ByteElement2
ByteElement
Padding Byte
WordElement
ByteElement1
ByteElement2
ByteElement
Padding Byte
WordElement
ByteElement
Padding Byte
WordElement
Struct1 Struct2
Struct3
Struct4
Array1
Size: 4 bytes
Align: 2 bytes
Size: 4 bytes
Align: 2 bytes
Size: 2 bytes
Align: 1 byte
Size: 6 bytes
Align: 2 bytes
Size: 8 bytes
Align: 2 bytes