<?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>nRF9161 DK and an I2S microphone</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/121084/nrf9161-dk-and-an-i2s-microphone</link><description>I&amp;#39;m trying to convert some code from ESP32 to nRF, and I&amp;#39;m having problems with the microphone input. Mind you, I&amp;#39;m a beginner with nRF, so I&amp;#39;m sure I&amp;#39;m missing something! 
 I have this in the prj.conf file: 
 and this nrf9161dk_nrf9161_ns.overlay: 
</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Wed, 21 May 2025 14:21:37 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/121084/nrf9161-dk-and-an-i2s-microphone" /><item><title>RE: nRF9161 DK and an I2S microphone</title><link>https://devzone.nordicsemi.com/thread/536480?ContentTypeID=1</link><pubDate>Wed, 21 May 2025 14:21:37 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:5d950c22-0bd7-43de-b7ed-17fea79e0408</guid><dc:creator>Einar Thorsrud</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;This is a limitation of the I2S peripheral on the nRF91 as well as nRF52 series devics (also discussed in &lt;a href="https://devzone.nordicsemi.com/f/nordic-q-a/15713/i2s-32-bit-word-size/59992"&gt;this old thread&lt;/a&gt;).&lt;/p&gt;
&lt;p&gt;Which signals are drifting relative to eachother? And how are both generated and used?&amp;nbsp; &amp;nbsp;I have not looked into the details of the linked project, but if that works I would assume the same sould be possible on the 91.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nRF9161 DK and an I2S microphone</title><link>https://devzone.nordicsemi.com/thread/535876?ContentTypeID=1</link><pubDate>Sun, 18 May 2025 13:27:31 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:7d5b1969-e73c-4b13-94c4-7f118e7efaa2</guid><dc:creator>Moskus</dc:creator><description>[quote userid="5203" url="~/f/nordic-q-a/121084/nrf9161-dk-and-an-i2s-microphone/535176"]Smells, that &lt;a href="https://github.com/gregtomasch/nRF52_24-bit-_I2S_Microphone_Audio_Recording_Utility"&gt;nRF52 24-bit I2S Microphone Audio Recording Utility&lt;/a&gt; applies for the nRF91 as well.[/quote]
&lt;p&gt;After reading through this, it seems you&amp;#39;re stuck with the same problem with the 16 MHz clock. I&amp;#39;ve&amp;nbsp;changed the PWM outputs, and the PWM frequencies should now read 3.2 MHz and 50 kHz. However, they are&amp;nbsp;drifting somewhat and the 64 ratio is not kept. Resulting in no data...&amp;nbsp;&lt;span class="emoticon" data-url="https://devzone.nordicsemi.com/cfs-file/__key/system/emoji/1f615.svg" title="Confused"&gt;&amp;#x1f615;&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nRF9161 DK and an I2S microphone</title><link>https://devzone.nordicsemi.com/thread/535179?ContentTypeID=1</link><pubDate>Tue, 13 May 2025 15:16:54 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:4ae8b31c-0a70-4b5e-8c91-43fa4ccaf327</guid><dc:creator>Moskus</dc:creator><description>[quote userid="5203" url="~/f/nordic-q-a/121084/nrf9161-dk-and-an-i2s-microphone/535176"]Smells, that &lt;a href="https://github.com/gregtomasch/nRF52_24-bit-_I2S_Microphone_Audio_Recording_Utility"&gt;nRF52 24-bit I2S Microphone Audio Recording Utility&lt;/a&gt; applies for the nRF91 as well.[/quote]
&lt;p&gt;Thank you very much for this link! I will absolutely look into this!&amp;nbsp;&lt;span class="emoticon" data-url="https://devzone.nordicsemi.com/cfs-file/__key/system/emoji/1f60a.svg" title="Blush"&gt;&amp;#x1f60a;&lt;/span&gt;&lt;br /&gt;It actually looks like what I&amp;#39;m trying to do.&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nRF9161 DK and an I2S microphone</title><link>https://devzone.nordicsemi.com/thread/535176?ContentTypeID=1</link><pubDate>Tue, 13 May 2025 15:04:36 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:bc7adb41-3672-407c-b403-fd785e6b9d23</guid><dc:creator>Achim Kraus</dc:creator><description>&lt;p&gt;Smells, that &lt;a href="https://github.com/gregtomasch/nRF52_24-bit-_I2S_Microphone_Audio_Recording_Utility"&gt;nRF52 24-bit I2S Microphone Audio Recording Utility&lt;/a&gt; applies for the nRF91 as well.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nRF9161 DK and an I2S microphone</title><link>https://devzone.nordicsemi.com/thread/535111?ContentTypeID=1</link><pubDate>Tue, 13 May 2025 11:54:14 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:671c7b2d-bac5-43c0-a3c8-e36a750a9db7</guid><dc:creator>Moskus</dc:creator><description>&lt;p&gt;Yet another small update, for the pwm approach (even if I&amp;#39;d like to avoid it).&amp;nbsp;As suspected, I did something stupid in the .overlay file. This works just fine:&lt;br /&gt;&lt;pre class="ui-code" data-mode="text"&gt;&amp;amp;pinctrl {
    /* PWM0.ch0 → BCLK on P0.24 */
    pwm0_ch0: pwm0_bclk {
        group1 { psels = &amp;lt;NRF_PSEL(PWM_OUT0, 0, 24)&amp;gt;; };
    };

    /* PWM1.ch0 → LRCLK on P0.24 */
    pwm1_lr: pwm1_lr {
            group1 { psels = &amp;lt;NRF_PSEL(PWM_OUT0, 0 , 25)&amp;gt;; };
    };
    /* I2S-slave: SDIN=22, BCLK=21, LRCLK=23 */
    i2s0_default: i2s0_default {
        group1 {
            psels = &amp;lt;NRF_PSEL(I2S_SDIN,   0, 22)&amp;gt;,
                    &amp;lt;NRF_PSEL(I2S_SCK_S,  0, 21)&amp;gt;,
                    &amp;lt;NRF_PSEL(I2S_LRCK_S, 0, 23)&amp;gt;;
        };
    };
};

