DA7212 MKRZERO Interface

⚠️
Hi there.. thanks for coming to the forums. Exciting news! we’re now in the process of moving to our new forum platform that will offer better functionality and is contained within the main Dialog website. All posts and accounts have been migrated. We’re now accepting traffic on the new forum only - please POST any new threads at//www.xmece.com/support. We’ll be fixing bugs / optimising the searching and tagging over the coming days.
9 posts / 0 new
Last post
niradat
Offline
Last seen:1 year 2 months ago
加入:2019-12-27 07:09
DA7212 MKRZERO Interface

Hi,

According to the datasheet of DA7212 Page 62, there is no need of MCLK when DA7212 is interfaced with the processor in slave mode. I have interfaced ard-audio-da7212 board with my Arduino MKRZERO. Arduino MKRZERO is capable of generating the required I2S signals like BCLK,WCLK and DATOUT. My question is do I have to provide MCLK to ard-audio-da7212 from MKRZERO?

regards,

Niradat.

Device:
charlesxue1122
Offline
Last seen:12 hours 57 min ago
Staff
加入:2019-12-23 05:48
Dear Niradat,

Dear Niradat,

Sorry for the late to response. The DA7212 datasheet of mine seems that have some difference with yours.

Could you send yours to me to check the description. I need check the PLL clock soucrec is from MCLK or BLCK.

许多Thanks!

BR

Charles

niradat
Offline
Last seen:1 year 2 months ago
加入:2019-12-27 07:09
Hi,

Hi,

Attached herewith is the datasheet of DA7212 that I have.

Regards,

Niradat

Attachment:
charlesxue1122
Offline
Last seen:12 hours 57 min ago
Staff
加入:2019-12-23 05:48
Hi Niradat,

Hi Niradat,

Attached is a new one. You can take the section "13.25 Clock modes" as reference. Pls pay attention for Pll mode configuration.

Thanks!

niradat
Offline
Last seen:1 year 2 months ago
加入:2019-12-27 07:09
Hi Charles,

Hi Charles,

Thanks for sharing the updated Datasheet of DA7212. Using the datasheet I have written the follwing code on Arduino MKRZERO. In this code the MKRZERO is playing a 16-bit Stereo WAV file and I can listen it on my ARD-AUDIO-DA7212 Audio Shield. But it seems that DA7212 suddenly goes in sleep state and the audio stops. Although MKRZERO is playing the Audio. Furthermore the Audio from DA7212 Module is not Stereo. Kindly help in this regard.

Best Regards,

NIradat.

