hil_set_analog_output_ranges hil_set_clock_mode navigation bar

Table of Contents

hil_set_clock_frequency

Sets the frequencies of the given hardware clocks.

Description

The hil_set_clock_frequency function sets the frequencies of the given hardware clocks. This function is typically used in conjunction with hil_set_card_specific_options to program a counter to drive some other function of the card, such as A/D conversions.

Prototype

t_error
hil_set_clock_frequency(t_card card, const t_clock clocks[], t_uint32 num_clocks, const t_double clock_frequencies[]);
    

Parameters

t_card card

A handle to the board, as returned by hil_open.

const t_clock * clocks

An array containing the clocks whose frequencies will be changed. System clocks do not support different frequencies so only hardware clocks, such as HARDWARE_CLOCK_0, should be specified.

Select a board type from the list for board-specific details: .

t_uint32 num_clocks

The number of clocks specified in the clocks and clock_frequencies arrays.

const t_double * clock_frequencies

An array of frequencies, in Hertz, to which to set the clocks. Each element in the clock_frequencies array corresponds to the same element in the clocks array. Hence, there must be as many elements in the clock_frequencies array as there are clocks. If a frequency of zero is specified for any element then that clock is disabled.

Return value

The return value is 0 if the clock frequencies are set successfully. Otherwise a negative error code is returned. Error codes are defined in quanser_errors.h. A suitable error message may be retrieved using msg_get_error_message.

Error codes

QERR_HIL_SET_CLOCK_FREQUENCY_NOT_SUPPORTED

This function is not supported by the board-specific HIL driver for this board type.

QERR_INVALID_CARD_HANDLE

An invalid card handle was passed as an argument. Once a card has been closed using hil_close the card handle is invalid.

QERR_TOO_MANY_CLOCKS

Too many clocks were specified.

QERR_CLOCK_NOT_SUPPORTED

One of the clocks that was specified is not a valid clock. Clock numbers range from 0 to one less than the number of hardware clocks.

QERR_CLOCK_FREQUENCY_TOO_LOW

One of the clock frequencies that was specified was too low for the corresponding clock. Clock frequencies of zero are a special case and do not generate this error.

QERR_CLOCK_FREQUENCY_TOO_HIGH

One of the clock frequencies that was specified was too high for the corresponding clock.

QERR_HARDWARE_CLOCK_IN_USE

One of the specified clocks is already in use for another operation and the board-specific HIL driver for this board does not permit sharing of the hardware clock.

Requirements

Include Files

Libraries

hil.h

hil.lib;quanser_runtime.lib;quanser_common.lib

Examples

/* Set HARDWARE_CLOCK_0 to 1 MHz. */
t_uint32 clocks[] = { HARDWARE_CLOCK_0 };
t_int32 frequencies[] = { 1e6 };
t_error result = hil_set_clock_frequency(board, clocks, ARRAY_LENGTH(clocks), frequencies);
    

See Also

 

navigation bar