DA7212 MKRZERO Interface

9 posts / 0 new
Last post
niradat
Offline
Last seen: 4 months 3 weeks ago
Joined: 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: 1 week 3 days ago
Staff
Joined: 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.

Many Thanks!

BR

Charles 

niradat
Offline
Last seen: 4 months 3 weeks ago
Joined: 2019-12-27 07:09
Hi,

Hi,

Attached herewith is the datasheet of DA7212 that I have.

Regards,

Niradat

Attachment: 
charlesxue1122
Offline
Last seen: 1 week 3 days ago
Staff
Joined: 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: 4 months 3 weeks ago
Joined: 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.


#define  CODEC_ADDRESS    0x1A
#include <SD.h>
#include <ArduinoSound.h>
#include <Wire.h>

// 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: 1 week 3 days ago
Staff
Joined: 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: 4 months 3 weeks ago
Joined: 2019-12-27 07:09
Hi Charles,

Hi Charles,

Yes, I want to configure DA7212 in slave 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: 1 week 3 days ago
Staff
Joined: 2019-12-23 05:48
Hi Niradat,

Hi Niradat,

Pls refer the code attached.

Thanks!

niradat
Offline
Last seen: 4 months 3 weeks ago
Joined: 2019-12-27 07:09
Thanks a lot Charles

Thanks a lot Charles