<?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>X-NUCLEO-IK02A1 Microphone Example: dmic_configure returns -22</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/102902/x-nucleo-ik02a1-microphone-example-dmic_configure-returns--22</link><description>Hello, 
 I have been attempting to utilize the X-NUCLEO-IK02A1 microphone with my nrf5340 DK. After making some adjustments to the x_nucleo_iks02a1_mic_overlay (getting rid of the arduino_i2s node name that was not compatible with my board) and swapping</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Mon, 21 Aug 2023 18:16:09 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/102902/x-nucleo-ik02a1-microphone-example-dmic_configure-returns--22" /><item><title>RE: X-NUCLEO-IK02A1 Microphone Example: dmic_configure returns -22</title><link>https://devzone.nordicsemi.com/thread/442379?ContentTypeID=1</link><pubDate>Mon, 21 Aug 2023 18:16:09 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:5a2783b0-f89d-436c-86bb-33db9067fbe0</guid><dc:creator>Quintin H.</dc:creator><description>&lt;p&gt;Thanks for your help &lt;a href="https://devzone.nordicsemi.com/members/ladivin"&gt;Ladivin&lt;/a&gt;&amp;nbsp;! I&amp;#39;ll try out the new sample you provided alongside you when I get the time to do so.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: X-NUCLEO-IK02A1 Microphone Example: dmic_configure returns -22</title><link>https://devzone.nordicsemi.com/thread/442284?ContentTypeID=1</link><pubDate>Mon, 21 Aug 2023 11:55:42 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:b48574c1-d42b-4509-a362-f29ab34fd19e</guid><dc:creator>Ladivin</dc:creator><description>&lt;p&gt;Hi Quintin, thanks for testing this.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Long story short, the division by zero issue can be solved by changing&amp;nbsp;&lt;code&gt;hfclkaudio-frequency&lt;/code&gt; from&amp;nbsp;11289600 to&amp;nbsp;12288000. The thing is that&amp;nbsp;&lt;code&gt;find_suitable_clock() from&amp;nbsp;&lt;/code&gt;&lt;span&gt;zephyr\drivers\i2s\i2s_nrfx.c performs quite a few computations to determine the correct frequency settings - more on this&amp;nbsp;&lt;a href="https://infocenter.nordicsemi.com/topic/ps_nrf5340/i2s.html?cp=4_0_0_6_14_4#concept_ezd_bqy_vr"&gt;here&lt;/a&gt;. Apparently, some of the computations are not robust enough and a wrong combination of inputs can cause Division by zero (we&amp;#39;re considering creating a PR to propose a fix).&amp;nbsp;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;This will solve the Division by zero issue, but we&amp;#39;re still not there. Our code is based on &lt;a href="https://developer.nordicsemi.com/nRF_Connect_SDK/doc/latest/zephyr/samples/shields/x_nucleo_iks02a1/microphone/README.html"&gt;this&lt;/a&gt;&amp;nbsp;sample (I assume that yours is too?). When I measured the output clock frequency and it&amp;#39;s around 4 MHz. This exceeds maximal frequency the mic can handle. Also this is two times more than the documentation of this sample says the frequency should be. So clearly, there&amp;#39;s still something wrong.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Currently, we&amp;nbsp;shifted our focus to&amp;nbsp;&lt;a href="https://developer.nordicsemi.com/nRF_Connect_SDK/doc/latest/zephyr/samples/drivers/audio/dmic/README.html"&gt;this&lt;/a&gt;&amp;nbsp;sample because we believe it might be easier to make it working with the mic.&lt;/p&gt;
