Commit 78623870f4e18910448b9beed86b32911f1db3a2

Authored by Winged Unicorn
Committed by David Gräff
1 parent ff3bb8f3

Fix the [no] downsampler border case for DSO 2250.

downsampler == 1 means divide by one => no downsampling, use the base clocks.

On 2250, frequency divider is a 16-bit up-counter. It outputs a pulse on
overflow when enabled and reloads the value which was passed in
the ESETTRIGGERORSAMPLERATE command.

If you enable downsampler with ESETTRIGGERORSAMPLERATE and:
 - write 0xffff as a counter (0x10001 - 2), it will divide by 2
 - write 0xfffe as a counter (0x10001 - 3), it will divide by 3
 ....
 - write 0x0001 as a counter (0x10001 - 0), it will divide by 65535
 - write 0x0000 as a counter (0x10001 - 1), it will divide by 65536

Fixes #81
openhantek/src/hantekdso/hantekdsocontrol.cpp
@@ -531,11 +531,11 @@ unsigned HantekDsoControl::updateSamplerate(unsigned downsampler, bool fastRate) @@ -531,11 +531,11 @@ unsigned HantekDsoControl::updateSamplerate(unsigned downsampler, bool fastRate)
531 BulkSetSamplerate2250 *commandSetSamplerate2250 = 531 BulkSetSamplerate2250 *commandSetSamplerate2250 =
532 modifyCommand<BulkSetSamplerate2250>(BulkCode::ESETTRIGGERORSAMPLERATE); 532 modifyCommand<BulkSetSamplerate2250>(BulkCode::ESETTRIGGERORSAMPLERATE);
533 533
534 - bool downsampling = downsampler >= 1; 534 + bool downsampling = downsampler > 1;
535 // Store downsampler state value 535 // Store downsampler state value
536 commandSetSamplerate2250->setDownsampling(downsampling); 536 commandSetSamplerate2250->setDownsampling(downsampling);
537 // Store samplerate value 537 // Store samplerate value
538 - commandSetSamplerate2250->setSamplerate(downsampler > 1 ? 0x10001 - downsampler : 0); 538 + commandSetSamplerate2250->setSamplerate(downsampling ? 0x10001 - downsampler : 0);
539 // Set fast rate when used 539 // Set fast rate when used
540 commandSetSamplerate2250->setFastRate(fastRate); 540 commandSetSamplerate2250->setFastRate(fastRate);
541 541