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:2个月前1年
加入: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?

问候,

Niradat.

Device:
charlesxue1122
Offline
Last seen:1 day 13 min ago
Staff
加入:2019-12-23 05:48
亲爱的Niradat,

亲爱的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:2个月前1年
加入:2019-12-27 07:09
Hi,

Hi,

Attached herewith is the datasheet of DA7212 that I have.

问候,

Niradat

Attachment:
charlesxue1122
Offline
Last seen:1 day 13 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:2个月前1年
加入: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,

尼拉达特。

#define codec_address 0x1a #include  #include  #include  // wave for to to const char filename [] =“music.wav”;//表示波浪文件sdwavefile wavefile的变量;void setup(){//打开串行通信并等待端口打开:Serial.Begin(9600);延迟(5000);//根据您的突破板//的屏蔽设置SD卡//您可能需要在开头的SS Serial.print中传递PIN号(“初始化SD卡...”);if(!sd.begin()){serial.println(“初始化失败!”);返回;erial.println(“完成初始化”。);//创建一个sdwavefile wavefile = sdwavefile(文件名);//检查波文件是否有效,if(!波浪文件){serial.println(“Wave文件无效!”); 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:1 day 13 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?

我可以为您找到一些示例代码。

Thanks!

niradat
Offline
Last seen:2个月前1年
加入:2019-12-27 07:09
Hi Charles,

Hi Charles,

是的,我想在从模式下配置DA7212。关于Arduino Mkrzero的时钟输出,MKRZERO即来自MKRZERE的只有三个输出,WS和DOUT,其各自的频率BCLK = 1.4112 MHz和WS = 44.1kHz。MKRZERO不会输出MCLK。

BCLK= 44.1 kHz × 16 × 2 = 1.4112 MHz

问候,

Niradat.

charlesxue1122
Offline
Last seen:1 day 13 min ago
Staff
加入:2019-12-23 05:48
Hi Niradat,

Hi Niradat,

Pls refer the code attached.

Thanks!

niradat
Offline
Last seen:2个月前1年
加入:2019-12-27 07:09
Thanks a lot Charles

Thanks a lot Charles