&amp;amp;pwm0 {
        status = &amp;quot;okay&amp;quot;;
        pinctrl-names = &amp;quot;default&amp;quot;,&amp;quot;sleep&amp;quot;;
        pinctrl-0 = &amp;lt;&amp;amp;pwm0_ch0&amp;gt;;
        pinctrl-1 = &amp;lt;&amp;amp;pwm0_ch0&amp;gt;;
};
&amp;amp;pwm1 {
        status = &amp;quot;okay&amp;quot;;
        pinctrl-names = &amp;quot;default&amp;quot;,&amp;quot;sleep&amp;quot;;
        pinctrl-0 = &amp;lt;&amp;amp;pwm1_lr&amp;gt;;
        pinctrl-1 = &amp;lt;&amp;amp;pwm1_lr&amp;gt;;
};

&amp;amp;i2s0 {
    status = &amp;quot;okay&amp;quot;;
    pinctrl-names = &amp;quot;default&amp;quot;;
    pinctrl-0 = &amp;lt;&amp;amp;i2s0_default&amp;gt;;
};
&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;The&amp;nbsp;problem was here:&lt;br /&gt;&lt;pre class="ui-code" data-mode="text"&gt;    pwm1_lr: pwm1_lr {
            group1 { psels = &amp;lt;NRF_PSEL(PWM_OUT0, 0 , 25)&amp;gt;; };
    };&lt;/pre&gt;&lt;br /&gt;where I for some reason had &amp;quot;pwm_out0, &lt;span style="color:#ff0000;"&gt;&lt;strong&gt;1&lt;/strong&gt;&lt;/span&gt;, 25&amp;quot;.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nRF9161 DK and an I2S microphone</title><link>https://devzone.nordicsemi.com/thread/535081?ContentTypeID=1</link><pubDate>Tue, 13 May 2025 10:42:03 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:d9cf947a-15cf-4cb7-a012-f16e79f012d3</guid><dc:creator>Moskus</dc:creator><description>[quote userid="7377" url="~/f/nordic-q-a/121084/nrf9161-dk-and-an-i2s-microphone/534928"]I see, do you mean just clocking the microphone with that, or did you test with the nRF in slave mode using this clock?[/quote]
