<?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>I2S clocks and softdevice</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/65863/i2s-clocks-and-softdevice</link><description>I am on Ubuntu 20.04 with SES 5.42c, SDK 16, and SoftDevice S140 version 7.0.1 I am using a Knowles SPH0645LM4H. I have put together a beacon that operates the microphone via I2S. I2S is configured in slave mode and i use PWM to generate SCK and LRCK</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Mon, 14 Sep 2020 01:51:36 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/65863/i2s-clocks-and-softdevice" /><item><title>RE: I2S clocks and softdevice</title><link>https://devzone.nordicsemi.com/thread/269269?ContentTypeID=1</link><pubDate>Mon, 14 Sep 2020 01:51:36 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:cc80bf7c-216c-4dff-9e33-9d8feaefb51b</guid><dc:creator>matty</dc:creator><description>&lt;p&gt;After I call nrfx_i2s_stop, an assertion is thrown in the I2S data handler. For some reason the data handler seems to be called by the I2S peripheral even after nrfx_i2s_stop is called. The assertion is NRF_ERROR 8 - Invalid State on&amp;nbsp;a&amp;nbsp;nrfx_i2s_next_buffers_set call. The invalid state is defined as either the buffers have already been supplied or the peripheral is currently being stopped.&amp;nbsp;The way I fixed this was to wrap the code in the&amp;nbsp;i2s_data_handler in an&amp;nbsp;if (status &amp;amp; NRFX_t2S_STATUS_NEXT_BUFFERS_NEEDED) condition.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;My understanding is that the data handler&amp;#39;s 2nd in parameter, status, will be either 0 or NRFX_I2S_STATUS_NEXT_BUFFERS_NEEDED. Although I have read about a second value called NRFX_I2S_STATUS_TRANSFER_STOPPED in Drivers-&amp;gt;nrfx v2.3. That value isn&amp;#39;t available in my environment.&lt;/p&gt;
&lt;p&gt;So it works now and my problem had nothing to do with clocks or the softdevice. However, I have yet to figure out how the code worked in a none BLE application. Back to work.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: I2S clocks and softdevice</title><link>https://devzone.nordicsemi.com/thread/269266?ContentTypeID=1</link><pubDate>Sun, 13 Sep 2020 17:48:09 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:ecf4abc0-0795-4211-a9e4-84756f958ace</guid><dc:creator>matty</dc:creator><description>&lt;p&gt;I can&amp;#39;t decide if the call to&amp;nbsp;nrfx_i2s_stop() is causing the firmware reset or if its the return back to main after my I2S function finishes. I&amp;#39;d think it was my program structure that is at fault but why can&amp;#39;t I have all of the I2S code in a separate module and leave main out of it. The worse thing I&amp;#39;m doing is having main wait for the function to return and that period is a little more than 500 mS.&lt;/p&gt;
&lt;p&gt;I have slightly changed the above code to alternate calls to nrfx_i2s_stop() I don&amp;#39;t call nrfx_i2s_stop before returning to main but I call it at the beginning of the second time main wants to use the microphone. The following screen shot illustrates the results.&lt;/p&gt;
&lt;p&gt;&lt;img alt=" " src="https://devzone.nordicsemi.com/resized-image/__size/320x240/__key/communityserver-discussions-components-files/4/alternating_5F00_i2s_2D00_start_5F00_stop.png" /&gt;&lt;/p&gt;
&lt;p&gt;Point 1) Otii powers up and firmware starts.&lt;/p&gt;
&lt;p&gt;Point 2) main&amp;#39;s timer triggers a call to &amp;quot;i2s_mic_generate_an_spl&amp;quot;. main waits for it to return.&lt;/p&gt;
&lt;p&gt;Point 3) &amp;quot;i2s_mic_generate_an_spl&amp;quot; starts the PWM &amp;quot;clocks&amp;quot;. It starts a 500 mS app_timer to give the microphone a half second to stabilize.&lt;/p&gt;
&lt;p&gt;Point 4) nrfx_i2s_start is called. &amp;quot;i2s_mic_generate_an_spl&amp;quot; waits until the I2S data handler has toggled a flag signalling that data collection is complete. On this first call, &amp;quot;i2s_mic_generate_an_spl&amp;quot; then stops the PWM &amp;quot;clocks&amp;quot; but &lt;span style="text-decoration:underline;"&gt;does not&lt;/span&gt; call nrfx_i2s_stop. &amp;quot;i2s_mic_generate_an_spl&amp;quot; returns to main.&lt;/p&gt;
&lt;p&gt;Point 5) Back in main. Note the elevated power level. Don&amp;#39;t know what causes that. There must be a clock associated with the nrfx_i2s_start call still running.&lt;/p&gt;
&lt;p&gt;Point 6) main makes it&amp;#39;s&amp;nbsp;timer induced advertisement.&lt;/p&gt;
&lt;p&gt;Point 7) main&amp;#39;s timer triggers the second call to &amp;quot;i2s_mic_generate_an_spl&amp;quot; and waits for it to return.&lt;/p&gt;
&lt;p&gt;Point 8) In this second call, the first thing &amp;quot;i2s_mic_generate_an_spl&amp;quot; does is call nrfx_i2s_stop.&amp;nbsp;It would then start the PWM &amp;quot;clocks&amp;quot;, wait on it&amp;#39;s timer, call nrfx_i2s_start, wait for the I2S data handler to toggle the flag etc.. Obviously, there is no PWM, no I2S, etc...&lt;/p&gt;
&lt;p&gt;Point 9) Firm ware reset and repeat of sequence.&lt;/p&gt;
&lt;p&gt;I&amp;#39;m doing something that isn&amp;#39;t allowed. I just can&amp;#39;t figure out what it is. I&amp;#39;m hoping its something obvious to more experienced folk and greatly appreciate their observations and thoughts.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>