summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorfishsoupisgood <github@madingley.org>2019-02-21 13:18:34 +0000
committerfishsoupisgood <github@madingley.org>2019-02-21 13:18:34 +0000
commite761edee5e8ef7106fc8080fc386447e7956be71 (patch)
treebba377795294a958501ee3ebbcb30d2064a80c13
parentc93861c733ced9c6659241cea69c7feed56afcce (diff)
downloadclock-e761edee5e8ef7106fc8080fc386447e7956be71.tar.gz
clock-e761edee5e8ef7106fc8080fc386447e7956be71.tar.bz2
clock-e761edee5e8ef7106fc8080fc386447e7956be71.zip
add edge magic
-rw-r--r--app/main.c1
-rw-r--r--app/pll.c20
-rw-r--r--app/project.h3
3 files changed, 17 insertions, 7 deletions
diff --git a/app/main.c b/app/main.c
index 6116a5b..703d366 100644
--- a/app/main.c
+++ b/app/main.c
@@ -49,6 +49,7 @@ static void
board_setup (void)
{
rcc_osc_bypass_enable (HSE);
+ RCC_SSCGR=0;
rcc_clock_setup_hse_3v3 (&hse_10mhz_3v3_168);
rcc_periph_clock_enable (RCC_SYSCFG);
diff --git a/app/pll.c b/app/pll.c
index 5fa370e..944e6cc 100644
--- a/app/pll.c
+++ b/app/pll.c
@@ -2,8 +2,8 @@
#define JUMP_THRESH 0.1
#define JUMP_TICKS 30
-#define FEEDBACK 0.001
-#define WARM_UP 3
+#define FEEDBACK 0.01
+#define WARM_UP 30
static int64_t offset;
@@ -47,15 +47,12 @@ static void modify_pll_freq (uint64_t now, int d)
phase = now - pd2;
}
+
void pll_dispatch (uint64_t happy, uint64_t edge, const char *src)
{
double f;
int64_t pd;
- if (warming_up) {
- warming_up--;
- return;
- }
#if 0
@@ -78,12 +75,23 @@ void pll_dispatch (uint64_t happy, uint64_t edge, const char *src)
#endif
+if ((!gps_last_happy) && (!dcf77_last_happy) && (!msf_last_happy)) return;
+
if (happy < gps_last_happy) return;
if (happy < dcf77_last_happy) return;
if (happy < msf_last_happy) return;
+ if (warming_up) {
+ warming_up--;
+ return;
+ }
+
+printf("EDGE %08x%08x\r\n",
+ (uint32_t) (edge >>32),
+ (uint32_t) (edge & 0xffffffff));
+
{
int diff, hf;
diff --git a/app/project.h b/app/project.h
index fa8d5b2..d19cd61 100644
--- a/app/project.h
+++ b/app/project.h
@@ -42,7 +42,8 @@
#include "prototypes.h"
-#define HZ 168000000
+#define HZ 167999973
+//#define HZ 168000000
//#define HZ 167968615
//#define HZ 165925490
//#define HZ 167996682