<?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 Zephyr SDOUT not working</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/84603/i2s-zephyr-sdout-not-working</link><description>I am trying to get I2S communication up and running but am unable to produce a signal on my SDOUT pin. MCLK, LRCLK and SCLK work as intended but trying to send any data does not work. I did notice that the TXD.PTR register is empty. I have tried multiple</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Wed, 23 Feb 2022 12:54:34 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/84603/i2s-zephyr-sdout-not-working" /><item><title>RE: I2S Zephyr SDOUT not working</title><link>https://devzone.nordicsemi.com/thread/354570?ContentTypeID=1</link><pubDate>Wed, 23 Feb 2022 12:54:34 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:d95b1223-ddbb-47c6-bce4-c95b363c3ecb</guid><dc:creator>Edvin</dc:creator><description>&lt;p&gt;I did some more testing, removing the break and testing with the logic analyzer. This is the main.c I ended up using:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;/*
 * Copyright (c) 2020 Nordic Semiconductor ASA
 *
 * SPDX-License-Identifier: LicenseRef-Nordic-5-Clause
 */

#include &amp;lt;zephyr.h&amp;gt;
#include &amp;lt;drivers/gpio.h&amp;gt;
#include &amp;lt;init.h&amp;gt;
#include &amp;lt;nrf.h&amp;gt;
#include &amp;lt;nrfx.h&amp;gt;
#include &amp;lt;nrfx_gpiote.h&amp;gt;
#include &amp;lt;drivers/i2s.h&amp;gt;
#include &amp;quot;nrfx_i2s.h&amp;quot;
#include &amp;lt;errno.h&amp;gt;
#include &amp;lt;string.h&amp;gt;
#include &amp;lt;logging/log.h&amp;gt;
#include &amp;lt;dk_buttons_and_leds.h&amp;gt;

LOG_MODULE_REGISTER(Main);

#define AUDIO_SAMPLE_FREQ (44100)
#define AUDIO_NUM_CHANNELS (1)
#define AUDIO_SAMPLE_BIT_WIDTH (16)
#define AUDIO_SAMPLES_PER_CH_PER_FRAME (128)
#define AUDIO_SAMPLES_PER_FRAME (AUDIO_SAMPLES_PER_CH_PER_FRAME * AUDIO_NUM_CHANNELS)
#define AUDIO_SAMPLE_BYTES (sizeof(uint16_t))
#define AUDIO_FRAME_BUF_BYTES (AUDIO_SAMPLES_PER_FRAME * AUDIO_SAMPLE_BYTES)
#define I2S_PLAY_BUF_COUNT (500)

#define RUN_STATUS_LED DK_LED1
#define TEST_LED1 DK_LED1
#define TEST_LED2 DK_LED2
#define TEST_LED3 DK_LED3
#define TEST_LED4 DK_LED4
#define TEST_COUNT  10

static const struct device *host_i2s_tx_dev;
static struct k_mem_slab i2s_tx_mem_slab;
static char tx_buffer[AUDIO_FRAME_BUF_BYTES * I2S_PLAY_BUF_COUNT];
static struct i2s_config config;
volatile int ret;



static void init(void)
{
	host_i2s_tx_dev = device_get_binding(&amp;quot;I2S_0&amp;quot;);

	k_mem_slab_init(&amp;amp;i2s_tx_mem_slab, tx_buffer, AUDIO_FRAME_BUF_BYTES, I2S_PLAY_BUF_COUNT);
	//if (ret &amp;lt; 0)
	{
		LOG_INF(&amp;quot;mem slab init: %d&amp;quot;, ret);
	}

	config.word_size = AUDIO_SAMPLE_BIT_WIDTH;
	config.channels = AUDIO_NUM_CHANNELS;
	//config.format = I2S_FMT_DATA_FORMAT_I2S;
    config.format = I2S_FMT_DATA_FORMAT_LEFT_JUSTIFIED;
	config.options = (I2S_OPT_BIT_CLK_MASTER | I2S_OPT_FRAME_CLK_MASTER);
	config.frame_clk_freq = AUDIO_SAMPLE_FREQ;
	config.block_size = AUDIO_FRAME_BUF_BYTES;
	config.mem_slab = &amp;amp;i2s_tx_mem_slab;
	config.timeout = 1000;

	ret = i2s_configure(host_i2s_tx_dev, I2S_DIR_TX, &amp;amp;config);
	//if (ret &amp;lt; 0)
	{
		LOG_INF(&amp;quot;tx config: %d&amp;quot;, ret);
	}
}

