From e761edee5e8ef7106fc8080fc386447e7956be71 Mon Sep 17 00:00:00 2001 From: fishsoupisgood Date: Thu, 21 Feb 2019 13:18:34 +0000 Subject: add edge magic --- app/main.c | 1 + app/pll.c | 20 ++++++++++++++------ app/project.h | 3 ++- 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 -- cgit v1.2.3