Mercurial > hg > beaglert
changeset 147:e9a2f31dff7b ClockSync
Something weird happened when pllP=8, so I set pllP=7, which reduces (a bit) the clock adjustment precision
author | Giulio Moro <giuliomoro@yahoo.it> |
---|---|
date | Tue, 15 Sep 2015 02:01:15 +0100 |
parents | 0a5a94de9dd0 |
children | 6cd38e261027 |
files | core/I2c_Codec.cpp |
diffstat | 1 files changed, 6 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/core/I2c_Codec.cpp Mon Sep 14 21:39:54 2015 +0100 +++ b/core/I2c_Codec.cpp Tue Sep 15 02:01:15 2015 +0100 @@ -47,9 +47,11 @@ // The master clock PLLCLK_IN is 12MHz // K can be varied in intervals of resolution of 0.0001 up to 63.9999 // using P=8 and R=1 gives a resolution of 0.0732421875Hz ( 0.000166% at 44.1kHz) + // for whatever reason, P=8 does not work (i.e.: setting the sampling rate works fine, + // but when changing K by a small-ish value (0.0040), the clock does not seem to change). // to obtain Fs=44100 we need to have K=60.2112 - if(setPllP(8)) + if(setPllP(7)) return 1; if(setPllR(1)) return 1; @@ -217,7 +219,9 @@ long int PLLCLK_IN=12000000; // f_{S(ref)} = (PLLCLK_IN × K × R)/(2048 × P) float k = ((double)(newSamplingRate * pllP * 2048.0f/(float)pllR)) / PLLCLK_IN ; - return (setPllK(k)); + int ret = setPllK(k); +// printf("P: %d, R: %d, J: %d, D: %d\n", pllP, pllR, pllJ, pllD); + return ret; } short unsigned int I2c_Codec::getPllJ(){