int eth32_set_pwm_parameters(eth32 handle, int channel, int state, float freq, float duty);
This function is provided for your convenience in working with all of the various PWM settings. It allows you to specify the PWM frequency and the duty cycle of a channel in more familiar terms (hertz and percentage) rather than PWM clock counts. It also puts the appropriate I/O pin into output mode unless you specify that the PWM channel should be disabled. This function internally calls several other API functions to set everything up, therefore replacing calls to eth32_set_pwm_base_period, eth32_set_pwm_duty_period, eth32_set_pwm_clock_state, eth32_set_pwm_channel, and eth32_set_direction_bit with a single call to this function.
handle - The value returned by the eth32_open function.
channel - Specifies the PWM channel number (0 or 1).
state - Specifies the new state for the PWM channel. This may be PWM_CHANNEL_DISABLED, PWM_CHANNEL_NORMAL, or PWM_CHANNEL_INVERTED.
freq - Specifies the frequency in Hertz. The valid range is 30.5 HZ to 40,000 HZ (40 KHZ)
duty - Specifies the duty cycle as a percentage (A floating point number from 0.0 to 1.0). This specifies the percentage of each cycle that the channel will be active.
This function returns zero on success and a negative error code on failure. Please see the Error Codes section for possible error codes.
Note that this function calls eth32_set_pwm_base_period to set the PWM base period. Because the PWM base period is shared between both PWM channels, this will affect the other PWM channel if you specify a frequency different than what is already in effect.
eth32 handle; int result; // .... Your code that establishes a connection here // Set up PWM channel 0 to have a 10 KHZ, 60% PWM signal: result=eth32_set_pwm_parameters(handle, 0, PWM_CHANNEL_NORMAL, 10000, 0.60); if(result) { // Handle error }