code/WPILib/DigitalModule.cpp
/**
 * Configure the duty-cycle of the PWM generator
 * @param pwmGenerator The generator index reserved by AllocateDO_PWM()
 * @param dutyCycle The percent duty cycle to output [0..1].
 */
Configure the duty-cycle of the PWM generator
@param pwmGenerator The generator index reserved by AllocateDO_PWM()
@param dutyCycle The percent duty cycle to output [0..1].
Configure the duty - cycle of the PWM generator @param pwmGenerator The generator index reserved by AllocateDO_PWM () @param dutyCycle The percent duty cycle to output [ 0 .. 1 ] .
void DigitalModule::SetDO_PWMDutyCycle(UINT32 pwmGenerator, float dutyCycle)
{
	if (pwmGenerator == ~0ul) return;
	if (dutyCycle > 1.0) dutyCycle = 1.0;
	if (dutyCycle < 0.0) dutyCycle = 0.0;
	float rawDutyCycle = 256.0 * dutyCycle;
	if (rawDutyCycle > 255.5) rawDutyCycle = 255.5;
	UINT8 pwmPeriodPower = m_fpgaDIO->readDO_PWMConfig_PeriodPower(&status);
	if (pwmPeriodPower < 4)
	{
		rawDutyCycle = rawDutyCycle / pow(2.0, 4 - pwmPeriodPower);
	}
	m_fpgaDIO->writeDO_PWMDutyCycle(pwmGenerator, (UINT8)rawDutyCycle, &status);
	wpi_assertCleanStatus(status);
}
void DigitalModule :: SetDO_PWMDutyCycle ( UINT32 pwmGenerator , float dutyCycle ) { if ( pwmGenerator == ~ 0ul ) return ; if ( dutyCycle > 1.0 ) dutyCycle = 1.0 ; if ( dutyCycle < 0.0 ) dutyCycle = 0.0 ; float rawDutyCycle = 256.0 * dutyCycle ; if ( rawDutyCycle > 255.5 ) rawDutyCycle = 255.5 ; UINT8 pwmPeriodPower = m_fpgaDIO -> readDO_PWMConfig_PeriodPower ( & status ) ; if ( pwmPeriodPower < 4 ) { rawDutyCycle = rawDutyCycle / pow ( 2.0 , 4 - pwmPeriodPower ) ; } m_fpgaDIO -> writeDO_PWMDutyCycle ( pwmGenerator , ( UINT8 ) rawDutyCycle , & status ) ; wpi_assertCleanStatus ( status ) ; }
Configure the duty-cycle of the PWM generator
 @param pwmGenerator The generator index reserved by AllocateDO_PWM()
 @param dutyCycle The percent duty cycle to output [0..1].
Configure the duty - cycle of the PWM generator @param pwmGenerator The generator index reserved by AllocateDO_PWM () @param dutyCycle The percent duty cycle to output [ 0 .. 1 ] .
// The resolution of the duty cycle drops close to the highest frequencies.