We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 1bd8cf6 commit 425849dCopy full SHA for 425849d
1 file changed
Source/Devices/DigitalIO.cpp
@@ -78,7 +78,9 @@ int DigitalIO::configureDevice()
78
if (rc != ONI_ESUCCESS)
79
throw error_str("Could not read the base frequency register on the DigitalIO device.");
80
81
- uint32_t periodTicks = baseFreqHz / (uint32_t)AnalogIO::getSampleRate();
+ // 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;
84
rc = deviceContext->writeRegister(deviceIdx, (uint32_t)DigitalIORegisters::SAMPLE_PERIOD, periodTicks);
85
86
throw error_str("Could not write the sample rate for polling to the DigitalIO device.");
0 commit comments