&lt;p&gt;This is setting&amp;nbsp;the nRF&amp;nbsp;to slave mode, and using the BCLK and LRCL from an ESP32.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
[quote userid="7377" url="~/f/nordic-q-a/121084/nrf9161-dk-and-an-i2s-microphone/534928"]Can you elaborate on that? From&amp;nbsp;&lt;a href="https://docs.nordicsemi.com/bundle/ps_nrf9161/page/i2s.html#ariaid-title6"&gt;Master clock (MCK)&lt;/a&gt; and &lt;a href="https://docs.nordicsemi.com/bundle/ps_nrf9161/page/i2s.html#ariaid-title31"&gt;CONFIG.RATIO&lt;/a&gt;&amp;nbsp;that should be OK? Is there any need to use the PWM?[/quote]
&lt;p&gt;I&amp;#39;d &lt;em&gt;love&lt;/em&gt; it if it&amp;#39;s possible to avoid PWM, but it seems that I can&amp;#39;t get the ratio to anything else than 48 when I2S is master in zephyr. There&amp;#39;s no support for 32 bit (if my googling is to be believed). The &lt;a href="https://mm.digikey.com/Volume0/opasdata/d220001/medias/docus/908/SPH0645LM4H-B.pdf"&gt;microphone requires 64&amp;nbsp;ratio&lt;/a&gt;. (My filters require 48 kHz sampling rate, but I&amp;#39;m sure I can redefine them if needed).&lt;/p&gt;
&lt;p&gt;Even if the first issue can be solved, I&amp;#39;m not sure if the 32 problem can be...? In slave mode 32 bit issue apparently isn&amp;#39;t a problem.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
[quote userid="7377" url="~/f/nordic-q-a/121084/nrf9161-dk-and-an-i2s-microphone/534928"]For the secure fault, I wonder if you are using overlapping peripheral instances, and it is allready used by secure mode firmware (TF-M). But there is no overlap with PWM instances and other peripherals (see &lt;a href="https://docs.nordicsemi.com/bundle/ps_nrf9161/page/memory.html#ariaid-title3"&gt;Instatiation&lt;/a&gt;), so that may not be the case. I see the error happened at&amp;nbsp;0x2000ce80 (check again if you modifi the firmware). What do you see there with &lt;a href="https://academy.nordicsemi.com/courses/nrf-connect-sdk-intermediate/lessons/lesson-2-debugging/topic/exercise-2-11/"&gt;addr2line&lt;/a&gt;?[/quote]
&lt;p&gt;I&amp;#39;m&amp;nbsp;new to nordic, my project is pretty standard. I just tried to add two different pwm instances, nothing else fancy going on (to my somewhat limited knowledge &lt;span class="emoticon" data-url="https://devzone.nordicsemi.com/cfs-file/__key/system/emoji/1f609.svg" title="Wink"&gt;&amp;#x1f609;&lt;/span&gt;).&lt;br /&gt;&lt;br /&gt;addr2line outputs:&lt;br /&gt;&lt;pre class="ui-code" data-mode="text"&gt;C:/ncs/v3.0.0/zephyr/kernel/init.c:54&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;&lt;/p&gt;
&lt;p&gt;...&amp;nbsp;which tells us:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;struct k_thread z_main_thread;&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nRF9161 DK and an I2S microphone</title><link>https://devzone.nordicsemi.com/thread/534928?ContentTypeID=1</link><pubDate>Mon, 12 May 2025 14:19:06 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:01d58a5e-8b46-48fa-ae6b-36c280a12da4</guid><dc:creator>Einar Thorsrud</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
[quote user="Moskus"]A small update: Using an external clock (like the working ESP32) gives data as we expect![/quote]
&lt;p&gt;I see, do you mean just clocking the microphone with that, or did you test with the nRF in slave mode using this clock?&lt;/p&gt;
[quote user="Moskus"]It seems that the&amp;nbsp;buffer is zeros because the microphone needs an oversampling of 64: WS must be BCLK/64. It seems like the I2S implementation on the nRF9161 isn&amp;#39;t capable of that.[/quote]
&lt;p&gt;Can you elaborate on that? From&amp;nbsp;&lt;a href="https://docs.nordicsemi.com/bundle/ps_nrf9161/page/i2s.html#ariaid-title6"&gt;Master clock (MCK)&lt;/a&gt; and &lt;a href="https://docs.nordicsemi.com/bundle/ps_nrf9161/page/i2s.html#ariaid-title31"&gt;CONFIG.RATIO&lt;/a&gt;&amp;nbsp;that should be OK? Is there any need to use the PWM?&lt;/p&gt;
&lt;p&gt;Regarding the PWM, the &amp;quot;Incompatible period&amp;quot; comes from the PWM frequency having to be the same on all channels on the same PWM instance.&lt;/p&gt;
&lt;p&gt;For the secure fault, I wonder if you are using overlapping peripheral instances, and it is allready used by secure mode firmware (TF-M). But there is no overlap with PWM instances and other peripherals (see &lt;a href="https://docs.nordicsemi.com/bundle/ps_nrf9161/page/memory.html#ariaid-title3"&gt;Instatiation&lt;/a&gt;), so that may not be the case. I see the error happened at&amp;nbsp;0x2000ce80 (check again if you modifi the firmware). What do you see there with &lt;a href="https://academy.nordicsemi.com/courses/nrf-connect-sdk-intermediate/lessons/lesson-2-debugging/topic/exercise-2-11/"&gt;addr2line&lt;/a&gt;?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nRF9161 DK and an I2S microphone</title><link>https://devzone.nordicsemi.com/thread/534883?ContentTypeID=1</link><pubDate>Mon, 12 May 2025 12:23:49 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:6fcbbea8-9bc7-4286-b72a-8d59b5210af4</guid><dc:creator>Moskus</dc:creator><description>&lt;p&gt;A small update: Using an external clock (like the working ESP32) gives data as we expect! &lt;span class="emoticon" data-url="https://devzone.nordicsemi.com/cfs-file/__key/system/emoji/1f60a.svg" title="Blush"&gt;&amp;#x1f60a;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;We desperately need to find a way to generate&amp;nbsp;the clocks using the nRF9161 alone...&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nRF9161 DK and an I2S microphone</title><link>https://devzone.nordicsemi.com/thread/534847?ContentTypeID=1</link><pubDate>Mon, 12 May 2025 11:10:15 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:7b0eec63-7e9f-40c5-a755-f7aec134ed53</guid><dc:creator>Moskus</dc:creator><description>&lt;p&gt;It seems that the&amp;nbsp;buffer is zeros because the microphone needs an oversampling of 64: WS must be BCLK/64. It seems like the I2S implementation on the nRF9161 isn&amp;#39;t capable of that.&lt;br /&gt;&lt;br /&gt;I&amp;#39;ve tried setting&amp;nbsp;the i2s to be slave instead of master:&lt;br /&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;    struct i2s_config cfg = {
        .word_size     = SAMPLE_BITS,
        .channels      = CHANNELS,
        .format        = I2S_FMT_DATA_FORMAT_I2S,
        .options       = I2S_OPT_BIT_CLK_SLAVE | I2S_OPT_FRAME_CLK_SLAVE,
        .frame_clk_freq= SAMPLE_RATE,
        .block_size    = BLOCK_SIZE,
        .mem_slab      = &amp;amp;i2s_dma_slab,
        .timeout       = 200,
    };&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;&lt;br /&gt;with nrf9161dk_nrf9161_ns.overlay:&lt;br /&gt;&lt;pre class="ui-code" data-mode="text"&gt;&amp;amp;pinctrl {
    /* PWM0.ch0 → BCLK on P0.21 */
    pwm0_ch0: pwm0_bclk {
        group1 { psels = &amp;lt;NRF_PSEL(PWM_OUT0, 0, 21)&amp;gt;; };
    };

    /* PWM0.ch0 → LRCLK on P0.23 */
    pwm0_ch1: pwm0_lr {
        group1 {
            psels = &amp;lt;NRF_PSEL(PWM_OUT1, 0, 23)&amp;gt;;
        };
    };

    /* I2S-slave: SDIN=22, BCLK=21, LRCLK=23 */
    i2s0_default: i2s0_default {
        group1 {
            psels = &amp;lt;NRF_PSEL(I2S_SDIN,   0, 22)&amp;gt;,
                    &amp;lt;NRF_PSEL(I2S_SCK_S,  0, 21)&amp;gt;,
                    &amp;lt;NRF_PSEL(I2S_LRCK_S, 0, 23)&amp;gt;;
        };
    };
};