void main(void)

{
    uint32_t counter = 0;
	init();

    LOG_INF(&amp;quot;I2S sample started&amp;quot;);



	uint16_t buf[128];
	size_t size = sizeof(buf);

	int i;
	for (i = 0; i &amp;lt; size; i++)
	{
		if (i &amp;lt;= size / 4)
		{
			buf[i] = i;
		}
		else if (i &amp;gt; size / 4)
		{
			buf[i] = size / 2 - i;
		}
	}
    LOG_INF(&amp;quot;0x%04x&amp;quot;, buf[0]);
    LOG_INF(&amp;quot;0x%04x&amp;quot;, buf[1]);
    LOG_INF(&amp;quot;0x%04x&amp;quot;, buf[2]);
    LOG_INF(&amp;quot;0x%04x&amp;quot;, buf[3]);
    LOG_INF(&amp;quot;0x%04x&amp;quot;, buf[4]);

	void *tx_mem_block;



    ret = 0;
    
	while ((ret == 0) &amp;amp;&amp;amp; (counter &amp;lt; TEST_COUNT))
	{

       	ret = i2s_trigger(host_i2s_tx_dev, I2S_DIR_TX, I2S_TRIGGER_START);
        if (ret &amp;lt; 0)
        {
            LOG_INF(&amp;quot;trigger: %d&amp;quot;, ret);
            break;
        }


		ret = k_mem_slab_alloc(&amp;amp;i2s_tx_mem_slab, &amp;amp;tx_mem_block, K_NO_WAIT);
		if (ret &amp;lt; 0)
		{
			LOG_INF(&amp;quot;mem slab alloc: %d&amp;quot;, ret);
            break;
		}


		memcpy(tx_mem_block, buf, size);

        ret = i2s_write(host_i2s_tx_dev, tx_mem_block, size);
		if (ret != 0)
		{
			LOG_INF(&amp;quot;write: %d&amp;quot;, ret);
            break;
		}
		
		k_mem_slab_free(&amp;amp;i2s_tx_mem_slab, &amp;amp;tx_mem_block);
        counter++;
        LOG_INF(&amp;quot;counter %d&amp;quot;, counter);
	}
    while (true)
    {
        k_sleep(K_SECONDS(1));
        LOG_INF(&amp;quot;done, counter = %d&amp;quot;, counter);
    }
}&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;I am not familiar with I2S, and how to use it, but running it on an nRF5340DK, I get data on the DOUT pin:&lt;/p&gt;
&lt;p&gt;&lt;img src="https://devzone.nordicsemi.com/resized-image/__size/320x240/__key/communityserver-discussions-components-files/4/pastedimage1645620743870v1.png" alt=" " /&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;The reason I changed&amp;nbsp;&lt;/p&gt;
&lt;div&gt;
&lt;div&gt;&lt;span&gt;config.format = I2S_FMT_DATA_FORMAT_I2S&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt;to&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;div&gt;
&lt;div&gt;&lt;span&gt;config&lt;/span&gt;&lt;span&gt;.&lt;/span&gt;&lt;span&gt;format&lt;/span&gt;&lt;span&gt; = &lt;/span&gt;&lt;span&gt;I2S_FMT_DATA_FORMAT_LEFT_JUSTIFIED&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt;was just so that I could see that the data was correct in the logic analyzer. There was data on the DOUT pin before I changed it as well.&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: I2S Zephyr SDOUT not working</title><link>https://devzone.nordicsemi.com/thread/354469?ContentTypeID=1</link><pubDate>Wed, 23 Feb 2022 07:29:59 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:2caccc10-73ed-42c6-bde9-3e0cbee15ef3</guid><dc:creator>Edvin</dc:creator><description>&lt;p&gt;Can you please try to replace your while loop with this:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;    ret = 0;
	while (!ret)
	{
		ret = k_mem_slab_alloc(&amp;amp;i2s_tx_mem_slab, &amp;amp;tx_mem_block, K_NO_WAIT);
		if (ret &amp;lt; 0)
		{
			LOG_INF(&amp;quot;mem slab alloc: %d&amp;quot;, ret);
		}

		memcpy(tx_mem_block, buf, size);

	    ret = i2s_trigger(host_i2s_tx_dev, I2S_DIR_TX, I2S_TRIGGER_START);
	    if (ret &amp;lt; 0)
	    {
            LOG_INF(&amp;quot;trigger: %d&amp;quot;, ret);
        }

		ret = i2s_write(host_i2s_tx_dev, tx_mem_block, size);
		if (ret &amp;lt; 0)
		{
			LOG_INF(&amp;quot;write: %d&amp;quot;, ret);
		}

		k_mem_slab_free(&amp;amp;i2s_tx_mem_slab, &amp;amp;tx_mem_block);
	}
    while (true)
    {
        LOG_INF(&amp;quot;done&amp;quot;);
        k_sleep(K_SECONDS(1));
    }
}&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;Is the last loop ever reached?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: I2S Zephyr SDOUT not working</title><link>https://devzone.nordicsemi.com/thread/354421?ContentTypeID=1</link><pubDate>Tue, 22 Feb 2022 17:03:43 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:2f1aac6e-695a-4794-bc1c-9ad29dd21c66</guid><dc:creator>jspiller</dc:creator><description>&lt;p&gt;Hi,&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Yes I did take a look at the sample projects there but unfortunately they did not work on my board. Not sure if something is being configured incorrectly or where the issue is stemming from. I had a delay at first but then it gave me the I2S_STATE_ERROR until I removed it. The state that I sent my code in ran for me with all returns of 0.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: I2S Zephyr SDOUT not working</title><link>https://devzone.nordicsemi.com/thread/354382?ContentTypeID=1</link><pubDate>Tue, 22 Feb 2022 14:11:26 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:58e2cc25-69e0-489f-8d74-99765b03d688</guid><dc:creator>Edvin</dc:creator><description>&lt;p&gt;Hello,&lt;/p&gt;
&lt;p&gt;So I was able to change the project so that I was able to compile without your custom files, and so that it ran on my nRF53DK &amp;quot;without errors&amp;quot;.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Did you check the return&amp;nbsp;value from&amp;nbsp;i2s_write()? (It didn&amp;#39;t print until I added &amp;quot;k_sleep(K_SECONDS(1))&amp;quot; to the end of your while loop (for the log to be processed), but in my case it returns -5 and prints &amp;quot;Cannot write in state: 4&amp;quot;,&amp;nbsp; where 4 refers to&amp;nbsp;I2S_STATE_ERROR.&lt;/p&gt;
&lt;div&gt;
&lt;div&gt;&lt;span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;I haven&amp;#39;t gotten to play around with I2S in NCS that much. Did you test the sample found in NCS\zephyr\samples\drivers\i2s?&lt;/div&gt;
&lt;div&gt;&lt;/div&gt;
&lt;div&gt;Best regards,&lt;/div&gt;
&lt;div&gt;Edvin&lt;/div&gt;
&lt;/div&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: I2S Zephyr SDOUT not working</title><link>https://devzone.nordicsemi.com/thread/353164?ContentTypeID=1</link><pubDate>Tue, 15 Feb 2022 16:17:40 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:00baacc0-8afb-4ce7-a327-26ad2b02adc9</guid><dc:creator>jspiller</dc:creator><description>&lt;p&gt;Yes I use nrf connect for VS code, and I just recently tried it in an unmodified SDK. It runs without any errors for me but the DOUT line remains low while the clocks function.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: I2S Zephyr SDOUT not working</title><link>https://devzone.nordicsemi.com/thread/353111?ContentTypeID=1</link><pubDate>Tue, 15 Feb 2022 13:40:04 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:a65d6712-6909-4e2c-a8e4-6873e51270c5</guid><dc:creator>Edvin</dc:creator><description>&lt;p&gt;Hello,&lt;/p&gt;
&lt;p&gt;How do you build your project? Do you use nRF Connect for VS Code? If so, can you please try to unzip it to an unmodified SDK and see if you can compile it? (I tried both this and using West from the command line, but in both cases, I get a ZEPHYR_FATAL_ERROR:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;00&amp;gt; [00:00:00.281,000] &amp;lt;err&amp;gt; fatal_error: Resetting system
00&amp;gt; [00:00:00.004,000] &amp;lt;err&amp;gt; os: ***** BUS FAULT *****
00&amp;gt; [00:00:00.004,000] &amp;lt;err&amp;gt; os:   Instruction bus error
00&amp;gt; 
00&amp;gt; [00:00:00.004,000] &amp;lt;err&amp;gt; os: r0/a1:  0x00000000  r1/a2:  0x00000001  r2/a3:  0x200002f8
00&amp;gt; [00:00:00.004,000] &amp;lt;err&amp;gt; os: r3/a4:  0x2ef7fbb5 r12/ip:  0xffffffff r14/lr:  0x000004a5
00&amp;gt; [00:00:00.004,000] &amp;lt;err&amp;gt; os:  xpsr:  0x69000000
00&amp;gt; [00:00:00.004,000] &amp;lt;err&amp;gt; os: Faulting instruction address (r15/pc): 0x2ef7fbb4
00&amp;gt; [00:00:00.004,000] &amp;lt;err&amp;gt; os: &amp;gt;&amp;gt;&amp;gt; ZEPHYR FATAL ERROR 0: CPU exception on CPU 0
00&amp;gt; [00:00:00.004,000] &amp;lt;err&amp;gt; os: Current thread: 0x20000270 (unknown)
00&amp;gt; [00:00:00.281,000] &amp;lt;err&amp;gt; fatal_error: Resetting system
00&amp;gt; [00:00:00.004,000] &amp;lt;err&amp;gt; os: ***** BUS FAULT *****
00&amp;gt; [00:00:00.004,000] &amp;lt;err&amp;gt; os:   Instruction bus error
00&amp;gt; [00:00:00.004,000] &amp;lt;err&amp;gt; os: r0/a1:  0x00000000  r1/a2:  0x00000001  r2/a3:  0x200002f8
00&amp;gt; [00:00:00.004,000] &amp;lt;err&amp;gt; os: r3/a4:  0x2ef7fbb5 r12/ip:  0xffffffff r14/lr:  0x000004a5[0m
00&amp;gt; [00:00:00.004,000] &amp;lt;err&amp;gt; os:  xpsr:  0x69000000
00&amp;gt; [00:00:00.004,000] &amp;lt;err&amp;gt; os: Faulting instruction address (r15/pc): 0x2ef7fbb4
00&amp;gt; [00:00:00.004,000] &amp;lt;err&amp;gt; os: &amp;gt;&amp;gt;&amp;gt; ZEPHYR FATAL ERROR 0: CPU exception on CPU 0
00&amp;gt; [00:00:00.004,000] &amp;lt;err&amp;gt; os: Current thread: 0x20000270 (unknown)
00&amp;gt; [00:00:00.281,000] &amp;lt;err&amp;gt; fatal_error: Resetting system
00&amp;gt; [00:00:00.004,000] &amp;lt;err&amp;gt; os: ***** BUS FAULT *****
00&amp;gt; [00:00:00.004,000] &amp;lt;err&amp;gt; os:   Instruction bus error
00&amp;gt; [00:00:00.004,000] &amp;lt;err&amp;gt; os: r0/a1:  0x00000000  r1/a2:  0x00000001  r2/a3:  0x200002f8
00&amp;gt; [00:00:00.004,000] &amp;lt;err&amp;gt; os: r3/a4:  0x2ef7fbb5 r12/ip:  0xffffffff r14/lr:  0x000004a5
00&amp;gt; [00:00:00.004,000] &amp;lt;err&amp;gt; os:  xpsr:  0x69000000
00&amp;gt; [00:00:00.004,000] &amp;lt;err&amp;gt; os: Faulting instruction address (r15/pc): 0x2ef7fbb4
00&amp;gt; [00:00:00.004,000] &amp;lt;err&amp;gt; os: &amp;gt;&amp;gt;&amp;gt; ZEPHYR FATAL ERROR 0: CPU exception on CPU 0&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;I didn&amp;#39;t look into what it points to, but I want to check whether you get the same when you are using the DK?&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Best regards,&lt;/p&gt;
&lt;p&gt;Edvin&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: I2S Zephyr SDOUT not working</title><link>https://devzone.nordicsemi.com/thread/352966?ContentTypeID=1</link><pubDate>Mon, 14 Feb 2022 16:54:07 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:8b6326eb-3b56-46d7-ae4a-7a5f3efc7397</guid><dc:creator>jspiller</dc:creator><description>&lt;p&gt;Yes I forgot to mention I am using a DK, and yes this happens with no other peripherals attached to it.&lt;/p&gt;
&lt;p&gt;&lt;a href="https://devzone.nordicsemi.com/cfs-file/__key/communityserver-discussions-components-files/4/nRF5340_5F00_i2s_5F00_test.zip"&gt;devzone.nordicsemi.com/.../nRF5340_5F00_i2s_5F00_test.zip&lt;/a&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: I2S Zephyr SDOUT not working</title><link>https://devzone.nordicsemi.com/thread/352923?ContentTypeID=1</link><pubDate>Mon, 14 Feb 2022 14:05:15 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:892d3264-7ea7-4e9e-abeb-82f3a92c1788</guid><dc:creator>Edvin</dc:creator><description>&lt;p&gt;Hello,&lt;/p&gt;
&lt;p&gt;Would it be possible for me to reproduce this on a DK? Are you able to replicate this without any external I2C devices? If so, can you please send the project here? (Or if you can&amp;#39;t share, please strip the project down to something smaller that is able to replicate the issue).&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Best regards,&lt;/p&gt;
&lt;p&gt;Edvin&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: I2S Zephyr SDOUT not working</title><link>https://devzone.nordicsemi.com/thread/352421?ContentTypeID=1</link><pubDate>Thu, 10 Feb 2022 16:34:00 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:7ed5521b-84e6-4167-88f2-ea1080143e99</guid><dc:creator>jspiller</dc:creator><description>&lt;p&gt;Hi thank you for your response,&lt;/p&gt;
&lt;p&gt;I tried on GPIO 36, 26, 0, 2 ,3. Removing &amp;quot;&amp;amp;&amp;quot; gives the same result unfortunately, and yes the data is properly populated within tx_mem_block before i2s_write() is called. To view the TXD.PTR I use &amp;quot;Cortex-Debug: View Memory&amp;quot; then set the address to&amp;nbsp;&lt;span&gt;0x5002850C since&amp;nbsp;0x50028000 is the base address. I used this method to check the other registers&amp;nbsp;and they all seem to be set correctly.&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: I2S Zephyr SDOUT not working</title><link>https://devzone.nordicsemi.com/thread/352343?ContentTypeID=1</link><pubDate>Thu, 10 Feb 2022 13:27:52 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:38574258-25cd-4276-942b-ce63d7402905</guid><dc:creator>Edvin</dc:creator><description>&lt;p&gt;Hello,&lt;/p&gt;
&lt;p&gt;What pins were you origninally use when the SDOUT didn&amp;#39;t work? I know you say you have tried multiple pins, but perhaps you were unlucky.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Have you tried printing the tx_mem_block before you pass it on in i2s_write? Is it properly populated? Are you sure you need the &amp;quot;&amp;amp;&amp;quot; on &amp;quot;&amp;amp;buf&amp;quot; when buf is an array? Try without.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;How did you check the TXD.PTR register and decide that it was empty?&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Best regards,&lt;/p&gt;
&lt;p&gt;Edvin&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>