delsauce / ArduinoDueHiFi

An I2S audio codec driver library for the Arduino Due board.
42 stars 10 forks source link

Hook up guide for WM8731 #7

Open sriranjanr opened 9 years ago

sriranjanr commented 9 years ago

Hello,

I am trying to work with WM8731. Is there a hook up guide to arduino due which is running your Hi-Fi lib. If you could provide in formation on which pins to connect to Due or a table indicating that then it would be great. I have seen the other issue pertaining to WM8731 where in he uses the codec from Mikro and another library for configuring the WM8731 using I2C but I dont think that connection tells about the HiFi libs connections because as you mentioned HiFi uses SSC pins.But there are only two SSC pins on the Due , so what about the other pins on the codec shield. I am using the codec shield from Sparkfun.

michael-hirschmugl commented 9 years ago

WM8731 <-> ARDUINO DUE BCLK - Pin 3 <-> TK - Pin 7 DACDAT - Pin 4 <-> TD - Pin 78 DACLRC - Pin 5 <-> TF - Pin 8 BCLK - Pin 3 <-> RK - Pin 90 ADCDAT - Pin 6 <-> RD - Pin 89 ADCLRC - Pin 7 <-> RF - Pin 88

don't forget to use a resistor of about 220 Ohm between signals. :) I will upload a dedicated library and documentation for he WM8731 soon. I had a lot of issues with this chip...

benbiles commented 8 years ago

Hi Hirschmensch!

I have a Mikroe-506 with this codec wired up to DUE with working I2C control but passthough not working in passthrough example

I have noticed the CLKOUT 12.288mhz pin on this board is left floating, I could solder on a wire for 12.288mhz MCLK but to which pin should MCLK go to on the the DUE or its not needed?

Is this library finding MCLK by multiplying BCLK with ... ?

Either way , its not working for me ! are you any nearer to getting the Passthrough example working with codec ?

benbiles commented 8 years ago

EDIT: ok this is working now :) I'll paste the code below Mikroe-506 pin connections are above.

Why and who would design the Mikroe-506 without Line inputs connected etc I will nver know :)

I am getting on the scope using 220ohm resistors in series on all outputs. ( looks cleaner on scope )

I am using 48khz 32bit.

3.0722mhz on BCLK TK - Pin 7 TF - Pin 8

48.0034khz on
DACLRC , TF - Pin 8 ADCLRC
RF - Pin 88

370khz data DACDAT TD - Pin 78 ADCDAT RD - Pin 89

Here is my code,

`// Initialize the WM8731 Serial.println( "Initializing" ); delay(10);

Wire.begin(); Wire.beginTransmission(0x1e); Wire.write(0x1e); // reset reg Wire.write(B00000000); // do reset Wire.endTransmission();

// delay(50);

Wire.begin(); Wire.beginTransmission(0x1a); Wire.write(0x0c); // power reduction register Wire.write(0x00); // turn everything on Wire.endTransmission();

delay(10);

Wire.beginTransmission(0x1a); Wire.write(0x0e); // digital data format REG 00001110 0x0e

if BIT_RATE == 32

Wire.write(0x72); // 32bit,MASTER MODE 01110010 left justified

elif BIT_RATE == 24

Wire.write(0x62); // 24bit,MASTER MODE 01100010 left justified

elif BIT_RATE == 16

Wire.write(0x42); // 16bit,MASTER MODE 01000010 left justified

endif

Wire.endTransmission();

delay(10);

Wire.beginTransmission(0x1a);

Wire.write(0x10); // clock configuration

if SAMPLE_RATE == 88

Wire.write(0xbc);

elif SAMPLE_RATE == 48

Wire.write(0x00);

elif SAMPLE_RATE == 44

Wire.write(0xa0);

elif SAMPLE_RATE == 22

Wire.write(0xe0);

elif SAMPLE_RATE == 8

Wire.write(0xac);

elif SAMPLE_RATE == 2

Wire.write(0xce);

endif

Wire.endTransmission();

delay(10);

Wire.beginTransmission(0x1a); Wire.write(0x12); // digital interface active Wire.write(0x01); Wire.endTransmission();

delay(10);

Wire.beginTransmission(0x1a);

Wire.write(0x0a); // digital audio path configuration Wire.write((uint8_t)ADCHPD); Wire.endTransmission();

delay(10);

Wire.beginTransmission(0x1a); Wire.write(0x00); // left in setup register Wire.write((uint8_t)LINVOL); Wire.endTransmission();

delay(10);

Wire.beginTransmission(0x1a); Wire.write(0x02); // right in setup register Wire.write((uint8_t)RINVOL); Wire.endTransmission();

delay(10);

Wire.beginTransmission(0x1a); Wire.write(0x04); // left headphone out register Wire.write((uint8_t)LHPVOL); Wire.endTransmission();

delay(10);

Wire.beginTransmission(0x1a); Wire.write(0x06); // right headphone out register Wire.write((uint8_t)RHPVOL); Wire.endTransmission();

delay(10);

Wire.beginTransmission(0x1a); Wire.write(0x08); // analog audio pathway configuration Wire.write((uint8_t)((SIDEATT << 6) | (SIDETONE << 5) | (DACSEL << 4) | (BYPASS << 3) | (INSEL << 2) | (MUTEMIC << 1) | (MICBOOST << 0))); Wire.endTransmission();

delay(50);

Serial.println( "done" ); } // end initialisecodec`

