The GPIO_SET_CMP_CFG command configures the GPIO-24 adaptor comparator module.
| 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:
This byte contains command ID (command type). It should be set to 0x0F.
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.
This bit is reserved for future usage and must be set to 0.
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-.
C.6 pin is connected to CMP0 VIN-;
C.5 pin is connected to CMP1 VIN-.
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-.
1, if VIN+ > VIN-;
0, if VIN+ < VIN-.
I/O pin is
used to output comparator results, its output is also
inverted (MODE =
1, 3 or 5).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-.
1, if VIN+ > VIN-;
0, if VIN+ < VIN-.
I/O pin is
used to output comparator results, its output is also
inverted (MODE =
3 or 5).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”.
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 |
This bit is reserved for future usage and must be set to 0.
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.
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).
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
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).
With Bits 3-0: MULTIPLIER you can select the output voltage (CVREF) of voltage reference module.
Use the following equations to calculate the CVREF:
CVREF = (CVRSRC /24) x MULTIPLIER;
MULTIPLIER = 24* (CVREF/ CVRSRC).
CVREF = (CVRSRC /4) + ((CVRSRC /32) x MULTIPLIER);
MULTIPLIER = 32*( CVREF / CVRSRC) – 8.
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”.
| Bits 7..4 | Bits 3..0 |
|---|---|
| REPEAT0_MSB | COND0 |
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”.
The low nibble of Byte 5 defines when USB-I/O adapter sends events (GPIO_EV_CMP) for CMP0
comparator:
The comparator does not send events.
The event is sent when the comparison result changes.
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).
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”.
| Bits 7..4 | Bits 3..0 |
|---|---|
| REPEAT1_MSB | COND1 |
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”.
The low nibble of byte 7 defines when USB-I/O adapter sends events (GPIO_EV_CMP) for CMP1
comparator:
The comparator does not send events.
The event is sent when the comparison result changes.
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.
| 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:
The response ID. It should be set to 0x0F.
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.
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.
These bytes are reserved for future usage.
For convenience GPIO_SET_CMP_CFG_RSP structure is declared in reports.h file.