FP_SWAP_BYTES

Exchange higher bytes and lower bytes

This FP instruction exchanges the higher bytes and lower bytes of the data area specified by s if the trigger EN is TRUE. The result is transferred to d.

Parameters

Input

s (WORD)

Source data area

Output

d (WORD)

Destination data area

Error flags

sys_bIsOperationErrorHold (turns to TRUE and remains TRUE)
  • if the area specified using the index modifier exceeds the limit.
sys_bIsOperationErrorNonHold (turns to TRUE for one scan)
  • if the area specified using the index modifier exceeds the limit.
Related topics:

Example

POU header

All input and output variables used for programming this function have been declared in the POU header. The same POU header is used for all programming languages.

	VAR
		bStart: BOOL:=FALSE;
			(*activates the function*)
		wSwapValue: WORD:=16#2345;
			(*result after 0->1 leading
edge from start: 16#4523*)
		wResult: WORD:=0;
	END_VAR

POU body

When the variable bStart changes from FALSE to TRUE, the function is carried out.

LD body

BODY
    WORKSPACE
        NETWORK_LIST_TYPE := NWTYPELD ;
    END_WORKSPACE
    NET_WORK
        NETWORK_TYPE := NWTYPELD ;
        NETWORK_LABEL :=  ;
        NETWORK_TITLE :=  ;
        NETWORK_HEIGHT := 6 ;
        NETWORK_BODY
B(B_CONTACT,,bStart,3,2,5,4,R);
B(B_F,FP_SWAP_BYTES!,,12,1,21,5,,?DEN?D@'s'?AENO?Cd);
B(B_VARIN,,wSwapValue,10,3,12,5,);
B(B_VAROUT,,wResult,21,3,23,5,);
L(1,0,1,6);
L(1,3,3,3);
L(5,3,12,3);
        END_NETWORK_BODY
    END_NET_WORK
END_BODY

ST body

IF DF(bStart) THEN
    FP_SWAP_BYTES(s := wSwapValue_Copy, d => wResult);
END_IF;

Modified on: 2019-08-23Feedback on this pagePanasonic hotline