#定义CODEC_ADDRESS 0 x1a # include < SD.h > #萤火虫e  #include  // filename of wave file to play const char filename[] = "MUSIC.WAV"; // variable representing the Wave File SDWaveFile waveFile; void setup() { // Open serial communications and wait for port to open: Serial.begin(9600); delay(5000); // setup the SD card, depending on your shield of breakout board // you may need to pass a pin number in begin for SS Serial.print("Initializing SD card..."); if (!SD.begin()) { Serial.println("initialization failed!"); return; } Serial.println("initialization done."); // create a SDWaveFile waveFile = SDWaveFile(filename); // check if the WaveFile is valid if (!waveFile) { Serial.println("wave file is invalid!"); while (1); // do nothing } // print out some info. about the wave file Serial.print("Bits per sample = "); Serial.println(waveFile.bitsPerSample()); long channels = waveFile.channels(); Serial.print("Channels = "); Serial.println(channels); long sampleRate = waveFile.sampleRate(); Serial.print("Sample rate = "); Serial.print(sampleRate); Serial.println(" Hz"); long duration = waveFile.duration(); Serial.print("Duration = "); Serial.print(duration); Serial.println(" seconds"); ///////////////////////////////////////////////////////////////////// Initialization of DA7212 ///////////////////////////////////////////////////////////////// Wire.begin(); //WRITE DA7212 0x92 0x00 //Set Ramp rate to default delay(100); Wire.beginTransmission(CODEC_ADDRESS); Wire.write(0x92); Wire.write(0x00); Wire.endTransmission(); //WRITE DA7212 0x90 0x80 //Enable Digital LDO delay(100); Wire.beginTransmission(CODEC_ADDRESS); Wire.write(0x90); Wire.write(0x80); Wire.endTransmission(); //WRITE DA7212 0x29 0xC0 //Enable AIF 16bit I2S mode delay(100); Wire.beginTransmission(CODEC_ADDRESS); Wire.write(0x29); Wire.write(0xC0); Wire.endTransmission(); //WRITE DA7212 0x22 0x0A //Set incoming sample rate to 44.1kHz delay(100); Wire.beginTransmission(CODEC_ADDRESS); Wire.write(0x22); Wire.write(0x0A); Wire.endTransmission(); //WRITE DA7212 0x94 0x02 //Set PC sync to resync default delay(100); Wire.beginTransmission(CODEC_ADDRESS); Wire.write(0x94); Wire.write(0x02); Wire.endTransmission(); //WRITE DA7212 0x27 0x04 //PLL_CTRL PLL disabled delay(100); Wire.beginTransmission(CODEC_ADDRESS); Wire.write(0x27); Wire.write(0x04); Wire.endTransmission(); //WRITE DA7212 0x2A 0x32 //Route DAI to Outputs default delay(100); Wire.beginTransmission(CODEC_ADDRESS); Wire.write(0x2A); Wire.write(0x32); Wire.endTransmission(); //WRITE DA7212 0x4B 0x08 //MIXOUT_L input from DACL delay(100); Wire.beginTransmission(CODEC_ADDRESS); Wire.write(0x48); Wire.write(0x08); Wire.endTransmission(); //WRITE DA7212 0x4C 0x08 //MIXOUT_R input from DACR delay(100); Wire.beginTransmission(CODEC_ADDRESS); Wire.write(0x4C); Wire.write(0x08); Wire.endTransmission(); //WRITE DA7212 0x47 0xCD //Enable charge pump, CP_MOD mode, CPVDD/1 and Boost CP delay(100); Wire.beginTransmission(CODEC_ADDRESS); Wire.write(0x47); Wire.write(0xCD); Wire.endTransmission(); //WRITE DA7212 0x95 0x36 //Set CP threshold to 0x36 delay(100); Wire.beginTransmission(CODEC_ADDRESS); Wire.write(0x95); Wire.write(0x36); Wire.endTransmission(); //WRITE DA7212 0x96 0xA5 //Set CP Tau DELAY to 64ms delay(100); Wire.beginTransmission(CODEC_ADDRESS); Wire.write(0x96); Wire.write(0xA5); Wire.endTransmission(); //WRITE DA7212 0x48 0x2D //Set volume to -12dB delay(100); Wire.beginTransmission(CODEC_ADDRESS); Wire.write(0x48); Wire.write(0x2D); Wire.endTransmission(); //WRITE DA7212 0x49 0x2D //Set volume to -12dB delay(100); Wire.beginTransmission(CODEC_ADDRESS); Wire.write(0x49); Wire.write(0x2D); Wire.endTransmission(); //WRITE DA7212 0x51 0xF1 //Enable DAC, Mix and HP amplifiers delay(100); Wire.beginTransmission(CODEC_ADDRESS); Wire.write(0x51); Wire.write(0xF1); Wire.endTransmission(); //WRITE DA7212 0xFD 0x01 //Set tone gen gain to -18dBstem Active delay(100); Wire.beginTransmission(CODEC_ADDRESS); Wire.write(0xFD); Wire.write(0x01); Wire.endTransmission(); ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // adjust the playback volume AudioOutI2S.volume(50); // check if the I2S output can play the wave file if (!AudioOutI2S.canPlay(waveFile)) { Serial.println("unable to play wave file using I2S!"); while (1); // do nothing } // start playback Serial.println("starting playback"); AudioOutI2S.play(waveFile); } void loop() { // check if playback is still going on if (!AudioOutI2S.isPlaying()) { // playback has stopped Serial.println("playback stopped"); while (1); // do nothing } }

charlesxue1122
Offline
Last seen:12 hours 57 min ago
Staff
加入:2019-12-23 05:48
Hi Niradat,

Hi Niradat,

If you have decieded to configure DA7212 as slave mode, could you provide the frequency of MCLK/BCLK/WS sent from your Arduino MKRZERO?

I can find some sample code for you.

Thanks!

niradat
Offline
Last seen:1 year 2 months ago
加入:2019-12-27 07:09
Hi Charles,

Hi Charles,

是的,我想要配置DA7212slave mode. Regarding the clock outputs from Arduino MKRZERO, there are only three outputs from MKRZERO namely BCLK, WS and DOUT with their respective frequency BCLK= 1.4112 MHz and WS=44.1KHz. MCLK is not output from MKRZERO.

BCLK= 44.1 kHz × 16 × 2 = 1.4112 MHz

Regards,

Niradat.

charlesxue1122
Offline
Last seen:12 hours 57 min ago
Staff
加入:2019-12-23 05:48
Hi Niradat,

Hi Niradat,

Pls refer the code attached.

Thanks!

niradat
Offline
Last seen:1 year 2 months ago
加入:2019-12-27 07:09
Thanks a lot Charles

Thanks a lot Charles