company profile news email HTI links
Highland logo
ENDIAN CONSIDERATIONS FOR THE V180/AT180


The V180 and AT180 electrical metering modules are used on the VME and PC/AT (ISA) busses respectively. The modules internally use a Motorola MC68332 microprocessor. The MC68332 and the VME bus use "high endian" architectures, in which more significant data is located first in memory, namely at numerically lower addresses. Intel x86 processors use "low endian" terminology, wherein less significant data appears first in memory. Sometimes Intel x86 machines are used as VMEbus masters, with or without the benefit of end-swapping hardware in the processor-to- VMEbus interface.

Some examples are...

Motorola:
16-bit integer 1234 hex (4660 decimal) is stored in memory as...
Location 1000 : 12 hex
1001 : 34 hex
32-bit integer 12345678 hex (305,419,896 decimal) is stored as...
Location
1000 : 12 hex
1001 : 34
1002 : 56
1003 : 78
Intel:
16-bit integer 1234 hex (4660 decimal) is stored in memory as...
Location 1000 : 34 hex
1001 : 12
32-bit integer 12345678 hex (305,419,896 decimal) is stored as...
Location 1000 : 78 hex
1001 : 56
1002 : 34
1003 : 12
In both cases, a text string "HELLO" would be stored as...
Location
1000 : H
1001 : E
1002 : L
1003 : L
1004 : O
Data is exchanged between the module and the external bus via a 16-bit wide dual-port memory which both the 68332 and the external bus can read and write. Bus bits are called "bit 15" through "bit 0", left-to-right, where bit 15 is the most significant. The bits (on either bus) are arranged as...
MS   LS
15 14 13 12 11 10 09 08 07 06 05 04 03 02 01 00
|-- Motorola byte 0 --|         |-- Motorola byte 1 --|

|----- Intel byte 1 ----|         |----- Intel byte 0 ----|
Consider three cases...

1. The 68332 measures 480.00 volts RMS and presents it to the dual-port memory as decimal integer 48000, hex 6680. The value 6680 is written to DPM as a single 16-bit word, and is read by either the VME or PC/AT bus as a single word. In this case, either bus reads the voltage correctly because a single 16-bit word transfer maintains the integrity of all 16 data bits (that is, all processors and busses agree that "bit 0" is the least significant bit, and "bit 15" is the most significant, and no bits are transposed in a word transfer.)

2. The 68332 measures a kilowatt-hour value of 20,000.00 KWH and presents it to DPM as 2,000,000 decimal, hex 001E8480. The hex value is written to DPM as a 32-bit integer, stored in two sequential 16-bit word addresses. If the first word (lowest address) is 001E and the second is 8480, then "high endian" processors (say, a 68000 VMEbus master) will consider the data to be correct, but an Intel processor on the PC/AT bus will consider the KWH data to be scrambled; it will interpret the value as 8480001E hex.

3. The V180/AT180 installs its default parameter set, and that set is read by an external processor. The parameter set contains both IEEE-format floating-point numbers and text strings. If the floaters were in Motorola format, they would appear to be word-swapped to an Intel processor, and Motorola-type text strings would appear scrambled ("AMPS" would look like "MASP").

The potential endian problems associated with use of the V180 and AT180 are resolved as follows:

A. The parameter set is always assumed to be in Intel (low endian) format. This is sensible, since the Highland PARSET.EXE program is nearly always used to create and manage parameter sets, and a V180/AT180 module can store and use a loaded parameter set indefinitely. The two data types in the parameter set which are order sensitive (namely IEEE floaters and text strings) are not actually used by the module, but are merely "along for the ride" scaling and point ID data, so their format is not important to the module. Should users desire to manage parameter sets using their own code, the floater and text fields may be used in any manner.

B. 16-bit module-generated data is presented to the bus as-is, and is read correctly in all cases.

C. 32-bit module-created data is order-sensitive, so must be edited according to the expectations of the host processor system. A parameter set flag is provided to control the endian presentation of such data. If the flag is ON, 32-bit data is delivered in high-endian (Motorola) format, and if the flag is OFF, data is in low-endian (Intel) form.

D. Some commands can transfer 32-bit data from the host bus to the V180/AT180, for example the "Load a KWH register" command. These commands also recognize the endian flag and adjust the data appropriately.