You are here

GPIO_SET_CMP_CFG (0x0F)

The GPIO_SET_CMP_CFG command configures the GPIO-24 adaptor comparator module.

GPIO_SET_CMP_CFG Command

Go to Response

Byte 0 GPIO_SET_CMP_CFG Command ID (0x0F).
Byte 1 ECHO Echo to associate a command with the response.
Byte 2 CMP_CFG Bit 7 Reserved Reserved (must be 0).
Bit 6 CIS Comparator Input Switch bit.
Bit 5 CMP0_INV CMP0 comparator output inversion bit.
Bit 4 CMP1_INV CMP1 comparator output inversion bit.
Bit 3..0 MODE Operation mode for the USB-I/O adapter comparators.
Byte 3 VREF Bit 7 Reserved Reserved (must be 0).
Bit 6 OUTPUT CVREF output.
Bit 5 EXT_SOURCE Voltage source (internal or external).
Bit 4 RANGE Range of output values (CVREF).
Bits 3..0 MULTIPLIER  
Byte 4 REPEAT0_LSB Least significant bits of repeat interval value for CMP0 comparator.
Byte 5 REPEAT0_MSB / COND0 Bits 7..4 REPEAT0_MSB Most significant bits of repeat interval value for CMP0 comparator.
Bits 3..0 COND0 Low nibble of byte 5 defines when USB-I/O adapter sends events for CMP0 comparator.
Byte 6 REPEAT1_LSB Least significant bits of repeat interval value for CMP1 comparator.
Byte 7 REPEAT1_MSB / COND1 Bit 7..4 REPEAT1_MSB Most significant bits of repeat interval value for CMP1 comparator.
Bit 3..0 COND1 Low nibble of byte 5 defines when USB-I/O adapter sends events for CMP1 comparator.

Command is an 8-byte array of the following format:

Byte 0: GPIO_SET_CMP_CFG (0x0F)

This byte contains command ID (command type). It should be set to 0x0F.

Byte 1: ECHO

This byte is used to associate a response received from GPIO-24 adapter with a specific command. Response will contain exactly the same value in its echo byte.

Byte 2: CMP_CFG
Bit 7 Bit 6 Bit 5 Bit 4 Bit 3..0
Reserved CIS CMP0_INV CMP1_INV MODE
Bit 7: Reserved

This bit is reserved for future usage and must be set to 0.

Bit 6: CIS

Comparator Input Switch bit. The comparator input switch bit is used only in Four Inputs Multiplexed to Two Comparators mode (MODE = 6).

If CIS = 0:

  • C.1 pin is connected to CMP0 VIN-;

  • C.2 pin is connected to CMP1 VIN-.

If CIS = 1:

  • C.6 pin is connected to CMP0 VIN-;

  • C.5 pin is connected to CMP1 VIN-.

If CIS = 1 you cannot use C.5 pin as comparator reference voltage module output (Bit 6: OUTPUT of Byte 2: VREF). You also cannot use C.5 and C.6 pins as external voltage source (Bit 5: EXT_SOURCE of Byte 2: VREF) of comparator reference voltage module.

Bit 5: CMP0_INV

CMP0 comparator output inversion bit. Can be set for certain modes of operation for comparator module (MODE = 1, 2, 3, 4, 5 or 6).

If CMP0_INV = 1, CMP0 comparator output is inverted:

  • 1, if VIN+ < VIN-;

  • 0, if VIN+ > VIN-.

If CMP0_INV = 0, CMP0 comparator output is not inverted:

  • 1, if VIN+ > VIN-;

  • 0, if VIN+ < VIN-.

When C.4 I/O pin is used to output comparator results, its output is also inverted (MODE = 1, 3 or 5).

Bit 4: CMP1_INV

CMP1 comparator output inversion bit. Can be set for certain modes of operation for comparator module (MODE = 2, 3, 4, 5 or 6)

If CMP1_INV = 1, CMP1 comparator output is inverted:

  • 1, if VIN+ < VIN-;

  • 0, if VIN+ > VIN-.

If CMP1_INV = 0, CMP1 comparator output is not inverted:

  • 1, if VIN+ > VIN-;

  • 0, if VIN+ < VIN-.

When B.3 I/O pin is used to output comparator results, its output is also inverted (MODE = 3 or 5).

Bits 3-0: MODE

These bits are used to select an operation mode for the USB-I/O adapter comparators. There are eight operation modes described in Section 8.1, “Modes of operation for comparator module”.

Byte 3: VREF

This byte is used to configure comparator voltage reference module. For more detailed information see Section 8.2, “Comparator voltage reference module”.

The comparator voltage reference module is only available in Four Inputs Multiplexed to Two Comparators mode (MODE = 6). In other modes this byte must be set to 0.

Voltage reference module configuration (VREF) is a bit field of the following format:

Bit 7 Bit 6 Bit 5 Bit 4 Bit 3..0
Reserved OUTPUT EXT_SOURCE RANGE MULTIPLIER
Bit 7: Reserved

This bit is reserved for future usage and must be set to 0.

Bit 6: OUTPUT

Voltage reference module can also output the voltage reference (CVREF) onto C.5 I/O pin:

  • If OUTPUT = 1, CVREF is output on C.5 I/O pin;

  • If OUTPUT = 0, CVREF is disconnected from C.5 I/O pin.

You can use the C.5 pin to check the reference voltage with oscilloscope. It has limited current drive capability. Due to the limited current drive capability, a buffer must be used on the voltage reference output for external connections to CVREF.

