<?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>nRF52840 I2S write failed -11</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/116766/nrf52840-i2s-write-failed--11</link><description>Hello, 
 I am using two nrf52840 DKs to test ble transmission and i2s output. The nRF Connect SDK I use is v2.6.0. 
 Both of them are ble connected. One sends data to the other through ble, and the other receives the data and outputs it to i2s. 
 The</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Fri, 17 Jan 2025 07:11:55 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/116766/nrf52840-i2s-write-failed--11" /><item><title>RE: nRF52840 I2S write failed -11</title><link>https://devzone.nordicsemi.com/thread/518770?ContentTypeID=1</link><pubDate>Fri, 17 Jan 2025 07:11:55 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:03bdfffe-067c-4885-8093-f169ceb5689a</guid><dc:creator>Vidar Berg</dc:creator><description>&lt;p&gt;Thank you for the update. You would probably have been able to play the stream uninterrupted a bit longer if you had queued up more audio packets before triggering the start signal. However,&amp;nbsp;this doesn&amp;#39;t really help when you want a continuous audio stream to work uninterrupted over time. LE Audio is more suitable for this.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nRF52840 I2S write failed -11</title><link>https://devzone.nordicsemi.com/thread/518768?ContentTypeID=1</link><pubDate>Fri, 17 Jan 2025 07:01:18 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:72d2449f-75f4-4992-bc2b-abd227b62c05</guid><dc:creator>LandyWang</dc:creator><description>[quote userid="4240" url="~/f/nordic-q-a/116766/nrf52840-i2s-write-failed--11/517437"]Have you tried filling up your TX&amp;nbsp;i2s queue by calling i2s_buf_write() multiple times before issuing the I2S_TRIGGER_START command?&amp;nbsp;[/quote]
