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()
7878 if (rc != ONI_ESUCCESS)
7979 throw error_str (" Could not read the base frequency register on the DigitalIO device." );
8080
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 ;
8284 rc = deviceContext->writeRegister (deviceIdx, (uint32_t )DigitalIORegisters::SAMPLE_PERIOD, periodTicks);
8385 if (rc != ONI_ESUCCESS)
8486 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