niradat commented 4 years ago

EDIT: ok this is working now :) I'll paste the code below Mikroe-506 pin connections are above.

Why and who would design the Mikroe-506 without Line inputs connected etc I will nver know :)

I am getting on the scope using 220ohm resistors in series on all outputs. ( looks cleaner on scope )

I am using 48khz 32bit.

3.0722mhz on BCLK TK - Pin 7 TF - Pin 8

48.0034khz on DACLRC , TF - Pin 8 ADCLRC RF - Pin 88

370khz data DACDAT TD - Pin 78 ADCDAT RD - Pin 89

Here is my code,

`// Initialize the WM8731 Serial.println( "Initializing" ); delay(10);

Wire.begin(); Wire.beginTransmission(0x1e); Wire.write(0x1e); // reset reg Wire.write(B00000000); // do reset Wire.endTransmission();

// delay(50);

Wire.begin(); Wire.beginTransmission(0x1a); Wire.write(0x0c); // power reduction register Wire.write(0x00); // turn everything on Wire.endTransmission();

delay(10);

Wire.beginTransmission(0x1a); Wire.write(0x0e); // digital data format REG 00001110 0x0e

if BIT_RATE == 32

Wire.write(0x72); // 32bit,MASTER MODE 01110010 left justified

elif BIT_RATE == 24

Wire.write(0x62); // 24bit,MASTER MODE 01100010 left justified

elif BIT_RATE == 16

Wire.write(0x42); // 16bit,MASTER MODE 01000010 left justified

endif

Wire.endTransmission();

delay(10);

Wire.beginTransmission(0x1a);

Wire.write(0x10); // clock configuration

if SAMPLE_RATE == 88

Wire.write(0xbc);

elif SAMPLE_RATE == 48

Wire.write(0x00);

elif SAMPLE_RATE == 44

Wire.write(0xa0);

elif SAMPLE_RATE == 22

Wire.write(0xe0);

elif SAMPLE_RATE == 8

Wire.write(0xac);

elif SAMPLE_RATE == 2

Wire.write(0xce);

endif

Wire.endTransmission();

delay(10);

Wire.beginTransmission(0x1a); Wire.write(0x12); // digital interface active Wire.write(0x01); Wire.endTransmission();

delay(10);

Wire.beginTransmission(0x1a);

Wire.write(0x0a); // digital audio path configuration Wire.write((uint8_t)ADCHPD); Wire.endTransmission();

delay(10);

Wire.beginTransmission(0x1a); Wire.write(0x00); // left in setup register Wire.write((uint8_t)LINVOL); Wire.endTransmission();

delay(10);

Wire.beginTransmission(0x1a); Wire.write(0x02); // right in setup register Wire.write((uint8_t)RINVOL); Wire.endTransmission();

delay(10);

Wire.beginTransmission(0x1a); Wire.write(0x04); // left headphone out register Wire.write((uint8_t)LHPVOL); Wire.endTransmission();

delay(10);

Wire.beginTransmission(0x1a); Wire.write(0x06); // right headphone out register Wire.write((uint8_t)RHPVOL); Wire.endTransmission();

delay(10);

Wire.beginTransmission(0x1a); Wire.write(0x08); // analog audio pathway configuration Wire.write((uint8_t)((SIDEATT << 6) | (SIDETONE << 5) | (DACSEL << 4) | (BYPASS << 3) | (INSEL << 2) | (MUTEMIC << 1) | (MICBOOST << 0))); Wire.endTransmission();

delay(50);

Serial.println( "done" ); } // end initialisecodec`

Hi, I think there is a minor printing mistake at the start of the code after delay(10). What I believe is that the address parameter in the following line Wire.beginTransmission(0x1e); should be 0x1a instead of 0x1e. Kindly verify and comment?