<?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>nrf52840dk PCA10056 I2S MCLK Ratio</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/98374/nrf52840dk-pca10056-i2s-mclk-ratio</link><description>Hello, 
 I&amp;#39;m currently trying to replicate an existing ESP32 ESP-IDF application to nRF52840 Connect SDK. The goal of the application is echoing the Line In to the Line Out Audio on an I2S Codec. The I2S Codec is a NAU88C22. 
 I have used the following</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Tue, 04 Apr 2023 13:02:29 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/98374/nrf52840dk-pca10056-i2s-mclk-ratio" /><item><title>RE: nrf52840dk PCA10056 I2S MCLK Ratio</title><link>https://devzone.nordicsemi.com/thread/419056?ContentTypeID=1</link><pubDate>Tue, 04 Apr 2023 13:02:29 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:21f2056f-581f-442a-a77d-14ec6e53117a</guid><dc:creator>tomatosoup</dc:creator><description>&lt;p&gt;Ok, I have now found the solution.&lt;/p&gt;
&lt;p&gt;Reconfiguring the MCKFREQ register results in a LRCLK/BCLK which isn&amp;#39;t correct anymore as they were based on a different calculation.&lt;/p&gt;
&lt;p&gt;Thus also setting the register RATIO is necessary.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;This code was the solution for 8kHz SR and 256fs:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;// 8kHz Sampling Rate
// --
// MCLK = 256 * 8 kHz = 2.048Mhz
// BCLK = 2 * 16 * 8kHz = 256kHz
// --
// CONFIG.MCKFREQ = 32MHz / 16 = 2Mhz -&amp;gt; 0x10000000
// CONFIG.RATIO = 2MHz / 256 = 7.8125kHz -&amp;gt; 6		
*(volatile uint32_t *) 0x40025514 = 0x10000000;
*(volatile uint32_t *) 0x40025518 = 6;&lt;/pre&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nrf52840dk PCA10056 I2S MCLK Ratio</title><link>https://devzone.nordicsemi.com/thread/418966?ContentTypeID=1</link><pubDate>Tue, 04 Apr 2023 08:00:52 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:c2c60fea-d93b-435d-80f3-a618c491ffd0</guid><dc:creator>Kenneth</dc:creator><description>&lt;p&gt;Seems to work here:&lt;/p&gt;
&lt;div&gt;
&lt;div&gt;&lt;span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;img style="max-height:240px;max-width:320px;" src="https://devzone.nordicsemi.com/resized-image/__size/640x480/__key/communityserver-discussions-components-files/4/pastedimage1680595244896v1.png" alt=" " /&gt;&lt;/div&gt;
&lt;div&gt;Kenneth&lt;/div&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nrf52840dk PCA10056 I2S MCLK Ratio</title><link>https://devzone.nordicsemi.com/thread/418905?ContentTypeID=1</link><pubDate>Mon, 03 Apr 2023 18:50:10 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:a3cde1c2-a7fb-4622-bc9d-7bd8872b0cda</guid><dc:creator>tomatosoup</dc:creator><description>&lt;p&gt;Thanks, but somehow this seems to break the I2S Transfer.&lt;/p&gt;
&lt;p&gt;Currently, I have hooked up an external 2.048MHz Clock Source to MCLK of my Codec. Doing so, the Echo Example with my modified codec.c works as expected. I have Audio on my Line Out with Echo from the Line In.&lt;/p&gt;
&lt;p&gt;As soon as I place your suggested Line after printk(&amp;quot;Streams started\n&amp;quot;) I don&amp;#39;t get any audio anymore.&lt;/p&gt;
&lt;p&gt;No matter if I use the MCLK of my external clock source or the MCLK of the nRF.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nrf52840dk PCA10056 I2S MCLK Ratio</title><link>https://devzone.nordicsemi.com/thread/418893?ContentTypeID=1</link><pubDate>Mon, 03 Apr 2023 15:12:50 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:836d0f92-8d8f-4306-b100-7f92e512e521</guid><dc:creator>Kenneth</dc:creator><description>&lt;p&gt;You can try:&amp;nbsp;*(volatile uint32_t *) 0x40025514 = 0x10000000;&lt;/p&gt;
&lt;p&gt;Kenneth&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nrf52840dk PCA10056 I2S MCLK Ratio</title><link>https://devzone.nordicsemi.com/thread/418884?ContentTypeID=1</link><pubDate>Mon, 03 Apr 2023 14:25:41 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:9cf7676e-40a7-4a09-ad6e-c6422803f598</guid><dc:creator>tomatosoup</dc:creator><description>&lt;p&gt;Ok, can you give me a code example to change the MCLK after i2s_configure()?&lt;/p&gt;
&lt;p&gt;To my understanding, the nRF Connect SDK I2S driver hooks into the nRF5 SDK. But theres no API to change the MCLK. There is just nrfx_i2s_init(). But this doesn&amp;#39;t really help me as I don&amp;#39;t have the config object.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nrf52840dk PCA10056 I2S MCLK Ratio</title><link>https://devzone.nordicsemi.com/thread/418845?ContentTypeID=1</link><pubDate>Mon, 03 Apr 2023 12:37:28 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:c11aec39-7471-4364-b4e8-23d292314bed</guid><dc:creator>Kenneth</dc:creator><description>&lt;p&gt;Looking quickly at the implementation of&amp;nbsp;find_suitable_clock() in i2s_nrfx.c&amp;nbsp;it looks to just choose one that fits, so if you need a specific MCLK I suggest to set it manually after i2s_configure() yes.&lt;/p&gt;
&lt;p&gt;Kenneth&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nrf52840dk PCA10056 I2S MCLK Ratio</title><link>https://devzone.nordicsemi.com/thread/418816?ContentTypeID=1</link><pubDate>Mon, 03 Apr 2023 10:47:10 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:7e6c8957-c398-4821-83e0-d779c21e3645</guid><dc:creator>tomatosoup</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;Thanks for your Answer.&lt;/p&gt;
&lt;p&gt;Can you explain me on how I can set it to 2MHz in nRF Connect SDK? Do I need to write the Register directly?&lt;br /&gt;&lt;br /&gt;Currently, I&amp;#39;m using this example which I would like to reconfigure to 2MHz: &lt;a href="https://github.com/zephyrproject-rtos/zephyr/tree/main/samples/drivers/i2s/echo"&gt;github.com/.../echo&lt;/a&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nrf52840dk PCA10056 I2S MCLK Ratio</title><link>https://devzone.nordicsemi.com/thread/418808?ContentTypeID=1</link><pubDate>Mon, 03 Apr 2023 10:07:09 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:e1fe2033-1498-4683-8d29-3f88d93040ce</guid><dc:creator>Kenneth</dc:creator><description>&lt;p&gt;Hello,&lt;/p&gt;
&lt;p&gt;Looking at the Table 1 configuration example I can find that &lt;span&gt;32MDIV16&amp;nbsp;&lt;/span&gt;equals 2MHz:&lt;br /&gt;&lt;a href="https://infocenter.nordicsemi.com/topic/ps_nrf52840/i2s.html"&gt;https://infocenter.nordicsemi.com/topic/ps_nrf52840/i2s.html&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Also see:&lt;br /&gt;&lt;a href="https://infocenter.nordicsemi.com/topic/ps_nrf52840/i2s.html#register.CONFIG.MCKFREQ"&gt;https://infocenter.nordicsemi.com/topic/ps_nrf52840/i2s.html#register.CONFIG.MCKFREQ&lt;/a&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;For Audio you should consider using the nRF5340 which has an Audio PLL (e.g. it can for instance allow dynamic adjustment on the fly):&lt;br /&gt;&lt;a href="https://infocenter.nordicsemi.com/topic/ps_nrf5340/i2s.html"&gt;https://infocenter.nordicsemi.com/topic/ps_nrf5340/i2s.html&lt;/a&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Best regards,&lt;br /&gt;Kenneth&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>