This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

How to interface DA7212 codec with nrf52840?

I am testing DA7212 with my nrf52840 and i have made connections but i am not sure if thats right. Also i am trying to use i2s loopback example from sdk.

i need some guidence

Parents
  • Could you please also let me know if you were able to get the I2S example to work as intended?

    Yes Carl the example is working as intended.

    Control of the DA7212 by the nRF52840 requires using the I2C interface.

    Could you tell me how to achieve this?

    As there are 2 configurations one with i2c and one with i2s .

    - I2S is used to do audio transfer, since we want the DA7212 to receive input from the nRF52840, we need the DA7212 to be in slave configuration but the default configuration is master.

    I am assuming this will be done if i connect mclk from nrf board.

    i made some changes to the config in the i2s  loop back example program to configure sck , lrck and mck pin as seen below. Please tell me if thats correct.

        config.mck_pin=1 ;
        config.lrck_pin=I2S_CONFIG_LRCK_PIN;
        config.sck_pin = I2S_CONFIG_SCK_PIN;
    you are able to see the expected output from the loopback test, as described in the loopback documentation?

    yes i got the expected result wit the loopback test but i noticed in the example the mclk , sck and lrck pins were not configured so i found 2 of the in sdk config 

    #ifndef I2S_CONFIG_SCK_PIN
    #define I2S_CONFIG_SCK_PIN 31
    #endif
    // <o> I2S_CONFIG_LRCK_PIN - LRCK pin  <1-31> 
    #ifndef I2S_CONFIG_LRCK_PIN
    #define I2S_CONFIG_LRCK_PIN 30
    #endif
    // <o> I2S_CONFIG_MCK_PIN - MCK pin 
    #ifndef I2S_CONFIG_MCK_PIN
    #define I2S_CONFIG_MCK_PIN 255
    #endif

    since mck pin was configured to 255 i changed it to pin 1

    Are you familiar with how to find the correct pins on the different headers mentioned in the datasheet?

    yes i have some idea about it

    After reading the datasheet, this seems incorrect to me. Please see the J5 - Speaker output section of table 2 in the datasheet you linked.

    okay thanks for this i have made the necessary connections now how do i proceed.

  • Brijesh said:
    Could you tell me how to achieve this?

    By this, are you asking how you should connect the DA7212 with the nRF52840?
    Have you taken a look at the schematics for the DA7212 development kit? Please have a look at the different wiring options in the second page, and cross reference them with the table you linked in your previous comment. Pay attention to the different designation on each of the [option] connections, to see which option is the right one for your application.
    If you are unable to identify the correct connections, let me know and I will take a closer look at the provided schematics along with your suggestions.

    Brijesh said:
    I am assuming this will be done if i connect mclk from nrf board.

    I am not certain this is a valid assumption for the DA7212. After some searching I was able to find the DA7212 complete datasheet.
    Are you familiar with reading datasheets like this?
    In case you are not; search for the functionality you would like to enable/configure/control, find its associated register names, look up the register names in the 14.1 "register map", and click on the name of each bit-field to see the different configuration options. Learning to read a datasheet like this is an essential skill when working with embedded development, even though it seems a lot on the surface it is really not much more than the procedure I explained above.
    All configuration and control of the DA7212 is done over the I2C interface, so you will need to use that as well.

    In Section 13.33 of the datasheet the Digital Audio Interface(DAI) is detailed, and it seems you will need to set both the DAI_CTRL register, as well as possibly changing the DAI_CLK_MODE register, using I2C. Please study the referenced datasheet, and get back to me with any questions you might have! :)

    I must also mention: from reading the DA7212 datasheet, it seems that the default DAI configuration is slave - which conflicts my previous statement, having only read the development kit documentation. Just a heads up.

    Brijesh said:
    i made some changes to the config in the i2s  loop back example program to configure sck , lrck and mck pin as seen below. Please tell me if thats correct.

    I would advice against using "magic numbers" in any code, especially embedded code, since it massively decreases readability and causes a lot of confusion in the long run. Please reconfigure the I2S_CONFIG_MCK_PIN definition instead.

    Brijesh said:
    since mck pin was configured to 255 i changed it to pin 1

    Is this a random or conscious choice? Have you chosen it with respect to the pin assignment documentation for the nRF52840?
    You need to verify that the pins you have high frequency ( > 10 kHz ) signals on is not designated low-frequency pins, as this will interfere with your radio.

    Brijesh said:
    okay thanks for this i have made the necessary connections now how do i proceed.

    The documentation and common module operation on the nRF52840's end is described here.
    When the DA7212 is configured correctly, you can stream audio on your speaker by following the recipe provided in the above link.

    I look forward to hearing how you progress with your application!
    Please let me know if you have any more questions.

    Best regards,
    Karl