/* Enable both PWM0 and PWM1 (each gets its own prescaler + countertop) */
&amp;amp;pwm0 {
    status = &amp;quot;okay&amp;quot;;
    /* To states: default + sleep */
    pinctrl-names = &amp;quot;default&amp;quot;, &amp;quot;sleep&amp;quot;;
    pinctrl-0 = &amp;lt;&amp;amp;pwm0_ch0 &amp;amp;pwm0_ch1&amp;gt;;
    pinctrl-1 = &amp;lt;&amp;amp;pwm0_ch0 &amp;amp;pwm0_ch1&amp;gt;;
};

/* I2S0 in slave mode using the remapped pins */
&amp;amp;i2s0 {
    status = &amp;quot;okay&amp;quot;;
    pinctrl-names = &amp;quot;default&amp;quot;;
    pinctrl-0 = &amp;lt;&amp;amp;i2s0_default&amp;gt;;
};
&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;.. and pwm_clocks.c&lt;br /&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;#include &amp;quot;pwm_clocks.h&amp;quot;
#include &amp;lt;zephyr/device.h&amp;gt;
#include &amp;lt;zephyr/drivers/pwm.h&amp;gt;
#include &amp;lt;zephyr/sys/util.h&amp;gt;
#include &amp;quot;mic_input.h&amp;quot; // for SAMPLE_RATE

