142 SI-Ethernet User Guide
Issue: 1
As an example, the following code may be used in the user program:
// Writing
// Calculate the value to write LSW
LSW% = Value% & 0x00007FFF
// Handle the casting from 32bit variable to 16bit parameter
IF Value%.15 = True% THEN
// Subtract 32768
LSW% = LSW% - 32768
ENDIF
// Write it to the correct parameter
Address% = BaseAddress% + 5
#Address% = LSW%
//Calculate the value to write MSW
MSW% = (Value% >> 16) & 0x00007FFF
// Handle the casting from 32bit variable to 16bit parameter
IF Value%.31 = True% THEN
// Subtract 32768
MSW% = MSW% - 32768
ENDIF
// Write it to the correct parameter
Address% = BaseAddress% + 6
#Address% = ValueMSW%
7.4.5 Reading the parameter value
The required parameter value is read from two signed 16-bit values, these two values
must then be correctly merged to form the correct 32-bit value.
Base address + 5 (LSW)
The least significant word of the parameter value is read and converted from a signed
16-bit value and stored in a 32-bit variable, this value is then bitwise ANDed with the
hexadecimal value 0x0000FFFF.
If an error is indicated in the status value then this value will identify the cause of the
error.
Base address + 6 (MSW)
The most significant word of the parameter value is read and converted from a signed
16-bit value and stored in a 32-bit variable by bitwise shifting it 16 places left and
bitwise ANDing the result with the hexadecimal value 0x0000FFFF.
The actual value is then calculated by bitwise ORing the two words together.
If the source parameter was a 16-bit parameter and the most significant bit (b15) was
set to 1 (indicating a negative number) then the decimal value 65536 is subtracted.
BaseAddress% is the parameter specified in S.02.036