<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="https://devzone.nordicsemi.com/cfs-file/__key/system/syndication/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Technical Inquiry About Configuring I2S MCLK</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/107025/technical-inquiry-about-configuring-i2s-mclk</link><description>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</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Wed, 10 Jan 2024 10:17:11 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/107025/technical-inquiry-about-configuring-i2s-mclk" /><item><title>RE: Technical Inquiry About Configuring I2S MCLK</title><link>https://devzone.nordicsemi.com/thread/463496?ContentTypeID=1</link><pubDate>Wed, 10 Jan 2024 10:17:11 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:59448b08-6d95-4903-abe6-ef2ac22d66f6</guid><dc:creator>ovrebekk</dc:creator><description>&lt;p&gt;&lt;span&gt;You welcome, the best of luck with your project &lt;span class="emoticon" data-url="https://devzone.nordicsemi.com/cfs-file/__key/system/emoji/1f642.svg" title="Slight smile"&gt;&amp;#x1f642;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Technical Inquiry About Configuring I2S MCLK</title><link>https://devzone.nordicsemi.com/thread/463452?ContentTypeID=1</link><pubDate>Wed, 10 Jan 2024 06:17:32 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:f35893f5-c916-48c6-88ac-805c0dc36c81</guid><dc:creator>emmovo</dc:creator><description>&lt;p&gt;Thank you so much for your patience and detailed response, it was very helpful!&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Technical Inquiry About Configuring I2S MCLK</title><link>https://devzone.nordicsemi.com/thread/463366?ContentTypeID=1</link><pubDate>Tue, 09 Jan 2024 13:53:38 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:11d0234b-3782-4290-9b1f-1e087abad7bc</guid><dc:creator>ovrebekk</dc:creator><description>&lt;p&gt;Hi&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Thanks for the clarification.&lt;/p&gt;
&lt;p&gt;Looking at your various requirements, including the&amp;nbsp;&lt;span&gt;NRF_I2S_SWIDTH_24BIT_IN32BIT bit mode, I don&amp;#39;t think you will be able to replicate these settings successfully using the Zephyr I2S driver.&amp;nbsp;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;The Zephyr driver is quite generic since it is made to support a wide range of hardware devices, and doesn&amp;#39;t expose all the functionality of the I2S peripheral in the nRF devices.&amp;nbsp;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;In your case I believe you are better of using the nrfx_i2s driver directly, skipping the standard Zephyr driver.&amp;nbsp;We also do this in the LE Audio application because the standard driver doesn&amp;#39;t provide enough control over the hardware.&amp;nbsp;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Best regards&lt;br /&gt;Torbjørn&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Technical Inquiry About Configuring I2S MCLK</title><link>https://devzone.nordicsemi.com/thread/463004?ContentTypeID=1</link><pubDate>Sat, 06 Jan 2024 04:51:09 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:0661b37a-806e-4cb1-84c7-0929f4fc2f95</guid><dc:creator>emmovo</dc:creator><description>&lt;p&gt;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;&lt;/p&gt;
&lt;p&gt;Again, sorry for misleading you with another mistake!&lt;/p&gt;
&lt;p&gt;Also, regarding the bypass issue, my considerations are located in the nRF5340 datasheet&amp;#39;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.&lt;/p&gt;
&lt;p&gt;I just accidentally clicked on the &amp;quot;Verify Answer&amp;quot; button, but my mclk output problem is still not solved, I hope to continue to get your help!&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Technical Inquiry About Configuring I2S MCLK</title><link>https://devzone.nordicsemi.com/thread/462939?ContentTypeID=1</link><pubDate>Fri, 05 Jan 2024 15:00:20 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:44b1f157-3940-4d1a-8f6b-fd8e1f47e4ba</guid><dc:creator>ovrebekk</dc:creator><description>&lt;p&gt;Hi&amp;nbsp;&lt;/p&gt;
&lt;p&gt;I don&amp;#39;t think setting&amp;nbsp;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?&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Also, why do you want to enable bypass?&amp;nbsp;&lt;br /&gt;Are you not the I2S master?&lt;/p&gt;
&lt;p&gt;Best regards&lt;br /&gt;Torbjørn&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Technical Inquiry About Configuring I2S MCLK</title><link>https://devzone.nordicsemi.com/thread/462739?ContentTypeID=1</link><pubDate>Thu, 04 Jan 2024 14:58:39 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:1024f09b-3be1-4a65-8a07-21d3e224846f</guid><dc:creator>emmovo</dc:creator><description>&lt;p&gt;Thank you for your patience!&lt;/p&gt;
&lt;p&gt;Here are the details about my project;&lt;/p&gt;
&lt;p&gt;I am using nrf7002dk and the dts file used is nrf7002dk_nrf5340_cpuapp&lt;/p&gt;
&lt;p&gt;The target state I need to configure is:&lt;br /&gt;Sample rate 48KHz&lt;br /&gt;Bit width 24bi&lt;/p&gt;
&lt;p&gt;These are the parameters I initialized with nrfx_i2s_init:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;        nrfx_i2s_config_t config;
    

        config.sck_pin        = AIF1BCLK;
        config.lrck_pin       = AIF1LRCLK;
        config.mck_pin        = AIF1MCLK;
        config.sdout_pin      = AIF1RXDAT;
        config.sdin_pin       = AIF1TXDAT;
        
        config.irq_priority   = 2;
        config.mode           = NRF_I2S_MODE_MASTER;
        config.format         = NRF_I2S_FORMAT_I2S;
        config.alignment      = I2S_CONFIG_ALIGN_ALIGN_Left;

        config.sample_width   = NRF_I2S_SWIDTH_16BIT;

        config.channels       = NRF_I2S_CHANNELS_STEREO;
        config.mck_setup      = NRF_I2S_MCK_32MDIV2;
        config.ratio          = NRF_I2S_RATIO_256X;
        config.clksrc         = I2S_CONFIG_CLKCONFIG_CLKSRC_ACLK;
        config.enable_bypass  = true;

        NRF_CLOCK-&amp;gt;TASKS_HFCLKSTART = 1;
        while (NRF_CLOCK-&amp;gt;EVENTS_HFCLKSTARTED == 0);
        NRF_CLOCK-&amp;gt;EVENTS_HFCLKSTARTED = 0;

        NRF_CLOCK-&amp;gt;TASKS_HFCLKAUDIOSTART = 1;
        while (NRF_CLOCK-&amp;gt;EVENTS_HFCLKAUDIOSTARTED == 0);
        NRF_CLOCK-&amp;gt;EVENTS_HFCLKAUDIOSTARTED = 0;

        // dac_power_on();

        nrfx_i2s_uninit();

        if ( nrfx_i2s_init(&amp;amp;config, custom_i2s_irq_handler) == NRFX_SUCCESS )
        {
            LOG_INF(&amp;quot;IIS INIT SUCCESSED\r\n&amp;quot;);
        }&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;Output in this configuration&lt;br /&gt;MCLK 12.288MHz&lt;br /&gt;BCLK 1.537MHz&lt;br /&gt;LRCK 48KHz&lt;/p&gt;