#define PWM0_NODE DT_NODELABEL(pwm0)
// #define PWM1_NODE    DT_NODELABEL(pwm1)

#define BCLK_CH 0
#define LRCLK_CH 1 // 0 for pwm1

static const struct device *pwm_bclk;
// static const struct device *pwm_lrclk;

void pwm_clocks_init(void)
{
    /* Acquire PWM devices */
    pwm_bclk = DEVICE_DT_GET(PWM0_NODE);
    // pwm_lrclk = DEVICE_DT_GET(PWM1_NODE);
    __ASSERT(device_is_ready(pwm_bclk), &amp;quot;PWM0 device not ready&amp;quot;);
    //__ASSERT(device_is_ready(pwm_lrclk), &amp;quot;PWM1 device not ready&amp;quot;);

    /* Query source clock rate (cycles per second) */
    uint64_t clk_b;
    uint64_t clk_l;
    int err;
    err = pwm_get_cycles_per_sec(pwm_bclk, BCLK_CH, &amp;amp;clk_b);
    __ASSERT(err == 0, &amp;quot;Failed to get PWM0 clock rate (%d)&amp;quot;, err);
    err = pwm_get_cycles_per_sec(pwm_bclk, LRCLK_CH, &amp;amp;clk_l);
    // err = pwm_get_cycles_per_sec(pwm_lrclk, LRCLK_CH, &amp;amp;clk_l);
    __ASSERT(err == 0, &amp;quot;Failed to get PWM1 clock rate (%d)&amp;quot;, err);

    /* Desired frequencies */
    const uint32_t bclk_hz = SAMPLE_RATE * 64U;
    const uint32_t lrclk_hz = SAMPLE_RATE;

    /* Calculate period (ticks) for each PWM */
    uint32_t b_period = (uint32_t)(clk_b / bclk_hz);
    uint32_t lr_period = (uint32_t)(clk_l / lrclk_hz);

    /* 50% duty cycle */
    uint32_t b_pulse = b_period / 2U;
    uint32_t lr_pulse = lr_period / 2U;

    /* Configure PWM0 for BCLK */
    err = pwm_set_cycles(pwm_bclk, BCLK_CH, b_period, b_pulse, PWM_POLARITY_NORMAL);
    __ASSERT(err == 0, &amp;quot;Failed to set BCLK PWM (%d)&amp;quot;, err);

    err = pwm_set_cycles(pwm_bclk, LRCLK_CH, lr_period, lr_pulse, PWM_POLARITY_NORMAL);
    __ASSERT(err == 0, &amp;quot;Failed to set LRCLK PWM (%d)&amp;quot;, err);

    /* Configure PWM1 for LRCLK */
    // err = pwm_set_cycles(pwm_lrclk, LRCLK_CH, lr_period, lr_pulse, PWM_POLARITY_NORMAL);
    // __ASSERT(err == 0, &amp;quot;Failed to set LRCLK PWM (%d)&amp;quot;, err);

    printk(&amp;quot;PWM clocks running: BCLK @ %u Hz, LRCLK @ %u Hz\n&amp;quot;,
           bclk_hz, lrclk_hz);
}
&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Which gives me:&lt;/p&gt;
&lt;p&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/pastedimage1747047771077v1.png" alt=" " /&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="color:#ff0000;"&gt;&amp;lt;err&amp;gt; pwm_nrfx: Incompatible period.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Well, thinking perhaps using just one pwm-channel might be too much, I tried using two:&lt;/p&gt;
&lt;p&gt;with nrf9161dk_nrf9161_ns.overlay:&lt;br /&gt;&lt;pre class="ui-code" data-mode="text"&gt;&amp;amp;pinctrl {
    /* PWM0.ch0 → BCLK on P0.21 */
    pwm0_ch0: pwm0_bclk {
        group1 { psels = &amp;lt;NRF_PSEL(PWM_OUT0, 0, 21)&amp;gt;; };
    };

    /* PWM1.ch0 → LRCLK on P0.23 */
    pwm1_lr: pwm1_lr {
            group1 { psels = &amp;lt;NRF_PSEL(PWM_OUT0, 1, 23)&amp;gt;; };
    };

    /* I2S-slave: SDIN=22, BCLK=21, LRCLK=23 */
    i2s0_default: i2s0_default {
        group1 {
            psels = &amp;lt;NRF_PSEL(I2S_SDIN,   0, 22)&amp;gt;,
                    &amp;lt;NRF_PSEL(I2S_SCK_S,  0, 21)&amp;gt;,
                    &amp;lt;NRF_PSEL(I2S_LRCK_S, 0, 23)&amp;gt;;
        };
    };
};

