eth32_set_counter_rollover

int eth32_set_counter_rollover(eth32 handle, int counter, int rollover);

Summary

This function defines the maximum permissible value for a counter. After the counter reaches the given value, the next count will cause the counter to be reset to 0 and a rollover event notification will be sent to any connections that have enabled that rollover event. For example, with a rollover threshold set to 35, the counter value will progress as follows: ..., 33, 34, 35, 0, 1, ... Because the comparisons and reset are done directly in hardware, no counts are missed during a rollover.

The valid range of the rollover threshold is from 0 to the maximum value of the counter (65535 for 16-bit counter 0, and 255 for 8-bit counter 1). The powerup default rollover threshold is 255 for 8-bit and 65535 for 16-bit counters.

Parameters

  • handle - The value returned by the eth32_open function.

  • counter - Specifies the counter number (0 or 1).

  • rollover - Specifies the rollover point for the counter. This may be 0-65535 for counter 0, and 0-255 for counter 1.

Return Value

This function returns zero on success and a negative error code on failure. Please see the Error Codes section for possible error codes.

Remarks

There is one special case involving rollover thresholds. When the counter value is manually set to exactly the threshold value using the eth32_set_counter_value function, the rollover will NOT occur and the rollover event will NOT fire on the next counter increment. Instead, the counter will increment past the threshold value. The event will not fire until the counter value has wrapped around and again exceeds the threshold. For example, suppose the rollover threshold is set to 10 on an 8-bit counter and the eth32_set_counter_value function is used to set the counter value to 10. As the input line pulses, the counter value would increment as follows: 11, 12, ..., 255, 0, 1, ..., 10, 0, 1, ..., 10, 0, ...

Please note that defining a rollover threshold with this function does not enable the current connection to actually receive the rollover event notifications when they occur. These must be enabled separately using the eth32_enable_event function. Also note that rollover thresholds are common to all connections. Changing the thresholds will affect other connections if they are utilizing that particular counter.

See Also

eth32_get_counter_rollover, eth32_set_counter_state