&lt;p&gt;Ladivin&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: X-NUCLEO-IK02A1 Microphone Example: dmic_configure returns -22</title><link>https://devzone.nordicsemi.com/thread/442149?ContentTypeID=1</link><pubDate>Sat, 19 Aug 2023 02:44:39 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:a83c5e60-55b1-4d3c-83a5-403dee6d4374</guid><dc:creator>Quintin H.</dc:creator><description>&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;***** USAGE FAULT *****em
[00:00:00.272,125] &amp;lt;err&amp;gt; os:   Division by zero
[00:00:00.272,155] &amp;lt;err&amp;gt; os: r0/a1:  0x0010ad72  r1/a2:  0x00000000  r2/a3:  0x0056b800
[00:00:00.272,155] &amp;lt;err&amp;gt; os: r3/a4:  0x00000000 r12/ip:  0x0000ad72 r14/lr:  0x000061d7
[00:00:00.272,155] &amp;lt;err&amp;gt; os:  xpsr:  0x49000000
[00:00:00.272,186] &amp;lt;err&amp;gt; os: Faulting instruction address (r15/pc): 0x000061de
[00:00:00.272,216] &amp;lt;err&amp;gt; os: &amp;gt;&amp;gt;&amp;gt; ZEPHYR FATAL ERROR 0: CPU exception on CPU 0
[00:00:00.272,247] &amp;lt;err&amp;gt; os: Current thread: 0x200009b0 (main)&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;&lt;a href="https://devzone.nordicsemi.com/members/ladivin"&gt;Ladivin&lt;/a&gt;&amp;nbsp;I tried out your solution, and it seems like whenever I remove&amp;nbsp;&lt;code&gt;I2S_FMT_BIT_CLK_INV&lt;/code&gt;&lt;span&gt;&amp;nbsp; it throws a Div by Zero error regardless of swapping the L/R config. It throws the same EINVAL error if I leave it as it was originally.&amp;nbsp;&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: X-NUCLEO-IK02A1 Microphone Example: dmic_configure returns -22</title><link>https://devzone.nordicsemi.com/thread/441907?ContentTypeID=1</link><pubDate>Thu, 17 Aug 2023 14:39:12 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:1df200f4-310e-41e9-8f32-aa46daeec07d</guid><dc:creator>Kenneth</dc:creator><description>&lt;p&gt;Nice &lt;a href="https://devzone.nordicsemi.com/members/ladivin"&gt;Ladivin&lt;/a&gt;&amp;nbsp;, this sounds like something that should work yes. I don&amp;#39;t have the possibility to try it myself, but looks very promising! thank you.&lt;/p&gt;
&lt;p&gt;Kenneth&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: X-NUCLEO-IK02A1 Microphone Example: dmic_configure returns -22</title><link>https://devzone.nordicsemi.com/thread/441904?ContentTypeID=1</link><pubDate>Thu, 17 Aug 2023 14:34:20 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:1592cf93-1a34-4691-835a-b94f4f8c86aa</guid><dc:creator>Ladivin</dc:creator><description>&lt;p&gt;Hello Kenneth and Quintin H.,&lt;/p&gt;
&lt;p&gt;me and my colleague are currently struggling with the very same issue with the same combination of hardware.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;I believe I have a workaround but - and I cannot stress this enough - I haven&amp;#39;t had a chance to test it yet. Long story short, what I propose is to comment out &lt;code&gt;I2S_FMT_BIT_CLK_INV &lt;/code&gt;in&amp;nbsp;&lt;code&gt;&lt;span&gt;mpxxdtyy_i2s_configure()&lt;/span&gt;&lt;/code&gt;, to close solder bridge SB30 and to open SB28 on the shield.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Now, why I think it will help. If&amp;nbsp;&lt;span&gt;&lt;code&gt;I2S_FMT_BIT_CLK_INV&lt;/code&gt; is not set, SD data gets sampled on rising edge of clk signal. If it is set, the data gets sample on falling edge of the clock -&amp;gt; and that&amp;#39;s what the microphone on the shield expects. We cannot make nrf5340 to fulfil this expectation, but we can change what the mic expects. &lt;/span&gt;&lt;/p&gt;
&lt;p&gt;Figure 2 in mic&amp;#39;s&amp;nbsp;&lt;a title="datasheet" href="https://www.st.com/resource/en/datasheet/imp34dt05.pdf"&gt;datasheet&lt;/a&gt;&amp;nbsp;is the key. It says that if the L/R input of the mic is connected to GND, data bit is send on falling edge of the clk. If L/R is connected to Vdd, rising edge is used instead. Datasheet of the&amp;nbsp;&lt;a href="https://www.st.com/resource/en/user_manual/um2633-getting-started-with-the-xnucleoiks02a1-industrial-motion-mems-sensor-expansion-board-for-stm32-nucleo-stmicroelectronics.pdf"&gt;shield&lt;/a&gt;&amp;nbsp;reveals that L/R is connected to GND by default. But if you close SB30 and open SB28, L/R gets connect to Vdd. Thanks to that data bit should be send on rising edge of the clk and thus&amp;nbsp;I2S_FMT_BIT_CLK_INV&amp;nbsp;wouldn&amp;#39;t be needed.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;I will have a chance to test this with the actual HW later next week. You&amp;#39;re more than welcome to try it too, but don&amp;#39;t yell at me if it does not work &lt;span class="emoticon" data-url="https://devzone.nordicsemi.com/cfs-file/__key/system/emoji/1f604.svg" title="Smile"&gt;&amp;#x1f604;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;Ladivin&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: X-NUCLEO-IK02A1 Microphone Example: dmic_configure returns -22</title><link>https://devzone.nordicsemi.com/thread/441808?ContentTypeID=1</link><pubDate>Thu, 17 Aug 2023 09:54:48 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:41904b37-188f-420d-8a11-03c88aba9be4</guid><dc:creator>Kenneth</dc:creator><description>&lt;p&gt;Interesting, I can see that in mpxxdtyy-i2s.c it configure inverted bit clock, ref in mpxxdtyy_i2s_configure():&lt;br /&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; i2s_cfg.format = I2S_FMT_DATA_FORMAT_LEFT_JUSTIFIED |&amp;nbsp;&lt;strong&gt;I2S_FMT_BIT_CLK_INV&lt;/strong&gt;;&lt;br /&gt;&lt;br /&gt;This&amp;nbsp;I2S_FMT_BIT_CLK_INV configuration is not supported by our I2S hardware, which I assume why it throws an error. But I don&amp;#39;t understand why the bit clock needs to be inverted, isn&amp;#39;t this just controlling left and right channel?&lt;br /&gt;&lt;br /&gt;Kenneth&lt;br /&gt;&lt;br /&gt;&lt;/p&gt;
&lt;div&gt;&lt;/div&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: X-NUCLEO-IK02A1 Microphone Example: dmic_configure returns -22</title><link>https://devzone.nordicsemi.com/thread/441718?ContentTypeID=1</link><pubDate>Wed, 16 Aug 2023 20:43:36 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:101dd674-688e-49c5-a525-77659a81eea6</guid><dc:creator>Quintin H.</dc:creator><description>&lt;p&gt;I debugged&amp;nbsp;&lt;span&gt;\zephyr\drivers\audio\mpxxdtyy-i2s.c and found that the EINVAL was triggered from the the value that came from the i2s_configure function as seen below:&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;ret = i2s_configure(config-&amp;gt;comm_master, I2S_DIR_RX, &amp;amp;i2s_cfg);
	if (ret != 0) {
		LOG_ERR(&amp;quot;I2S device configuration error&amp;quot;);
		return ret;
	}&lt;/pre&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Looking into it deeper I edited my pr.conf file to set CONFIG_LOG=y and&amp;nbsp; debugged zephyr\drivers\i2s\i2s_nrfx.c. I am getting two LOG_ERR messages.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;pre class="ui-code" data-mode="text"&gt;[00:00:00.444,732] &amp;lt;err&amp;gt; i2s_nrfx: Unsupported stream format: 0x13
