beckhoff TE1200 — 4.2.1.1.5 SA0005: Invalid addresses and data types

Configuration | Rules Sample: Global variable list: VAR_GLOBAL bVar AT%QX0.0 : BOOL; nSample AT%QW5 : INT; END_VAR MAIN program: PROGRAM MAIN VAR nCondition : INT; END_VAR IF nCondition bVar := TRUE; // => SA0004 nSample := INT#12; // => SA0004 END_IF CASE nCondition OF INT#1: bVar := FALSE; // => SA0004 INT#2: nSample := INT#11; // => SA0004 ELSE bVar := TRUE; // => SA0004 nSample := INT#9; // => SA0004 END_CASE Also see about this 2 Command 'Run static analysis' [ } 110] 4.2.1.1.5 SA0005: Invalid addresses and data types | SA0005: Invalid addresses and data types If the recommended placeholders %I* or %Q* are used, TwinCAT automatically performs flexible and optimized addressing. Samples:

PROGRAM MAIN VAR nOK AT%QW0 : INT; bOK AT%QX5.0 : BOOL; nNOK AT%QD10 : INT; // => SA0005 bNOK AT%QB15 : BOOL; // => SA0005 END_VAR TE1200 22 Version: 2.11.1 Function Determines invalid address and data type specifications. The following size prefixes are valid for addresses. Deviations from this lead to an invalid address specification. • X for BOOL • B for 1-byte data types • W for 2-byte data types • D for 4-byte data types Reason Variables that lie on direct addresses should, if possible, be associated with an address that corresponds to their data type width. It can be confusing for the reader of the code if, for example, a DWORD is placed on a BYTE address. Importance Low