&amp;amp;pwm0 {
        status = &amp;quot;okay&amp;quot;;
        pinctrl-names = &amp;quot;default&amp;quot;,&amp;quot;sleep&amp;quot;;
        pinctrl-0 = &amp;lt;&amp;amp;pwm0_ch0&amp;gt;;
        pinctrl-1 = &amp;lt;&amp;amp;pwm0_ch0&amp;gt;;
};
&amp;amp;pwm1 {
        status = &amp;quot;okay&amp;quot;;
        pinctrl-names = &amp;quot;default&amp;quot;,&amp;quot;sleep&amp;quot;;
        pinctrl-0 = &amp;lt;&amp;amp;pwm1_lr&amp;gt;;
        pinctrl-1 = &amp;lt;&amp;amp;pwm1_lr&amp;gt;;
};

/* I2S0 in slave mode using the remapped pins */
&amp;amp;i2s0 {
    status = &amp;quot;okay&amp;quot;;
    pinctrl-names = &amp;quot;default&amp;quot;;
    pinctrl-0 = &amp;lt;&amp;amp;i2s0_default&amp;gt;;
};
&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;but that won&amp;#39;t even start, but returns:&lt;br /&gt;Mic init complete&lt;br /&gt;&lt;span style="color:#ff0000;"&gt;[00:00:00.390,930] &amp;lt;err&amp;gt; os: ***** SECURE FAULT *****&lt;/span&gt;&lt;br /&gt;&lt;span style="color:#ff0000;"&gt;[00:00:00.390,960] &amp;lt;err&amp;gt; os: Address: 0xc&lt;/span&gt;&lt;br /&gt;&lt;span style="color:#ff0000;"&gt;[00:00:00.390,960] &amp;lt;err&amp;gt; os: Attribution unit violation&lt;/span&gt;&lt;br /&gt;&lt;span style="color:#ff0000;"&gt;[00:00:00.390,991] &amp;lt;err&amp;gt; os: r0/a1: 0x00000001 r1/a2: 0x00000017 r2/a3: 0x00000000&lt;/span&gt;&lt;br /&gt;&lt;span style="color:#ff0000;"&gt;[00:00:00.390,991] &amp;lt;err&amp;gt; os: r3/a4: 0x00800000 r12/ip: 0x00000000 r14/lr: 0x000149d7&lt;/span&gt;&lt;br /&gt;&lt;span style="color:#ff0000;"&gt;[00:00:00.390,991] &amp;lt;err&amp;gt; os: xpsr: 0x01000000&lt;/span&gt;&lt;br /&gt;&lt;span style="color:#ff0000;"&gt;[00:00:00.391,021] &amp;lt;err&amp;gt; os: Faulting instruction address (r15/pc): 0x0001474c&lt;/span&gt;&lt;br /&gt;&lt;span style="color:#ff0000;"&gt;[00:00:00.391,052] &amp;lt;err&amp;gt; os: &amp;gt;&amp;gt;&amp;gt; ZEPHYR FATAL ERROR 41: Unknown error on CPU 0&lt;/span&gt;&lt;br /&gt;&lt;span style="color:#ff0000;"&gt;[00:00:00.391,082] &amp;lt;err&amp;gt; os: Current thread: 0x2000ce80 (main)&lt;/span&gt;&lt;br /&gt;&lt;span style="color:#ff0000;"&gt;[00:00:00.453,857] &amp;lt;err&amp;gt; os: Halting system&lt;/span&gt;&lt;/p&gt;
&lt;p&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/pastedimage1747048208181v2.png" alt=" " /&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nRF9161 DK and an I2S microphone</title><link>https://devzone.nordicsemi.com/thread/534398?ContentTypeID=1</link><pubDate>Thu, 08 May 2025 07:39:43 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:75e92cf0-470e-4efd-b9d3-6a71aa0205f2</guid><dc:creator>Moskus</dc:creator><description>&lt;p&gt;The buffer is just zeros. But other than that, the code runs &amp;quot;fine&amp;quot; now.&lt;/p&gt;
&lt;p&gt;I have seen that sample, but I&amp;#39;ll go through it again to see if there&amp;#39;s anything I&amp;#39;ve missed. Tomorrow we&amp;#39;ll&amp;nbsp;use an oscilloscope to check the pins to see if clocks and such are working as they should.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nRF9161 DK and an I2S microphone</title><link>https://devzone.nordicsemi.com/thread/534254?ContentTypeID=1</link><pubDate>Wed, 07 May 2025 10:42:05 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:1d4495da-f115-41ac-a754-4ec9760ec940</guid><dc:creator>Einar Thorsrud</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;This code looks sensible. I assume you have had a look at the &lt;a href="https://github.com/nrfconnect/sdk-zephyr/blob/4270d8ac31d2b34f56d73e0ed9b14a5b5f041687/samples/drivers/i2s/echo/src/main.c"&gt;I2S echo sample&lt;/a&gt;?&lt;/p&gt;
&lt;p&gt;You write that you get no valid data. Does that mean no data at all, or not valid data? How do you determine it? Do you see anything from the logs? Also, what do you see if you check the I2S lines with a logic analyzer (most analyzers should be able to decode I2S)&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nRF9161 DK and an I2S microphone</title><link>https://devzone.nordicsemi.com/thread/533849?ContentTypeID=1</link><pubDate>Mon, 05 May 2025 07:03:21 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:a3d6b77a-0284-4afe-9f8e-ce5accaccc4b</guid><dc:creator>Moskus</dc:creator><description>&lt;p&gt;I&amp;#39;ve&amp;nbsp;made some progress, but nothing that really gives data. I&amp;#39;ve removed I2S_TRIGGER_PREPARE and of course the code now does... something. But still no valid data.&lt;br /&gt;&lt;br /&gt;&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;#include &amp;lt;zephyr/kernel.h&amp;gt;
#include &amp;lt;zephyr/device.h&amp;gt;
#include &amp;lt;zephyr/drivers/i2s.h&amp;gt;
#include &amp;lt;string.h&amp;gt;
#include &amp;lt;stdio.h&amp;gt;
#include &amp;lt;math.h&amp;gt;

