Mercurial > hg > beaglert
diff core/I2c_Codec.cpp @ 151:e9c9404e3d1f ClockSync
Pff partially working. No PID. When setting the audio clock on the bbb to 44098 the master and slave clock keep diverging instead of converging ...
author | Giulio Moro <giuliomoro@yahoo.it> |
---|---|
date | Tue, 22 Sep 2015 04:10:07 +0100 |
parents | 134bff10e561 |
children |
line wrap: on
line diff
--- a/core/I2c_Codec.cpp Tue Sep 22 04:09:13 2015 +0100 +++ b/core/I2c_Codec.cpp Tue Sep 22 04:10:07 2015 +0100 @@ -49,7 +49,7 @@ // using P=8 and R=1 gives a resolution of 0.0732421875Hz ( 0.000166% at 44.1kHz) // to obtain Fs=44100 we need to have K=60.2112 - if(setPllP(7)) + if(setPllP(1)) return 1; if(setPllR(1)) return 1; @@ -218,9 +218,9 @@ // f_{S(ref)} = (PLLCLK_IN × K × R)/(2048 × P) float k = ((double)(newSamplingRate * pllP * 2048.0f/(float)pllR)) / PLLCLK_IN ; int ret = setPllK(k); - float actualSamplingRate = PLLCLK_IN * (pllJ + pllD/10000.0) * pllR / (2048.0 * pllP); - printf("P: %d, R: %d, J: %d, D: %d, samplingRate= %f\n", pllP, pllR, pllJ, pllD, actualSamplingRate ); -// printf("fs_ref=%f;\n",actualSamplingRate); +// printf("P: %d, R: %d, J: %d, D: %d, samplingRate= %f\n", pllP, pllR, pllJ, pllD, getAudioSamplingRate()); +// printf("fs_ref=%f;\n",getAudioSamplingRate()); +// printf("0 0 0 0 0 0\n"); return ret; } @@ -243,7 +243,7 @@ return k; } -float I2c_Codec::getAudioSamplingRate(){ +double I2c_Codec::getAudioSamplingRate(){ int pllP=1; //TODO: create get/set for pllP and pllR int pllR=1; long int PLLCLK_IN=12000000;