&lt;p&gt;I only called i2s_buf_write() once before I2S_TRIGGER_START, and all other i2s_buf_write() calls were made after I2S_TRIGGER_START.&lt;/p&gt;
&lt;p&gt;Actually, I wanted to use regular BLE to achieve the goal of long-term continuous audio playback, but now it seems that it is not feasible and I still have to use LE Audio to achieve it.&lt;/p&gt;
&lt;p&gt;I think this is the end of the test, thank you for your assistance.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nRF52840 I2S write failed -11</title><link>https://devzone.nordicsemi.com/thread/517437?ContentTypeID=1</link><pubDate>Wed, 08 Jan 2025 10:57:28 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:cbc628ac-1eaf-4d56-b72e-2bc8ba3eaa03</guid><dc:creator>Vidar Berg</dc:creator><description>&lt;p&gt;It&amp;nbsp;looks like&amp;nbsp;the BLE throughput and buffer handling are not fast enough to&amp;nbsp;provide continuous playback of your audio. The app must&amp;nbsp;be able to keep the i2s buffers filled&amp;nbsp;for uninterrupted playback and the error you got below indicates that this is not the case.&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;[00:00:25.560,302] &amp;lt;err&amp;gt; i2s_nrfx: Next buffers not supplied on time&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;You&amp;nbsp;should be able to use&amp;nbsp;I2S_TRIGGER_PREPARE command to recover from this error state. However,&amp;nbsp;it will still lead to interrupts in your playback.&lt;/p&gt;
&lt;p&gt;Have you tried filling up your TX&amp;nbsp;i2s queue by calling i2s_buf_write() multiple times before issuing the I2S_TRIGGER_START command?&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Also, I would recommend&amp;nbsp;evaluating&amp;nbsp;LE audio (&lt;a href="https://docs.nordicsemi.com/bundle/ncs-latest/page/nrf/applications/nrf5340_audio/index.html"&gt;https://docs.nordicsemi.com/bundle/ncs-latest/page/nrf/applications/nrf5340_audio/index.html&lt;/a&gt;) if your&amp;nbsp;application requires streaming of audio. Regular BLE may be suitable if you only need to receive short audio sequences.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nRF52840 I2S write failed -11</title><link>https://devzone.nordicsemi.com/thread/514390?ContentTypeID=1</link><pubDate>Wed, 11 Dec 2024 01:58:20 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:ef3b72c6-f0b5-4eca-9744-2efecc5b4a53</guid><dc:creator>LandyWang</dc:creator><description>&lt;p&gt;Thank you for your assistance.&lt;/p&gt;
&lt;p&gt;I added debug at the end of i2s_nrfx_write to output the state after successful writing.&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;[00:00:38.656,372] &amp;lt;inf&amp;gt; i2s_nrfx: After Write state: 1
[00:00:38.657,501] &amp;lt;inf&amp;gt; i2s_nrfx: After Write state: 2&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;It seems that the state after successful writing is I2S_STATE_RUNNING, but the next write will change to I2S_STATE_ERROR.&lt;/p&gt;
&lt;p&gt;I don&amp;#39;t know what happened to cause this state to change.&lt;/p&gt;
&lt;p&gt;In &lt;a title="this post" href="https://devzone.nordicsemi.com/f/nordic-q-a/116122/how-to-play-pcm-raw-data-on-nrf52840-dk-through-i2s"&gt;this post&lt;/a&gt; where I&amp;#39;ve asked the question, this problem does not occur. The difference between them is that &lt;a title="this post" href="https://devzone.nordicsemi.com/f/nordic-q-a/116122/how-to-play-pcm-raw-data-on-nrf52840-dk-through-i2s"&gt;this post&lt;/a&gt; uses i2s to play the same pcm data, so mem_block only needs to be written once and does not need to be changed subsequently. My current case is that mem_block needs to be changed every time before writing to i2s. Could this problem be caused by changes in mem_block?&lt;/p&gt;
&lt;p&gt;Let me restate my problem. As I said at the beginning, if I use i2s_write and add i2s_trigger (i2s_dev_tx, I2S_DIR_TX, I2S_TRIGGER_STOP) after each successful write, there will be no errors and continuous writes will be successful, but the sound will be intermittent.&lt;/p&gt;
&lt;p&gt;In fact, what I want to solve is the intermittent problem caused by I2S_TRIGGER_STOP, but removing I2S_TRIGGER_STOP will cause these problems. Is there any other way to solve this intermittent problem?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nRF52840 I2S write failed -11</title><link>https://devzone.nordicsemi.com/thread/514072?ContentTypeID=1</link><pubDate>Mon, 09 Dec 2024 14:57:18 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:f02783df-132b-470d-8716-1dd8f8f7c375</guid><dc:creator>Maria Gilje</dc:creator><description>&lt;p&gt;Hello,&lt;/p&gt;
&lt;p&gt;Susheel is away, so I am taking over in his absence.&lt;/p&gt;
&lt;p&gt;The errors you get now seems to originate from &lt;a href="https://github.com/nrfconnect/sdk-zephyr/blob/v3.5.99-ncs1/drivers/i2s/i2s_nrfx.c#L244"&gt;data_handler&lt;/a&gt; in the i2s_nrfx driver.&lt;/p&gt;
&lt;p&gt;The &lt;a href="https://github.com/nrfconnect/sdk-zephyr/blob/v3.5.99-ncs1/include/zephyr/drivers/i2s.h#L217"&gt;I2S state&lt;/a&gt; with value 4 is I2S_STATE_ERROR, and the return value of -5 is -EIO, which is returned from the &lt;a href="https://github.com/nrfconnect/sdk-zephyr/blob/v3.5.99-ncs1/include/zephyr/drivers/i2s.h#L505"&gt;i2s_buf_write&lt;/a&gt; if the I2S peripheral is not in the READY or RUNNING state.&lt;/p&gt;
&lt;p&gt;-EIO is returned when &lt;a href="https://github.com/nrfconnect/sdk-zephyr/blob/v3.5.99-ncs1/drivers/i2s/i2s_common.c#L36"&gt;i2s_config_get&lt;/a&gt; returns NULL. So your I2S device is unconfigured after the first write.&lt;/p&gt;
&lt;p&gt;Could you please debug the application and see what happens after the successful write?&lt;/p&gt;
&lt;p&gt;Best regards,&lt;/p&gt;
&lt;p&gt;Maria&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nRF52840 I2S write failed -11</title><link>https://devzone.nordicsemi.com/thread/513738?ContentTypeID=1</link><pubDate>Fri, 06 Dec 2024 02:16:58 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:aed93aaa-3093-41bb-96e4-6835bbab48ee</guid><dc:creator>LandyWang</dc:creator><description>&lt;p&gt;Thank you for your reply.&lt;/p&gt;
&lt;p&gt;After I used i2s_buf_write instead of i2s_write, the error I encountered changed.&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;[00:00:25.157,379] &amp;lt;inf&amp;gt; central_test: Success to write data.
[00:00:25.560,302] &amp;lt;err&amp;gt; i2s_nrfx: Next buffers not supplied on time
[00:00:28.159,210] &amp;lt;err&amp;gt; i2s_nrfx: Cannot write in state: 4
[00:00:28.159,240] &amp;lt;err&amp;gt; central_test: Failed to write block -5
[00:00:28.160,369] &amp;lt;err&amp;gt; i2s_nrfx: Cannot write in state: 4
[00:00:28.160,369] &amp;lt;err&amp;gt; central_test: Failed to write data: -5
[00:00:29.164,764] &amp;lt;err&amp;gt; i2s_nrfx: Cannot write in state: 4
[00:00:29.164,794] &amp;lt;err&amp;gt; central_test: Failed to write block -5
[00:00:29.165,832] &amp;lt;err&amp;gt; i2s_nrfx: Cannot write in state: 4
[00:00:29.165,863] &amp;lt;err&amp;gt; central_test: Failed to write data: -5
[00:00:31.160,522] &amp;lt;err&amp;gt; i2s_nrfx: Cannot write in state: 4
[00:00:31.160,552] &amp;lt;err&amp;gt; central_test: Failed to write block -5
[00:00:31.161,743] &amp;lt;err&amp;gt; i2s_nrfx: Cannot write in state: 4
[00:00:31.161,743] &amp;lt;err&amp;gt; central_test: Failed to write data: -5
[00:00:31.336,212] &amp;lt;err&amp;gt; i2s_nrfx: Cannot write in state: 4
[00:00:31.336,212] &amp;lt;err&amp;gt; central_test: Failed to write block -5
[00:00:31.337,280] &amp;lt;err&amp;gt; i2s_nrfx: Cannot write in state: 4
[00:00:31.337,280] &amp;lt;err&amp;gt; central_test: Failed to write data: -5
[00:00:31.546,203] &amp;lt;err&amp;gt; i2s_nrfx: Cannot write in state: 4
[00:00:31.546,234] &amp;lt;err&amp;gt; central_test: Failed to write block -5&lt;/pre&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nRF52840 I2S write failed -11</title><link>https://devzone.nordicsemi.com/thread/512967?ContentTypeID=1</link><pubDate>Mon, 02 Dec 2024 12:11:44 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:a445341d-630c-4281-beef-005431976555</guid><dc:creator>Susheel Nuguru</dc:creator><description>&lt;p&gt;Thanks for explaining that a bit clearer this time. Error code -11 corresponds to -EAGAIN, meaning the I2S buffer is full or unavailable. This happens because the I2S driver uses a double buffering mechanism. If you do fail to synchronize correctly, the buffer gets stuck in an unavailable state as this is a double buffered mechanism&lt;br /&gt;&lt;br /&gt;Monitor buffer availability something like below&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;
// Use i2s_buf_write() instead of i2s_write(), as it provides better handling for buffer availability and is non-blocking
ret = i2s_buf_write(i2s_dev_tx, mem_block, BLOCK_SIZE);
if (ret == -EAGAIN) {
    LOG_ERR(&amp;quot;I2S buffer full, retrying...&amp;quot;);
    // add logic here to attempt few retires based on the acceptance of your application
}
&lt;/pre&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nRF52840 I2S write failed -11</title><link>https://devzone.nordicsemi.com/thread/512541?ContentTypeID=1</link><pubDate>Thu, 28 Nov 2024 09:50:25 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:765cd980-f0f7-4171-ae1b-de3c126edaa9</guid><dc:creator>LandyWang</dc:creator><description>&lt;p&gt;Sorry, I didn&amp;#39;t express myself clearly.&lt;/p&gt;
&lt;p&gt;I am currently using one nrf52840DK to receive ble data from another nrf52840 DK. These ble data are a continuous piece of audio data.&lt;/p&gt;
&lt;p&gt;Then, I send the received data to i2s, which should theoretically output a continuous audio.&lt;/p&gt;
&lt;p&gt;I divide this data into many segments in units of 100ms, and then transmit it to i2s multiple times. Each time the data is transmitted, the following function will be called.&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;void i2s_send(void){
	int ret;
	memset(mem_block, 0, BLOCK_SIZE);
	ret = i2s_write(i2s_dev_tx, mem_block, BLOCK_SIZE);
	if (ret &amp;lt; 0) {
		LOG_ERR(&amp;quot;Failed to write block %d&amp;quot;, ret);
	}
	/* Put data into the tx buffer */
	for (int i = 0; i &amp;lt; 9600; i++) {
		((int16_t*)mem_block)[i] = (int16_t)data_buf_modify[i];
  	}
	ret = i2s_trigger(i2s_dev_tx, I2S_DIR_TX, I2S_TRIGGER_START);
	if (ret &amp;lt; 0) {
		LOG_ERR(&amp;quot;Failed to trigger command I2S_TRIGGER_START on TX: %d\n&amp;quot;, ret);
	}
	ret = i2s_write(i2s_dev_tx, mem_block, BLOCK_SIZE);
	if (ret &amp;lt; 0) {
		LOG_ERR(&amp;quot;Failed to write data: %d&amp;quot;, ret);
	}else{
		LOG_INF(&amp;quot;Success to write data.&amp;quot;);
	}
	ret = i2s_trigger(i2s_dev_tx, I2S_DIR_TX, I2S_TRIGGER_STOP);
	if (ret &amp;lt; 0) {
		LOG_ERR(&amp;quot;Failed to trigger command I2S_TRIGGER_DRAIN on TX: %d\n&amp;quot;, ret);
	}
}&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;The output result is noisy, and I think this is because there is an I2S_TIGGER_STOP every 100ms.&lt;/p&gt;
&lt;p&gt;I tried changing the function that writes i2s every 100ms to the following:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;void i2s_send(void){
	int ret;
	memset(mem_block, 0, BLOCK_SIZE);
	ret = i2s_write(i2s_dev_tx, mem_block, BLOCK_SIZE);
	if (ret &amp;lt; 0) {
		LOG_ERR(&amp;quot;Failed to write block %d&amp;quot;, ret);
	}
	/* Put data into the tx buffer */
	for (int i = 0; i &amp;lt; 9600; i++) {
		((int16_t*)mem_block)[i] = (int16_t)data_buf_modify[i];
  	}
  	//Only do this once
  	if(!has_started){
  	    ret = i2s_trigger(i2s_dev_tx, I2S_DIR_TX, I2S_TRIGGER_START);
	    if (ret &amp;lt; 0) {
		    LOG_ERR(&amp;quot;Failed to trigger command I2S_TRIGGER_START on TX: %d\n&amp;quot;, ret);
	    }
	    has_started = 1;
  	}
	ret = i2s_write(i2s_dev_tx, mem_block, BLOCK_SIZE);
	if (ret &amp;lt; 0) {
		LOG_ERR(&amp;quot;Failed to write data: %d&amp;quot;, ret);
	}else{
		LOG_INF(&amp;quot;Success to write data.&amp;quot;);
	}
}&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;The failed to write data error occurred.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nRF52840 I2S write failed -11</title><link>https://devzone.nordicsemi.com/thread/512522?ContentTypeID=1</link><pubDate>Thu, 28 Nov 2024 08:52:53 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:caccb581-e8ca-4fff-af18-78a19adb004c</guid><dc:creator>Susheel Nuguru</dc:creator><description>&lt;p&gt;&lt;span&gt; The I2S peripheral use double buffering for the Tx and Rx pointers, so interrupts or other things happening should not matter (as long as it does not take too long time compared to the buffer size). So it should definitely be possible to get this working. Can you help us reproduce this issue on the nrf52840 DK?&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>