#include &amp;quot;mic_input.h&amp;quot;
#include &amp;quot;filters.h&amp;quot;

#define I2S_DEV_NODE DT_NODELABEL(i2s0)

#define SAMPLE_RATE 48000
//#define SAMPLE_BITS 24 //in .h file   
#define BLOCK_TIME_MS 125
#define CHANNELS 1
#define SAMPLE_BYTES (SAMPLE_BITS / 8)
#define SAMPLES_PER_BLOCK ((SAMPLE_RATE * BLOCK_TIME_MS) / 1000)
#define BLOCK_SIZE (SAMPLES_PER_BLOCK * sizeof(int32_t))

static const struct device *i2s_dev;

__aligned(4) static float work_buf[SAMPLES_PER_BLOCK];
K_MEM_SLAB_DEFINE(i2s_rx_slabs, BLOCK_SIZE, 4, 4);
K_MSGQ_DEFINE(samples_msgq, sizeof(sum_queue_t), 8, 4);

bool foundData = false;
static void mic_thread(void *, void *, void *)
{
    printf(&amp;quot;Mic thread started\n&amp;quot;);

    i2s_dev = DEVICE_DT_GET(I2S_DEV_NODE);
    __ASSERT(device_is_ready(i2s_dev), &amp;quot;I2S device not ready&amp;quot;);

    struct i2s_config cfg = {
        .word_size = SAMPLE_BITS,
        .channels = CHANNELS,
        .format = I2S_FMT_DATA_FORMAT_I2S,
        .options = I2S_OPT_BIT_CLK_MASTER | I2S_OPT_FRAME_CLK_MASTER,
        .frame_clk_freq = SAMPLE_RATE,
        .block_size = BLOCK_SIZE,
        .mem_slab = &amp;amp;i2s_rx_slabs,
        .timeout = 200,
    };

    printf(&amp;quot;Buffer size: %d\n&amp;quot;, BLOCK_SIZE);

    int ret = i2s_configure(i2s_dev, I2S_DIR_RX, &amp;amp;cfg);
    if (ret &amp;lt; 0) {
        printf(&amp;quot;I2S configure failed: %d\n&amp;quot;, ret);
        return;
    }

    printf(&amp;quot;I2S configured!\n&amp;quot;);

    ret = i2s_trigger(i2s_dev, I2S_DIR_RX, I2S_TRIGGER_START);
    if (ret &amp;lt; 0) {
        printf(&amp;quot;I2S trigger start failed: %d\n&amp;quot;, ret);
        return;
    }

    printf(&amp;quot;I2S triggered!\n&amp;quot;);

    void *mem_block;
    size_t size;

    while (true)
    {
        foundData = false;
        ret = i2s_read(i2s_dev, &amp;amp;mem_block, &amp;amp;size);

        if (ret == 0)
        {
            const int32_t *samples = (int32_t *)mem_block;
            int printed = 0;

	    //test if data is found
            for(int i = 0; i &amp;lt; SAMPLES_PER_BLOCK; i++) {
                if (samples[i] != 0) {
                    foundData = true;
                    printf(&amp;quot;Found data in sample[%d] = 0x%08X\n&amp;quot;, i, samples[i]);
                    break;
                }
            }

            // print 10 samples
            for (int i = 0; i &amp;lt; SAMPLES_PER_BLOCK &amp;amp;&amp;amp; printed &amp;lt; 10; i++) {
                int32_t s = samples[i];
                if (s != 0) {
                    printf(&amp;quot;sample[%d] = 0x%08X (%d)\n&amp;quot;, i, s, s);
                    printed++;
                }
            }

            for (int i = 0; i &amp;lt; SAMPLES_PER_BLOCK; i++) {
                work_buf[i] = unpack_24bit(samples[i]) / 8388608.0f;  // 2^23
            }
	    //do something smart with the work_buf[] here

            k_mem_slab_free(&amp;amp;i2s_rx_slabs, mem_block);

        }
        else if (ret == -EAGAIN)
        {
            printf(&amp;quot;No data yet (possible timeout)...\n&amp;quot;);
            k_sleep(K_MSEC(10));
        }
        else
        {
            printf(&amp;quot;i2s_read() failed: %d\n&amp;quot;, ret);
            k_sleep(K_MSEC(100));
        }
    }
}

