summaryrefslogtreecommitdiffstats
path: root/app/pll.c
diff options
context:
space:
mode:
Diffstat (limited to 'app/pll.c')
-rw-r--r--app/pll.c35
1 files changed, 30 insertions, 5 deletions
diff --git a/app/pll.c b/app/pll.c
index 43fb9ad..5fa370e 100644
--- a/app/pll.c
+++ b/app/pll.c
@@ -2,7 +2,7 @@
#define JUMP_THRESH 0.1
#define JUMP_TICKS 30
-#define FEEDBACK 0.01
+#define FEEDBACK 0.001
#define WARM_UP 3
@@ -47,7 +47,7 @@ static void modify_pll_freq (uint64_t now, int d)
phase = now - pd2;
}
-void pll_dispatch (uint64_t edge)
+void pll_dispatch (uint64_t happy, uint64_t edge, const char *src)
{
double f;
int64_t pd;
@@ -58,6 +58,32 @@ void pll_dispatch (uint64_t edge)
}
+#if 0
+ {
+ int h1, h2, h3, h4;
+ EPOCH e;
+
+
+ e = pll_decompose (happy);
+ h1 = e.s;
+ e = pll_decompose (gps_last_happy);
+ h2 = e.s;
+ e = pll_decompose (dcf77_last_happy);
+ h3 = e.s;
+ e = pll_decompose (msf_last_happy);
+ h4 = e.s;
+
+ printf ("H %d %d %d %d\r\n", h1 - h2, h2 - h2, h3 - h2, h4 - h2);
+ }
+#endif
+
+
+ if (happy < gps_last_happy) return;
+
+ if (happy < dcf77_last_happy) return;
+
+ if (happy < msf_last_happy) return;
+
{
int diff, hf;
@@ -81,9 +107,7 @@ void pll_dispatch (uint64_t edge)
else if (out_of_lock <= JUMP_TICKS)
out_of_lock = 0;
-#if 1
- printf ("PLL pd %.3f pll_freq %d phase %d\r\n", (float) f, (int) pll_freq, (int) phase);
-#endif
+ printf ("PLL pd %.3f pll_freq %d phase %d %s\r\n", (float) f, (int) pll_freq, (int) phase, src);
if (out_of_lock > JUMP_TICKS) {
phase += pd;
@@ -108,6 +132,7 @@ void pll_set_offset (EPOCH epoch, uint64_t abs)
int64_t new_offset;
int diff;
+
/* Find nearest second to abs*/
abs += pll_freq >> 2;
abs -= phase;