Hi Uwe, hi sigrok team,
The initial setting of the calibration frequency output (1 kHz)of the
FX2-based scopes is ok, but as soon as the user sets the frequency via
'set_calibration_pulse()' the output frequency is only half the
requested value, probably due to a recent change of CPU_FREQ from 24 to
12 MHz. The settings of RCAP2 must be half as big (see also
https://github.com/sigrokproject/sigrok-firmware-fx2lafw/commit/14728a53624f000db0fa8388ecdb8b021250322b).
Martin
PFA the patch that fixes the behaviour and adds also more frequency
choices (this is used in my OpenHantek6022 project).
--- a/include/scope.inc
+++ b/include/scope.inc
@@ -263,24 +263,54 @@ static BOOL set_samplerate(BYTE rate)
}
static BOOL set_calibration_pulse(BYTE fs)
-{
+{ // values for CLK_12M
switch (fs) {
- case 0: // 100Hz
+ case 105: // 50Hz
RCAP2L = -10000 & 0xff;
RCAP2H = (-10000 & 0xff00) >> 8;
return TRUE;
- case 1: // 1kHz
+ case 106: // 60Hz
+ RCAP2L = -8333 & 0xff;
+ RCAP2H = (-8333 & 0xff00) >> 8;
+ return TRUE;
+ case 0: // 100Hz
+ case 110: // 100Hz
+ RCAP2L = -5000 & 0xff;
+ RCAP2H = (-5000 & 0xff00) >> 8;
+ return TRUE;
+ case 120: // 200Hz
+ RCAP2L = -2500 & 0xff;
+ RCAP2H = (-2500 & 0xff00) >> 8;
+ return TRUE;
+ case 150: // 500Hz
RCAP2L = -1000 & 0xff;
RCAP2H = (-1000 & 0xff00) >> 8;
return TRUE;
- case 10: // 1kHz
- RCAP2L = (BYTE)(-100 & 0xff);
+ case 1: // 1kHz
+ RCAP2L = -500 & 0xff;
+ RCAP2H = (-500 & 0xff00) >> 8;
+ return TRUE;
+ case 2: // 2kHz
+ RCAP2L = -250 & 0xff;
+ RCAP2H = (-250 & 0xff00) >> 8;
+ return TRUE;
+ case 5: // 5kHz
+ RCAP2L = -100 & 0xff;
+ RCAP2H = (-100 & 0xff00) >> 8;
+ return TRUE;
+ case 10: // 10kHz
+ RCAP2L = (BYTE)(-50 & 0xff);
RCAP2H = 0xff;
return TRUE;
- case 50: // 50kHz
- RCAP2L = (BYTE)(-20 & 0xff);
+ case 20: // 20kHz
+ RCAP2L = (BYTE)(-25 & 0xff);
RCAP2H = 0xff;
return TRUE;
+// setting for 50 kHz doesn't work, gives 25 kHz (interrupt fires too often?)
+// case 50: // 50kHz
+// RCAP2L = (BYTE)(-10 & 0xff);
+// RCAP2H = 0xff;
+// return TRUE;
default:
return FALSE;
}
_______________________________________________
sigrok-devel mailing list
sigrok-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/sigrok-devel