&lt;p&gt;I was hoping to achieve the same result with the device tree configuration;&lt;/p&gt;
&lt;p&gt;Here is my current configuration:&lt;/p&gt;
&lt;p&gt;in my prj.conf:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;CONFIG_LOG=y
CONFIG_I2S=y
&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;Contents of my overlay file:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;&amp;amp;i2s0 {
    clock-source = &amp;quot;ACLK&amp;quot;;
    status = &amp;quot;okay&amp;quot;;
    pinctrl-0 = &amp;lt;&amp;amp;i2s0_default&amp;gt;;
    pinctrl-names = &amp;quot;default&amp;quot;;
};

&amp;amp;clock {
    hfclkaudio-frequency = &amp;lt;12288000&amp;gt;;
};
&amp;amp;pinctrl {
    i2s0_default: i2s0_default {
        group1 {
            psels = &amp;lt;NRF_PSEL(I2S_SCK_M, 0, 4)&amp;gt;,
                    &amp;lt;NRF_PSEL(I2S_LRCK_M, 0, 5)&amp;gt;,
                    &amp;lt;NRF_PSEL(I2S_SDIN, 0, 6)&amp;gt;,
                    &amp;lt;NRF_PSEL(I2S_MCK, 0, 7)&amp;gt;;
        };
    };
};
&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;This is my i2s initialization parameters:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;    
#define SAMPLE_FREQUENCY    48000
#define SAMPLE_BIT_WIDTH    32
#define BYTES_PER_SAMPLE    sizeof(int16_t)
#define NUMBER_OF_CHANNELS  2
/* Such block length provides an echo with the delay of 100 ms. */
#define SAMPLES_PER_BLOCK   ((SAMPLE_FREQUENCY / 10) * NUMBER_OF_CHANNELS)
#define INITIAL_BLOCKS      2
#define TIMEOUT             1000

if (!device_is_ready(i2s_dev)) {
LOG_INF(&amp;quot;%s is not ready\n&amp;quot;, i2s_dev-&amp;gt;name);
return 0;
}
else
{
	LOG_INF(&amp;quot;%s is ready\n&amp;quot;, i2s_dev-&amp;gt;name);
}

struct i2s_config config;
config.word_size = SAMPLE_BIT_WIDTH;
config.channels = NUMBER_OF_CHANNELS;
config.format = I2S_FMT_DATA_FORMAT_I2S;
config.options = I2S_OPT_BIT_CLK_MASTER |
				 I2S_OPT_FRAME_CLK_MASTER;
