File tree Expand file tree Collapse file tree 1 file changed +3
-1
lines changed Expand file tree Collapse file tree 1 file changed +3
-1
lines changed Original file line number Diff line number Diff line change @@ -78,7 +78,9 @@ int DigitalIO::configureDevice()
78
78
if (rc != ONI_ESUCCESS)
79
79
throw error_str (" Could not read the base frequency register on the DigitalIO device." );
80
80
81
- uint32_t periodTicks = baseFreqHz / (uint32_t )AnalogIO::getSampleRate ();
81
+ // NB: Two states are not accounted for when comparing clock ticks on the hardware,
82
+ // therefore the periodTicks variable must be decreased by 2 to get the correct sample rate.
83
+ uint32_t periodTicks = (baseFreqHz / (uint32_t )AnalogIO::getSampleRate ()) - 2u ;
82
84
rc = deviceContext->writeRegister (deviceIdx, (uint32_t )DigitalIORegisters::SAMPLE_PERIOD, periodTicks);
83
85
if (rc != ONI_ESUCCESS)
84
86
throw error_str (" Could not write the sample rate for polling to the DigitalIO device." );
You can’t perform that action at this time.
0 commit comments