Reply
  • Brijesh said:
    Could you tell me how to achieve this?

    By this, are you asking how you should connect the DA7212 with the nRF52840?
    Have you taken a look at the schematics for the DA7212 development kit? Please have a look at the different wiring options in the second page, and cross reference them with the table you linked in your previous comment. Pay attention to the different designation on each of the [option] connections, to see which option is the right one for your application.
    If you are unable to identify the correct connections, let me know and I will take a closer look at the provided schematics along with your suggestions.

    Brijesh said:
    I am assuming this will be done if i connect mclk from nrf board.

    I am not certain this is a valid assumption for the DA7212. After some searching I was able to find the DA7212 complete datasheet.
    Are you familiar with reading datasheets like this?
    In case you are not; search for the functionality you would like to enable/configure/control, find its associated register names, look up the register names in the 14.1 "register map", and click on the name of each bit-field to see the different configuration options. Learning to read a datasheet like this is an essential skill when working with embedded development, even though it seems a lot on the surface it is really not much more than the procedure I explained above.
    All configuration and control of the DA7212 is done over the I2C interface, so you will need to use that as well.

    In Section 13.33 of the datasheet the Digital Audio Interface(DAI) is detailed, and it seems you will need to set both the DAI_CTRL register, as well as possibly changing the DAI_CLK_MODE register, using I2C. Please study the referenced datasheet, and get back to me with any questions you might have! :)

    I must also mention: from reading the DA7212 datasheet, it seems that the default DAI configuration is slave - which conflicts my previous statement, having only read the development kit documentation. Just a heads up.

    Brijesh said:
    i made some changes to the config in the i2s  loop back example program to configure sck , lrck and mck pin as seen below. Please tell me if thats correct.

    I would advice against using "magic numbers" in any code, especially embedded code, since it massively decreases readability and causes a lot of confusion in the long run. Please reconfigure the I2S_CONFIG_MCK_PIN definition instead.

    Brijesh said:
    since mck pin was configured to 255 i changed it to pin 1

    Is this a random or conscious choice? Have you chosen it with respect to the pin assignment documentation for the nRF52840?
    You need to verify that the pins you have high frequency ( > 10 kHz ) signals on is not designated low-frequency pins, as this will interfere with your radio.

    Brijesh said:
    okay thanks for this i have made the necessary connections now how do i proceed.

    The documentation and common module operation on the nRF52840's end is described here.
    When the DA7212 is configured correctly, you can stream audio on your speaker by following the recipe provided in the above link.

    I look forward to hearing how you progress with your application!
    Please let me know if you have any more questions.

    Best regards,
    Karl

Children
  • Thanks Karl , I was able to configure the da7212 using i2c protocols and i wrote to registers using i2c interface.

    I was able to generate a beep tone and i was able to input audio and play it via speakers.

    now the tough part is i have still not used i2s protocol.

    I want to store some audio file into the ram and play it on my command .

    I have been looking out for examples where i would understand how that has to be done but I couldnot find any.

    Thanks againg fpr being so patient with me and extreamly sorry for the late reply.

    Hope you are well in the COVID 19 pandemic

  • Hello again Brijesh!

    Brijesh said:

    Thanks Karl , I was able to configure the da7212 using i2c protocols and i wrote to registers using i2c interface.

    I was able to generate a beep tone and i was able to input audio and play it via speakers.

    Great, I am happy to hear this! This is highly meaningful progress.
    How did you input the audio if you did not use I2S? Aux?

    Brijesh said:

    I want to store some audio file into the ram and play it on my command .

    I have been looking out for examples where i would understand how that has to be done but I couldnot find any.

    Have you read the I2S driver documentation? It would be a good place to start, once you successfully have configured your DA7212 using I2C(good job, by the way!).
    The full list of available functions in the I2S API Reference, which can be seen here.
    So, to proceed I suggest that you read the driver documentation for how to use the driver, than look at the API Reference to better understand each step.
    Do let me know if you encounter any issues or questions whilst doing so!

    Brijesh said:
    Thanks againg fpr being so patient with me and extreamly sorry for the late reply.

    Absolutely no problem at all! Do not worry about late replies, I fully understand, no worries.

    Brijesh said:
    Hope you are well in the COVID 19 pandemic

    Thank you, and I sincerely hope you are too :)
    Stay safe!

    Best regards,
    Karl

Related