config.frame_clk_freq = SAMPLE_FREQUENCY;
config.mem_slab = &amp;amp;mem_slab;
config.block_size = BLOCK_SIZE;
config.timeout = TIMEOUT;

if (!configure_streams(i2s_dev, i2s_dev, &amp;amp;config))
{
	LOG_INF(&amp;quot;Failed to configure streams\n&amp;quot;);
	return 0;
}
else
{
	LOG_INF(&amp;quot;configure streams success\n&amp;quot;);
}&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;I can see the frequency of my current configuration mclk output by the contents of the log:&lt;br /&gt;&lt;pre class="ui-code" data-mode="text"&gt;*** Booting Zephyr OS build v3.3.99-ncs1-1 ***
[00:00:00.251,342] &amp;lt;inf&amp;gt; i2s: This is i2s demo
[00:00:00.251,373] &amp;lt;inf&amp;gt; i2s: i2s@28000 is ready

[00:00:00.251,403] &amp;lt;inf&amp;gt; i2s_nrfx: I2S MCK frequency: 3072000, actual PCM rate: 48000
[00:00:00.251,403] &amp;lt;inf&amp;gt; i2s: configure streams success

[00:00:00.255,035] &amp;lt;inf&amp;gt; i2s: Streams started&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;Meanwhile I observed the status of the i2s registers via debug mode&lt;br /&gt;CLKSRC in NRF_I2S0-&amp;gt;CONFIG.CLKCONFIG has been configured to ACLK, but BYPASS is Disable&lt;/p&gt;
&lt;p&gt;Maybe I want to configure the mclk to 12.288MHz output, I need to solve the problem that aclk is not paired configured as bypass, also please help me to see where I am having problems, thanks for your patience!&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Technical Inquiry About Configuring I2S MCLK</title><link>https://devzone.nordicsemi.com/thread/462493?ContentTypeID=1</link><pubDate>Wed, 03 Jan 2024 12:46:07 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:fdc1bacf-6b50-4264-9e0d-5fefb610854c</guid><dc:creator>ovrebekk</dc:creator><description>&lt;p&gt;Hi&lt;/p&gt;
&lt;p&gt;Thanks for the clarification. For some reason the nRF52840 tag was set in your case, which is why I assumed you were using this device.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;One tip in order to get more information about the I2S settings used is to enable logging for the nrfx_i2s driver, by adding the following lines to the prj.conf file:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;CONFIG_LOG=y
CONFIG_NRFX_I2S_LOG=y
CONFIG_LOG_DEFAULT_LEVEL=4&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;Then you can see which MCK frequency gets configured by the driver.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;A MCK frequency of 12.288MHz sounds quite high. Does your settings match any of the &lt;a href="https://infocenter.nordicsemi.com/topic/ps_nrf5340/i2s.html?cp=4_0_0_6_14_3#master_clock_source_examples__table_conf_examples_pclk32"&gt;examples in the documentation&lt;/a&gt;?&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Could you let me know which other settings you are planning to use, such as the LRCK and RATIO settings?&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Best regards&lt;br /&gt;Torbjørn&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Technical Inquiry About Configuring I2S MCLK</title><link>https://devzone.nordicsemi.com/thread/462362?ContentTypeID=1</link><pubDate>Tue, 02 Jan 2024 17:40:36 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:c7b216be-cee4-49fa-bf65-2dadc21dcc7a</guid><dc:creator>emmovo</dc:creator><description>&lt;p&gt;Thank you for your answer, and I&amp;#39;m very sorry that I didn&amp;#39;t surface my development platform, I&amp;#39;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.&lt;br /&gt;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;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Technical Inquiry About Configuring I2S MCLK</title><link>https://devzone.nordicsemi.com/thread/462279?ContentTypeID=1</link><pubDate>Tue, 02 Jan 2024 12:28:27 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:4852bedb-931e-4d9c-afbc-4edf5133bf28</guid><dc:creator>ovrebekk</dc:creator><description>&lt;p&gt;Hi&lt;/p&gt;
&lt;p&gt;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, &lt;a href="https://infocenter.nordicsemi.com/topic/ps_nrf52840/i2s.html?cp=5_0_0_5_10"&gt;here&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;When using the Zephyr driver the I2S registers will be set indirectly depending on the configuration you set in the&amp;nbsp;i2s_config struct, such as the word_size, channels and frame_clk_freq fields.&amp;nbsp;&lt;/p&gt;
[quote user=""]Given the importance of the MCLK in the overall I2S communication, I am seeking specific guidance on how to correctly set up the MCLK.[/quote]
&lt;p&gt;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?&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Otherwise it is hard to say what would be the correct I2S configuration.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Best regards&lt;br /&gt;Torbjørn&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>