If you switch on the CVREF output to C.5 pin, you cannot use it as:

  • external voltage source for the voltage reference module (Bit 5: EXT_SOURCE in Byte 3: VREF must be set to 0);

  • VIN- input of the CMP1 comparator (Bit 6: CIS in Byte 2: CMP_CFG must be set to 0).

Bit 5: EXT_SOURCE

The comparator reference voltage module’s power supply can be provided either from the GPIO-24 adapter VDD/VSS or from an external source.

  • If EXT_SOURCE = 1, the voltage reference module uses C.5 (VREF+) and C.6 (VREF-) pins as voltage source:

    CVRSRC = VREF+- VREF-

  • If EXT_SOURCE = 0, the voltage reference module uses USB-I/O adapter positive (VDD) and negative (VSS) supply as voltage source:

    CVRSRC = VDD – VSS

Bit 4: RANGE

The comparator voltage reference module provides two ranges of output voltage (CVREF), each with 16 distinct levels. The range is selected with Bit 4: RANGE. The primary difference between the ranges is the size of the steps selected with Bits 3-0: MULTIPLIER. That is why one range offers finer resolution but shorter interval of possible values (RANGE = 0). On contrary, the other range offers not so accurate value but in wider interval (RANGE = 1).

Bits 3-0: MULTIPLIER

With Bits 3-0: MULTIPLIER you can select the output voltage (CVREF) of voltage reference module.

Use the following equations to calculate the CVREF:

If RANGE = 1:

CVREF = (CVRSRC /24) x MULTIPLIER;

MULTIPLIER = 24* (CVREF/ CVRSRC).

If RANGE = 0:

CVREF = (CVRSRC /4) + ((CVRSRC /32) x MULTIPLIER);

MULTIPLIER = 32*( CVREF / CVRSRC) – 8.

The CVRSRC is selected with Bit 5: EXT_SOURCE.

Byte 4: REPEAT0_LSB

The bits of Byte 4: REPEAT0_LSB are 8 least significant bits of repeat interval value for CMP0 comparator. For more detailed information see Section 8.3, “Comparator module event”.

Byte 5: REPEAT0_MSB / COND0
Bits 7..4 Bits 3..0
REPEAT0_MSB COND0
Bits 7..4 REPEAT0_MSB

Bits 7..4 REPEAT0_MSB are 4 most significant bits of repeat interval value for CMP0 comparator. For more detailed information see Section 8.3, “Comparator module event”.

Bits 3..0 COND0

The low nibble of Byte 5 defines when USB-I/O adapter sends events (GPIO_EV_CMP) for CMP0 comparator:

GPIO_CMP_EV_NONE (0x00)

The comparator does not send events.

GPIO_CMP_EV_CHANGE (0x01)

The event is sent when the comparison result changes.

GPIO_CMP_EV_ALWAYS (0x02)

The event is sent periodically with the predefined repeat interval. This interval value is specified in Byte 4: REPEAT0_LSB (8 least significant bits) and Bits 7..4 REPEAT0_MSB in Byte 5 (4 most significant bits).

Byte 6: REPEAT1_LSB

The bits of Byte 6: REPEAT1_LSB are 8 least significant bits of repeat interval value for CMP1 comparator. For more detailed information see Section 8.3, “Comparator module event”.

Byte 7: REPEAT1_MSB / COND1
Bits 7..4 Bits 3..0
REPEAT1_MSB COND1
Bits 7..4 REPEAT1_MSB

Bits 7..4 REPEAT1_MSB are 4 most significant bits of repeat interval value for CMP1 comparator. For more detailed information see Section 8.3, “Comparator module event”.

Bits 3..0 COND1

The low nibble of byte 7 defines when USB-I/O adapter sends events (GPIO_EV_CMP) for CMP1 comparator:

GPIO_CMP_EV_NONE (0x00)

The comparator does not send events.

GPIO_CMP_EV_CHANGE (0x01)

The event is sent when the comparison result changes.

GPIO_CMP_EV_ALWAYS (0x02)

The event is sent periodically with the predefined repeat interval. This interval value is specified in Byte 6: REPEAT1_LSB (8 least significant bits) and Bits 7..4 REPEAT1_MSB in Byte 7 (4 most significant bits).

For convenience GPIO_SET_CMP_CFG_CMD structure is declared in reports.h file.

GPIO-24 adapter sends GPIO_SET_CMP_CFG response after command execution.

GPIO_SET_CMP_CFG Response

Go to Command

Byte 0 GPIO_SET_CMP_CFG Response ID (0x0F).
Byte 1 ECHO Echo to associate a command with the response.
Byte 2 ST Command execution status.
Bytes 3..7 Reserved Reserved

Response is an 8-byte array of the following format:

Byte 0: GPIO_SET_CMP_CFG (0x0F)

The response ID. It should be set to 0x0F.

Byte 1: ECHO

This byte is used to associate a response received from GPIO-24 adapter with a specific command. Response will contain exactly the same value in its echo byte.

Byte 2: ST

Command execution status:

  • GPIO_ST_SUCCESS (0x0) – GPIO-24 comparator module is successfully configured.

  • GPIO_ST_INVALID_CFG (0x4) – GPIO-24 comparator module configuration is invalid.

  • GPIO_ST_INVALID_CMP_MODE (0x9) – The value of GPIO-24 comparator module operation mode is incorrect.

Bytes 3..7: Reserved

These bytes are reserved for future usage.

For convenience GPIO_SET_CMP_CFG_RSP structure is declared in reports.h file.