Technical Inquiry About Configuring I2S MCLK

Dear Nordic Semiconductor Team,

Hello! I have been exploring your I2S sample code, specifically the example located at “C:\ncs\v2.4.2\zephyr\samples\drivers\i2s\echo”. While I have gained a good understanding of most parts, I am encountering some difficulties in configuring the MCLK (Master Clock) for I2S.

I noticed that the sample code does not seem to explicitly mention how to configure the MCLK output. Given the importance of the MCLK in the overall I2S communication, I am seeking specific guidance on how to correctly set up the MCLK.

It would be greatly helpful if you could provide relevant code examples or configuration instructions for this. Thank you for your support and assistance. I look forward to your response.

Best regards, [Your Name] [Your Contact Information, such as email, phone number, etc.]

Parents
  • Hi

    For the best understanding of the I2S peripheral in the nRF52840 I would recommend starting by reading the I2S chapter in the nRF52840 product specification, here.

    When using the Zephyr driver the I2S registers will be set indirectly depending on the configuration you set in the i2s_config struct, such as the word_size, channels and frame_clk_freq fields. 

    Given the importance of the MCLK in the overall I2S communication, I am seeking specific guidance on how to correctly set up the MCLK.

    This question is a bit open. What kind of audio settings do you require, and do you need to connect to any particular I2S device? 

    Otherwise it is hard to say what would be the correct I2S configuration. 

    Best regards
    Torbjørn

  • Thank you for your answer, and I'm very sorry that I didn't surface my development platform, I'm using the nRF5340 for development. Through the nRF5340 + CS47L35 architecture. I originally used the i2s driver from nrfx_i2s.h to accomplish this, where the nRF5340 acts as the master device MCLK sending a synchronization frequency of 12.288MHz.
    Recently I found out that the new sdk version has the extra demo i2s_echo, which is an i2s driver implemented through the device tree and zephyr api, using want to know if there is a way to configure the MCLK to output a synchronization frequency of 12.288MHz;

  • Hi 

    I don't think setting SAMPLE_BIT_WIDTH to 32 is correct. Looking at your old code it seems you are using 16-bits pr sample, and stereo, meaning you have 32 bits for both channels but not 32 bit pr sample? 

    Also, why do you want to enable bypass? 
    Are you not the I2S master?

    Best regards
    Torbjørn

  • Hi, I confirmed that the configuration of the bit width is indeed incorrect; I wanted to be able to configure it as a 24bit bit width, and the original code should have NRF_I2S_SWIDTH_24BIT_IN32BIT; so I put SAMPLE_BIT_WIDTH = 32 in the code behind;

    Again, sorry for misleading you with another mistake!

    Also, regarding the bypass issue, my considerations are located in the nRF5340 datasheet's FIGURE 63, where the figure shows that turning on config.bypass,allows to connect the pesl.mck directly to the clock source, i.e., hfclk or aclk; in PAGE 265, 7.15.10.27 CONFIG. CLKCONFIG description also says that when bypass is enabled, MCK will be equal to source input.

    I just accidentally clicked on the "Verify Answer" button, but my mclk output problem is still not solved, I hope to continue to get your help!

  • Hi 

    Thanks for the clarification.

    Looking at your various requirements, including the NRF_I2S_SWIDTH_24BIT_IN32BIT bit mode, I don't think you will be able to replicate these settings successfully using the Zephyr I2S driver. 

    The Zephyr driver is quite generic since it is made to support a wide range of hardware devices, and doesn't expose all the functionality of the I2S peripheral in the nRF devices. 

    In your case I believe you are better of using the nrfx_i2s driver directly, skipping the standard Zephyr driver. We also do this in the LE Audio application because the standard driver doesn't provide enough control over the hardware. 

    Best regards
    Torbjørn

  • Thank you so much for your patience and detailed response, it was very helpful!

  • You welcome, the best of luck with your project Slight smile

Reply Children
No Data
Related