K_THREAD_DEFINE(mic_thread_instance, 1024 * 4, mic_thread, NULL, NULL, NULL, 7, 0, 0);&lt;/pre&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nRF9161 DK and an I2S microphone</title><link>https://devzone.nordicsemi.com/thread/533589?ContentTypeID=1</link><pubDate>Wed, 30 Apr 2025 13:45:55 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:1a672fd6-0c18-4075-b6b6-8432e02521d0</guid><dc:creator>Moskus</dc:creator><description>&lt;p&gt;Hei&amp;nbsp;Einar, thanks for getting back to me.&lt;br /&gt;&lt;br /&gt;I get this error:&lt;br /&gt;&lt;span style="color:#ff0000;"&gt;Failed to read memory at 0x40028000&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;... but I&amp;#39;m not sure that&amp;#39;s what I&amp;#39;m looking for. Stepping in&amp;nbsp;gets me here in the end:&lt;br /&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/pastedimage1746020410777v1.png" alt=" " /&gt;&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Do I understand this correctly?&lt;br /&gt;When I run...&lt;br /&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;    ret = i2s_trigger(i2s_dev, I2S_DIR_RX, I2S_TRIGGER_PREPARE);&lt;/pre&gt;&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;... cmd_allowed will be set to FALSE because the state error is not equal to I2S_STATE_ERROR...?&lt;br /&gt;Should it be?&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nRF9161 DK and an I2S microphone</title><link>https://devzone.nordicsemi.com/thread/533568?ContentTypeID=1</link><pubDate>Wed, 30 Apr 2025 12:34:30 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:978b899c-48cb-41ae-9b33-94331fac456a</guid><dc:creator>Einar Thorsrud</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;I do not immediately see the problem, but you get -5 (-EIO) returned from&amp;nbsp;i2s_trigger(). Can you debug and step down until you see more precisely where the error comes from?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>