[00:00:00.444,732] &amp;lt;err&amp;gt; mpxxdtyy: I2S device configuration error
microphone configuration error -22&lt;/pre&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;The i2s_nrfx error was generated from the snippet below:&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;if ((i2s_cfg-&amp;gt;format &amp;amp; I2S_FMT_DATA_ORDER_LSB) ||
	    (i2s_cfg-&amp;gt;format &amp;amp; I2S_FMT_BIT_CLK_INV) ||
	    (i2s_cfg-&amp;gt;format &amp;amp; I2S_FMT_FRAME_CLK_INV)) {
		LOG_ERR(&amp;quot;Unsupported stream format: 0x%02x&amp;quot;, i2s_cfg-&amp;gt;format);
		return -EINVAL;
	}&lt;/pre&gt;&lt;/span&gt;&lt;/p&gt;
&lt;div&gt;
&lt;div&gt;&lt;span&gt;i2s_cfg&lt;/span&gt;&lt;span&gt;-&amp;gt;&lt;/span&gt;&lt;span&gt;format = 19 &amp;#39;\023&amp;#39;&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: X-NUCLEO-IK02A1 Microphone Example: dmic_configure returns -22</title><link>https://devzone.nordicsemi.com/thread/441607?ContentTypeID=1</link><pubDate>Wed, 16 Aug 2023 12:31:14 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:f18c7347-5aa7-4a4e-a5a8-1173f9afcc7b</guid><dc:creator>Kenneth</dc:creator><description>&lt;p&gt;Dont&amp;#39; know, but do debugging&amp;nbsp;\zephyr\drivers\audio\mpxxdtyy-i2s.c provide any more insight to&amp;nbsp;what parameter(s) trigger&amp;nbsp;EINVAL?&lt;/p&gt;
&lt;p&gt;Kenneth&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>