# HG changeset patch # User Giulio Moro # Date 1442263194 -3600 # Node ID 0a5a94de9dd0504e2341050ef4cfcc10b5bff796 # Parent 55c1e591cb2eb66d7d9807a3ea887adc4a236f9d# Parent 8ff5668bbbad3430da6101935635852a1abbfc8e Merge diff -r 55c1e591cb2e -r 0a5a94de9dd0 .cproject --- a/.cproject Mon Sep 14 21:31:09 2015 +0100 +++ b/.cproject Mon Sep 14 21:39:54 2015 +0100 @@ -14,11 +14,11 @@ - + - + @@ -31,6 +31,8 @@ @@ -45,8 +47,10 @@ @@ -108,13 +114,13 @@ - + - + - + diff -r 55c1e591cb2e -r 0a5a94de9dd0 core/I2c_Codec.cpp --- a/core/I2c_Codec.cpp Mon Sep 14 21:31:09 2015 +0100 +++ b/core/I2c_Codec.cpp Mon Sep 14 21:39:54 2015 +0100 @@ -43,20 +43,33 @@ // see datasehet for TLV320AIC3104 from page 44 if(writeRegister(0x02, 0x00)) // Codec sample rate register: fs_ref / 1 return 1; + // The sampling frequency is given as f_{S(ref)} = (PLLCLK_IN × K × R)/(2048 × P) + // 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) + // to obtain Fs=44100 we need to have K=60.2112 + + if(setPllP(8)) + return 1; + if(setPllR(1)) + return 1; + if(setAudioSamplingRate(44100)) //this will automatically find and set K for the given P and R so that Fs=44100 + return 1; // if(writeRegister(0x03, 0x91)) // PLL register A: enable // return 1; - if(setPllP(1)) - return 1; // if(writeRegister(0x04, 0x1C)) // PLL register B // return 1; // if(writeRegister(0x05, 0x52)) // PLL register C // return 1; // if(writeRegister(0x06, 0x40)) // PLL register D // return 1; - if(setPllD(5264)) //7.5264 gives 44.1kHz nominal value with a 12MHz master clock - return 1; - if(setPllJ(7)) - return 1; +// if(writeRegister(0x0B, 0x01)) // Audio codec overflow flag register: PLL R = 1 +// return 1; + +// if(setPllD(5264)) //7.5264 gives 44.1kHz nominal value with a 12MHz master clock +// return 1; +// if(setPllJ(7)) +// return 1; if(dual_rate) { if(writeRegister(0x07, 0xEA)) // Codec datapath register: 44.1kHz; dual rate; standard datapath return 1; @@ -71,10 +84,6 @@ return 1; if(writeRegister(0x0A, 0x00)) // Audio serial control register C: 0 bit offset return 1; -// if(writeRegister(0x0B, 0x01)) // Audio codec overflow flag register: PLL R = 1 -// return 1; - if(setPllR(1)) - return 1; if(writeRegister(0x0C, 0x00)) // Digital filter register: disabled return 1; if(writeRegister(0x0D, 0x00)) // Headset / button press register A: disabled @@ -205,8 +214,6 @@ return 0; } int I2c_Codec::setAudioSamplingRate(float newSamplingRate){ - int pllP=getPllP(); //TODO: create get/set for pllP and pllR - int pllR=1; 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 ; diff -r 55c1e591cb2e -r 0a5a94de9dd0 include/I2c_Codec.h --- a/include/I2c_Codec.h Mon Sep 14 21:31:09 2015 +0100 +++ b/include/I2c_Codec.h Mon Sep 14 21:39:54 2015 +0100 @@ -25,7 +25,6 @@ short unsigned int pllD; short unsigned int pllP; short unsigned int pllR; - short unsigned int anotherField; public: int writeRegister(unsigned int reg, unsigned int value);