<?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>Adafruit I2S MEMS Microphone Breakout with the NRF9160 DK</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/60444/adafruit-i2s-mems-microphone-breakout-with-the-nrf9160-dk</link><description>Hello, 
 I am working on a project where I can have Voice over IP on the NRF9160 DK. I am now working with a I2S microphone ( https://www.adafruit.com/product/3421 ) at the moment I have trouble programming I2S. I read the I2S documentation on the zephyr</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Thu, 18 Jun 2020 23:51:15 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/60444/adafruit-i2s-mems-microphone-breakout-with-the-nrf9160-dk" /><item><title>RE: Adafruit I2S MEMS Microphone Breakout with the NRF9160 DK</title><link>https://devzone.nordicsemi.com/thread/255859?ContentTypeID=1</link><pubDate>Thu, 18 Jun 2020 23:51:15 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:02b273d2-85fd-42e0-b38e-f9c0c99d4d4f</guid><dc:creator>Nahom Abraha</dc:creator><description>&lt;p&gt;Hi Martin,&lt;/p&gt;
&lt;p&gt;I managed to get the microphone to work. The only thing that I don&amp;#39;t understand is that the frequency of the SCK pin is not the same &lt;span&gt;frequency&amp;nbsp;&lt;/span&gt;as the MCK pin. The MCK&amp;nbsp;&lt;span&gt;frequency&amp;nbsp;would be 4 mhz and the SCK frequency&amp;nbsp; 1 mhz and the micropohne doen&amp;#39;st work on a frequency lower then 2 mhz. I connected the microphone now to the MCK.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Now I want to play audio with this i2s amplifier(&lt;a href="https://www.adafruit.com/product/3006"&gt;https://www.adafruit.com/product/3006&lt;/a&gt;). I managed to play audio by connecting the data output from the&amp;nbsp; microphone directly to the amplifier to test it. Now I want to play audio by connecting to the NRF9160 dout pin. I know that I have to assign the data to the tx_buffer, ,but the audio that comes out is a random sound. I noticed that the data output from the nrf had a frequency of 700 khz. The microphone had a frequencccy of 300 khz and that works. How do i lower the frequency of the data output or should I change something else?&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Thank you in advance&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Adafruit I2S MEMS Microphone Breakout with the NRF9160 DK</title><link>https://devzone.nordicsemi.com/thread/251477?ContentTypeID=1</link><pubDate>Mon, 25 May 2020 12:18:16 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:d7ea5eaa-e01d-4ddb-a74c-d6c41ca4f0fb</guid><dc:creator>Martin Lesund</dc:creator><description>&lt;p&gt;Hi Nahom,&lt;/p&gt;
&lt;p&gt;Please try to assign other pins since 8 and 9 are used on switch 1 &amp;amp; switch 2 on the nrf91DK.&lt;/p&gt;
&lt;p&gt;Look at the documentation at which pins that are available:&amp;nbsp;&lt;a href="https://infocenter.nordicsemi.com/index.jsp?topic=%2Fug_nrf91_dk%2FUG%2Fnrf91_DK%2Fif_connector.html"&gt;https://infocenter.nordicsemi.com/index.jsp?topic=%2Fug_nrf91_dk%2FUG%2Fnrf91_DK%2Fif_connector.html&lt;/a&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Adafruit I2S MEMS Microphone Breakout with the NRF9160 DK</title><link>https://devzone.nordicsemi.com/thread/251321?ContentTypeID=1</link><pubDate>Fri, 22 May 2020 20:45:46 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:c9adcf90-e799-416d-aff7-b0545c1d2d46</guid><dc:creator>Nahom Abraha</dc:creator><description>&lt;p&gt;Hi Martin,&lt;/p&gt;
&lt;p&gt;So I am using now the nrfx_i2s driver I changed the code and I don&amp;#39;t receive any data. I think that the problem is with the datahandler. The microphone(&lt;a href="https://www.adafruit.com/product/3421"&gt;https://www.adafruit.com/product/3421&lt;/a&gt;) works with a raspberry pi so the microphone works.&lt;span&gt;I don&amp;#39;t know how to fix this.&lt;/span&gt; I connected&lt;br /&gt;LRCL with pin 8&lt;br /&gt;DOUT with 9&lt;br /&gt;BCLK with pin 10&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;#include &amp;lt;nrf.h&amp;gt;
#include &amp;lt;zephyr.h&amp;gt;
#include &amp;lt;device.h&amp;gt;
#include &amp;lt;sys/printk.h&amp;gt;
#include &amp;lt;stdbool.h&amp;gt;
#include &amp;lt;nrfx_i2s.h&amp;gt;
#include &amp;lt;string.h&amp;gt;

#include &amp;quot;microphone.h&amp;quot;
#include &amp;quot;button.h&amp;quot;
#include &amp;quot;udp.h&amp;quot;

#define  I2S_BUFFER_SIZE 1024
#define  SCK_PIN    10 
#define  SDIN_PIN   9
#define  LRCK_PIN   8
#define  MCK_PIN    7
#define  SDOUT_PIN  6 

int counter;
static uint32_t rx_buffer[I2S_BUFFER_SIZE]={0};
static uint32_t tx_buffer[I2S_BUFFER_SIZE]={0};
static nrfx_i2s_buffers_t buffer;   
 
ISR_DIRECT_DECLARE(i2s_isr_handler) 
{
  nrfx_i2s_irq_handler();
  ISR_DIRECT_PM();

  return 1; 
}

static void data_handler(nrfx_i2s_buffers_t const * p_released, uint32_t status)
{ 
  if (NRFX_I2S_STATUS_NEXT_BUFFERS_NEEDED == status)
  {
    printk(&amp;quot;%u\n&amp;quot;,status);
    nrfx_err_t err = nrfx_i2s_next_buffers_set(&amp;amp;buffer);
    if (err != NRFX_SUCCESS ) {
        printk(&amp;quot;next buffer failed with error code:%d\n&amp;quot;,err);
      } 
  }

  if(p_released != NULL){
    if (p_released-&amp;gt;p_rx_buffer != NULL)
    {
        //uint8_t* data=p_released-&amp;gt;p_rx_buffer;
        //data[0] == p_released-&amp;gt;p_rx_buffer[0]
        uint8_t data[I2S_BUFFER_SIZE]={0};
        memcpy(data,p_released-&amp;gt;p_rx_buffer, sizeof(p_released-&amp;gt;p_rx_buffer));
        for(int i=0; i &amp;lt;1024; i++)
        {
            printk(&amp;quot;data: 0x%hhX\n&amp;quot;,data[i]);
            printk(&amp;quot;data2:0x%hhX\n&amp;quot;,p_released-&amp;gt;p_rx_buffer[i]);
        }
      }
    }
  }
}

void recordaudio(void)
{
  printk(&amp;quot;Start i2s configuration\n&amp;quot;);
  nrfx_err_t err;
  uint16_t buffer_size=2048;
  nrfx_i2s_config_t config = NRFX_I2S_DEFAULT_CONFIG(SCK_PIN,LRCK_PIN,MCK_PIN,SDOUT_PIN,SDIN_PIN);
  
  buffer.p_rx_buffer=rx_buffer;
  buffer.p_tx_buffer=tx_buffer;

 //config.irq_priority = NRFX_I2S_DEFAULT_CONFIG_IRQ_PRIORITY;
// config.mode = NRF_I2S_MODE_MASTER;
// config.mck_setup = NRF_I2S_MCK_32MDIV8;
// config.channels = NRF_I2S_CHANNELS_LEFT;
// config.sample_width = NRF_I2S_SWIDTH_16BIT;
// config.ratio = NRF_I2S_RATIO_32X;
// config.format = NRF_I2S_FORMAT_I2S;
// config.alignment=NRF_I2S_ALIGN_LEFT;
//  
 IRQ_DIRECT_CONNECT(I2S_IRQn, 0,i2s_isr_handler, 0);

  err = nrfx_i2s_init(&amp;amp;config, data_handler);
  if (err != NRFX_SUCCESS)
  {
      printk(&amp;quot;i2s init failed:%d\n&amp;quot;,err);
  }
  printk(&amp;quot;i2s_start\n&amp;quot;);
  err=nrfx_i2s_start(&amp;amp;buffer,buffer_size, 0);
  if(err!=NRFX_SUCCESS )
    {
     printk(&amp;quot;i2s start failed with error:%d\n&amp;quot;,err);
    }
  while(1)
     {
      printk(&amp;quot;recording\n&amp;quot;);
      k_sleep(2000);
     }
    printk(&amp;quot;\n stop recording \n&amp;quot;);
    nrfx_i2s_stop();
    nrfx_i2s_uninit();
}&lt;/pre&gt;&lt;img src="https://devzone.nordicsemi.com/resized-image/__size/320x240/__key/communityserver-discussions-components-files/4/pastedimage1590179778303v1.png" alt=" " /&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Adafruit I2S MEMS Microphone Breakout with the NRF9160 DK</title><link>https://devzone.nordicsemi.com/thread/250877?ContentTypeID=1</link><pubDate>Wed, 20 May 2020 08:52:18 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:300033ba-e94a-4b8c-9306-39611b1a642f</guid><dc:creator>Nahom Abraha</dc:creator><description>&lt;p&gt;I am using now the nrfx_i2s driver. I asked a question about the i2s in this thread&amp;nbsp;&amp;nbsp;&lt;span&gt;&amp;nbsp;&lt;/span&gt;&lt;a href="https://devzone.nordicsemi.com/f/nordic-q-a/60256/i2s-on-nrf9160"&gt;https://devzone.nordicsemi.com/f/nordic-q-a/60256/i2s-on-nrf9160&lt;/a&gt;&amp;nbsp;can you please check it out.&lt;/p&gt;
&lt;p&gt;thank you&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Adafruit I2S MEMS Microphone Breakout with the NRF9160 DK</title><link>https://devzone.nordicsemi.com/thread/250252?ContentTypeID=1</link><pubDate>Fri, 15 May 2020 16:06:34 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:2f282d78-df10-4c19-b0c0-0e241bbf8362</guid><dc:creator>Martin Lesund</dc:creator><description>&lt;p&gt;Please check out this Devzone thread:&amp;nbsp;&lt;a href="https://devzone.nordicsemi.com/f/nordic-q-a/60256/i2s-on-nrf9160"&gt;https://devzone.nordicsemi.com/f/nordic-q-a/60256/i2s-on-nrf9160&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;/a&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Adafruit I2S MEMS Microphone Breakout with the NRF9160 DK</title><link>https://devzone.nordicsemi.com/thread/250148?ContentTypeID=1</link><pubDate>Fri, 15 May 2020 10:40:38 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:16172d46-952a-4bad-ad9b-8270be2228ad</guid><dc:creator>Nahom Abraha</dc:creator><description>&lt;p&gt;Hi Martin,&lt;/p&gt;
&lt;p&gt;I changed the files and the i2s_configure still doesn&amp;#39;t work. I found out that the device_get_binding returns a null pointer so the i2s_device is probably the problem. Is it possible that I have the wrong driver name or that i2s is still disabled. I enabled i2s in the prj.conf&amp;nbsp;CONFIG_I2S=y so that shouldn&amp;#39;t&amp;nbsp;be the problem.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Thank you in advance&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Adafruit I2S MEMS Microphone Breakout with the NRF9160 DK</title><link>https://devzone.nordicsemi.com/thread/249997?ContentTypeID=1</link><pubDate>Thu, 14 May 2020 14:09:46 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:bd1da710-e132-4a6e-8d54-c29295d421cc</guid><dc:creator>Martin Lesund</dc:creator><description>&lt;p&gt;Hi Nahom,&lt;br /&gt;Sorry for the delay.&lt;br /&gt;It does look like I2S is not enabled to be used in the non-secure area (&lt;em&gt;will make a pull request on this as well),&lt;br /&gt;&lt;/em&gt;so you need to change the nrf/subsys/spm files Kconfig and the spm.c to the following:&lt;/p&gt;
&lt;p&gt;spm.c (see line 354)&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;/*
 * Copyright (c) 2019 Nordic Semiconductor ASA
 *
 * SPDX-License-Identifier: LicenseRef-BSD-5-Clause-Nordic
 */

#include &amp;lt;zephyr.h&amp;gt;
#include &amp;lt;sys/printk.h&amp;gt;
#include &amp;lt;sys/util.h&amp;gt;
#include &amp;lt;linker/linker-defs.h&amp;gt;
#include &amp;lt;device.h&amp;gt;
#include &amp;lt;drivers/gpio.h&amp;gt;
#include &amp;lt;hal/nrf_spu.h&amp;gt;
#include &amp;quot;spm_internal.h&amp;quot;

#if !defined(CONFIG_ARM_SECURE_FIRMWARE)
#error &amp;quot;Module requires compiling for Secure ARM Firmware&amp;quot;
#endif

/* Include required APIs for TrustZone-M */
#include &amp;lt;arm_cmse.h&amp;gt;
#include &amp;lt;cortex_m/tz.h&amp;gt;

#include &amp;lt;nrfx.h&amp;gt;

#if USE_PARTITION_MANAGER
#include &amp;lt;pm_config.h&amp;gt;
#define NON_SECURE_APP_ADDRESS PM_APP_ADDRESS
#else
#define NON_SECURE_APP_ADDRESS DT_FLASH_AREA_IMAGE_0_NONSECURE_OFFSET_0
#endif /* USE_PARTITION_MANAGER */

/* This reflects the configuration in DTS. */
#define NON_SECURE_RAM_OFFSET 0x10000

#define NON_SECURE_FLASH_REGION_INDEX \
	((NON_SECURE_APP_ADDRESS) / (FLASH_SECURE_ATTRIBUTION_REGION_SIZE))
#define NON_SECURE_RAM_REGION_INDEX \
	((NON_SECURE_RAM_OFFSET) / (RAM_SECURE_ATTRIBUTION_REGION_SIZE))

/*
 *  * The security configuration for depends on where the non secure app
 *  * is placed. All flash regions before the region which contains the
 *  * non secure app is configured as Secure.
 *
 *                FLASH
 *  1 MB  |---------------------|
 *        |                     |
 *        |                     |
 *        |                     |
 *        |                     |
 *        |                     |
 *        |     Non-Secure      |
 *        |       Flash         |
 *        |                     |
 *  X kB  |---------------------|
 *        |                     |
 *        |     Secure          |
 *        |      Flash          |
 *  0 kB  |---------------------|
 *
 *  * The security configuration for SRAM is applied:
 *
 *                SRAM
 * 256 kB |---------------------|
 *        |                     |
 *        |                     |
 *        |                     |
 *        |     Non-Secure      |
 *        |    SRAM (image)     |
 *        |                     |
 * 128 kB |.................... |
 *        |     Non-Secure      |
 *        |  SRAM (BSD Library) |
 *  64 kB |---------------------|
 *        |      Secure         |
 *        |       SRAM          |
 *  0 kB  |---------------------|
 */

extern void irq_target_state_set(unsigned int irq, int secure_state);
extern int irq_target_state_is_secure(unsigned int irq);

/* printk wrapper, to turn off logs when booting silently */
#define PRINT(...)                                                             \
	do {                                                                   \
		if (!IS_ENABLED(CONFIG_SPM_BOOT_SILENTLY)) {                   \
			printk(__VA_ARGS__);                                   \
		}                                                              \
	} while (0)

/* Local convenience macro to extract the peripheral
 * ID from the base address.
 */
#define NRFX_PERIPHERAL_ID_GET(base_addr) \
	(uint8_t)((uint32_t)(base_addr) &amp;gt;&amp;gt; 12)

#ifdef CONFIG_SPM_BOOT_SILENTLY
#define PERIPH(name, reg, config)                                              \
	{                                                                      \
		.id = NRFX_PERIPHERAL_ID_GET(reg), IS_ENABLED(config)          \
	}
#else
#define PERIPH(name, reg, config)                                              \
	{                                                                      \
		name, .id = NRFX_PERIPHERAL_ID_GET(reg), IS_ENABLED(config)    \
	}
#endif

/* Check if configuration exceeds the number of
 * DPPI Channels available on device.
 */
#if (CONFIG_SPM_NRF_DPPIC_PERM_MASK &amp;gt;= (1 &amp;lt;&amp;lt; DPPI_CH_NUM))
#error &amp;quot;SPM_NRF_DPPIC_PERM_MASK exceeds number of available DPPI channels&amp;quot;
#endif

#if defined(CONFIG_ARM_FIRMWARE_HAS_SECURE_ENTRY_FUNCS)

static void spm_config_nsc_flash(void)
{
	/* Configure a single region in Secure Flash as Non-Secure Callable
	 * (NSC) area.
	 *
	 * Area to configure is dynamically decided with help from linker code.
	 *
	 * Note: Any Secure Entry functions, exposing secure services to the
	 * Non-Secure firmware, shall be located inside this NSC area.
	 *
	 * If the start address of the NSC area is hard-coded, it must follow
	 * the HW restrictions: The size must be a power of 2 between 32 and
	 * 4096, and the end address must fall on a SPU region boundary.
	 */
	u32_t nsc_size = FLASH_NSC_SIZE_FROM_ADDR(__sg_start);

	__ASSERT((u32_t)__sg_size &amp;lt;= nsc_size,
		&amp;quot;The Non-Secure Callable region is overflowed by %d byte(s).\n&amp;quot;,
		(u32_t)__sg_size - nsc_size);

	nrf_spu_flashnsc_set(NRF_SPU, 0, FLASH_NSC_SIZE_REG(nsc_size),
			FLASH_NSC_REGION_FROM_ADDR(__sg_start), false);

	PRINT(&amp;quot;Non-secure callable region 0 placed in flash region %d with size %d.\n&amp;quot;,
		NRF_SPU-&amp;gt;FLASHNSC[0].REGION, NRF_SPU-&amp;gt;FLASHNSC[0].SIZE &amp;lt;&amp;lt; 5);
}
#endif /* CONFIG_ARM_FIRMWARE_HAS_SECURE_ENTRY_FUNCS */


static void config_regions(bool ram, size_t start, size_t end, u32_t perm)
{
	const size_t region_size = ram ? RAM_SECURE_ATTRIBUTION_REGION_SIZE
					: FLASH_SECURE_ATTRIBUTION_REGION_SIZE;

	for (size_t i = start; i &amp;lt; end; i++) {
		if (ram) {
			NRF_SPU-&amp;gt;RAMREGION[i].PERM = perm;
		} else {
			NRF_SPU-&amp;gt;FLASHREGION[i].PERM = perm;
		}
	}

	PRINT(&amp;quot;%02u %02u 0x%05x 0x%05x \t&amp;quot;, start, end - 1,
				region_size * start, region_size * end);
	PRINT(&amp;quot;%s&amp;quot;, perm &amp;amp; (ram ? SRAM_SECURE : FLASH_SECURE) ? &amp;quot;Secure\t\t&amp;quot; :
								&amp;quot;Non-Secure\t&amp;quot;);
	PRINT(&amp;quot;%c&amp;quot;, perm &amp;amp; (ram ? SRAM_READ : FLASH_READ)  ? &amp;#39;r&amp;#39; : &amp;#39;-&amp;#39;);
	PRINT(&amp;quot;%c&amp;quot;, perm &amp;amp; (ram ? SRAM_WRITE : FLASH_WRITE) ? &amp;#39;w&amp;#39; : &amp;#39;-&amp;#39;);
	PRINT(&amp;quot;%c&amp;quot;, perm &amp;amp; (ram ? SRAM_EXEC : FLASH_EXEC)  ? &amp;#39;x&amp;#39; : &amp;#39;-&amp;#39;);
	PRINT(&amp;quot;%c&amp;quot;, perm &amp;amp; (ram ? SRAM_LOCK : FLASH_LOCK)  ? &amp;#39;l&amp;#39; : &amp;#39;-&amp;#39;);
	PRINT(&amp;quot;\n&amp;quot;);
}


static void spm_config_flash(void)
{
	/* Regions of flash up to and including SPM are configured as Secure.
	 * The rest of flash is configured as Non-Secure.
	 */
	const u32_t secure_flash_perm = FLASH_READ | FLASH_WRITE | FLASH_EXEC
			| FLASH_LOCK | FLASH_SECURE;
	const u32_t nonsecure_flash_perm = FLASH_READ | FLASH_WRITE | FLASH_EXEC
			| FLASH_LOCK | FLASH_NONSEC;

	PRINT(&amp;quot;Flash regions\t\tDomain\t\tPermissions\n&amp;quot;);

	config_regions(false, 0, NON_SECURE_FLASH_REGION_INDEX,
			secure_flash_perm);
	config_regions(false, NON_SECURE_FLASH_REGION_INDEX,
			NUM_FLASH_SECURE_ATTRIBUTION_REGIONS,
			nonsecure_flash_perm);
	PRINT(&amp;quot;\n&amp;quot;);

#if defined(CONFIG_ARM_FIRMWARE_HAS_SECURE_ENTRY_FUNCS)
	spm_config_nsc_flash();
	PRINT(&amp;quot;\n&amp;quot;);

#if defined(CONFIG_SPM_SECURE_SERVICES)
	int err = spm_secure_services_init();

	if (err != 0) {
		PRINT(&amp;quot;Could not initialize secure services (err %d).\n&amp;quot;, err);
	}
#endif
#endif /* CONFIG_ARM_FIRMWARE_HAS_SECURE_ENTRY_FUNCS */
}

static void spm_config_sram(void)
{
	/* Lower 64 kB of SRAM is allocated to the Secure firmware image.
	 * The rest of SRAM is allocated to Non-Secure firmware image.
	 */

	const u32_t secure_ram_perm = SRAM_READ | SRAM_WRITE | SRAM_EXEC
		| SRAM_LOCK | SRAM_SECURE;
	const u32_t nonsecure_ram_perm = SRAM_READ | SRAM_WRITE | SRAM_EXEC
		| SRAM_LOCK | SRAM_NONSEC;

	PRINT(&amp;quot;SRAM region\t\tDomain\t\tPermissions\n&amp;quot;);

	/* Configuration for Secure RAM Regions (0 - 64 kB) */
	config_regions(true, 0, NON_SECURE_RAM_REGION_INDEX,
			secure_ram_perm);
	/* Configuration for Non-Secure RAM Regions (64 kb - end) */
	config_regions(true, NON_SECURE_RAM_REGION_INDEX,
			NUM_RAM_SECURE_ATTRIBUTION_REGIONS,
			nonsecure_ram_perm);
	PRINT(&amp;quot;\n&amp;quot;);
}

static bool usel_or_split(u8_t id)
{
	const u32_t perm = NRF_SPU-&amp;gt;PERIPHID[id].PERM;

	/* NRF_GPIOTE1_NS needs special handling as its
	 * peripheral ID for non-secure han incorrect properties
	 * in the NRF_SPM-&amp;gt;PERIPHID[id].perm register.
	 */
	if (id == NRFX_PERIPHERAL_ID_GET(NRF_GPIOTE1_NS)) {
		return true;
	}

	bool present = (perm &amp;amp; SPU_PERIPHID_PERM_PRESENT_Msk) ==
		       SPU_PERIPHID_PERM_PRESENT_Msk;

	/* User-selectable attribution */
	bool usel = (perm &amp;amp; SPU_PERIPHID_PERM_SECUREMAPPING_Msk) ==
		    SPU_PERIPHID_PERM_SECUREMAPPING_UserSelectable;

	/* Split attribution */
	bool split = (perm &amp;amp; SPU_PERIPHID_PERM_SECUREMAPPING_Msk) ==
		     SPU_PERIPHID_PERM_SECUREMAPPING_Split;

	return present &amp;amp;&amp;amp; (usel || split);
}

static int spm_config_peripheral(u8_t id, bool dma_present)
{
	/* Set a peripheral to Non-Secure state, if
	 * - it is present
	 * - has UserSelectable/Split attribution.
	 *
	 * Assign DMA capabilities and lock down the attribution.
	 *
	 * Note: the function assumes that the peripheral ID matches
	 * the IRQ line.
	 */
	NVIC_DisableIRQ(id);

	if (usel_or_split(id)) {
		NRF_SPU-&amp;gt;PERIPHID[id].PERM = PERIPH_PRESENT | PERIPH_NONSEC |
			(dma_present ? PERIPH_DMA_NOSEP : 0) |
			PERIPH_LOCK;
	}

	/* Even for non-present peripherals we force IRQs to be routed
	 * to Non-Secure state.
	 */
	irq_target_state_set(id, 0);
	return 0;
}

static void spm_dppi_configure(u32_t mask)
{
	NRF_SPU-&amp;gt;DPPI[0].PERM = mask;
}

static void spm_config_peripherals(void)
{
	struct periph_cfg {
#ifndef CONFIG_SPM_BOOT_SILENTLY
		char *name;
#endif
		u8_t id;
		u8_t nonsecure;
	};

	/* - All user peripherals are allocated to the Non-Secure domain.
	 * - All GPIOs are allocated to the Non-Secure domain.
	 */
	static const struct periph_cfg periph[] = {
#ifdef NRF_P0
		PERIPH(&amp;quot;NRF_P0&amp;quot;, NRF_P0, CONFIG_SPM_NRF_P0_NS),
#endif
#ifdef NRF_CLOCK
		PERIPH(&amp;quot;NRF_CLOCK&amp;quot;, NRF_CLOCK, CONFIG_SPM_NRF_CLOCK_NS),
#endif
#ifdef NRF_RTC0
		PERIPH(&amp;quot;NRF_RTC0&amp;quot;, NRF_RTC0, CONFIG_SPM_NRF_RTC0_NS),
#endif
#ifdef NRF_RTC1
		PERIPH(&amp;quot;NRF_RTC1&amp;quot;, NRF_RTC1, CONFIG_SPM_NRF_RTC1_NS),
#endif
#ifdef NRF_NVMC
		PERIPH(&amp;quot;NRF_NVMC&amp;quot;, NRF_NVMC, CONFIG_SPM_NRF_NVMC_NS),
#endif
#ifdef NRF_UARTE1
		PERIPH(&amp;quot;NRF_UARTE1&amp;quot;, NRF_UARTE1, CONFIG_SPM_NRF_UARTE1_NS),
#endif
#ifdef NRF_UARTE2
		PERIPH(&amp;quot;NRF_UARTE2&amp;quot;, NRF_UARTE2, CONFIG_SPM_NRF_UARTE2_NS),
#endif
#ifdef NRF_TWIM2
		PERIPH(&amp;quot;NRF_TWIM2&amp;quot;, NRF_TWIM2, CONFIG_SPM_NRF_TWIM2_NS),
#endif
#ifdef NRF_SPIM3
		PERIPH(&amp;quot;NRF_SPIM3&amp;quot;, NRF_SPIM3, CONFIG_SPM_NRF_SPIM3_NS),
#endif
#ifdef NRF_TIMER0
		PERIPH(&amp;quot;NRF_TIMER0&amp;quot;, NRF_TIMER0, CONFIG_SPM_NRF_TIMER0_NS),
#endif
#ifdef NRF_TIMER1
		PERIPH(&amp;quot;NRF_TIMER1&amp;quot;, NRF_TIMER1, CONFIG_SPM_NRF_TIMER1_NS),
#endif
#ifdef NRF_TIMER2
		PERIPH(&amp;quot;NRF_TIMER2&amp;quot;, NRF_TIMER2, CONFIG_SPM_NRF_TIMER2_NS),
#endif
#ifdef NRF_SAADC
		PERIPH(&amp;quot;NRF_SAADC&amp;quot;, NRF_SAADC, CONFIG_SPM_NRF_SAADC_NS),
#endif
#ifdef NRF_PWM0
		PERIPH(&amp;quot;NRF_PWM0&amp;quot;, NRF_PWM0, CONFIG_SPM_NRF_PWM0_NS),
#endif
#ifdef NRF_PWM1
		PERIPH(&amp;quot;NRF_PWM1&amp;quot;, NRF_PWM1, CONFIG_SPM_NRF_PWM1_NS),
#endif
#ifdef NRF_PWM2
		PERIPH(&amp;quot;NRF_PWM2&amp;quot;, NRF_PWM2, CONFIG_SPM_NRF_PWM2_NS),
#endif
#ifdef NRF_PWM3
		PERIPH(&amp;quot;NRF_PWM3&amp;quot;, NRF_PWM3, CONFIG_SPM_NRF_PWM3_NS),
#endif
#ifdef NRF_WDT
		PERIPH(&amp;quot;NRF_WDT&amp;quot;, NRF_WDT, CONFIG_SPM_NRF_WDT_NS),
#endif
#ifdef NRF_I2S
		PERIPH(&amp;quot;NRF_I2S&amp;quot;, NRF_I2S, CONFIG_SPM_NRF_I2S_NS),
#endif
		/* There is no DTS node for the peripherals below,
		 * so address them using nrfx macros directly.
		 */
		PERIPH(&amp;quot;NRF_IPC&amp;quot;, NRF_IPC_S, CONFIG_SPM_NRF_IPC_NS),
		PERIPH(&amp;quot;NRF_VMC&amp;quot;, NRF_VMC_S, CONFIG_SPM_NRF_VMC_NS),
		PERIPH(&amp;quot;NRF_FPU&amp;quot;, NRF_FPU_S, CONFIG_SPM_NRF_FPU_NS),
		PERIPH(&amp;quot;NRF_EGU1&amp;quot;, NRF_EGU1_S, CONFIG_SPM_NRF_EGU1_NS),
		PERIPH(&amp;quot;NRF_EGU2&amp;quot;, NRF_EGU2_S, CONFIG_SPM_NRF_EGU2_NS),
		PERIPH(&amp;quot;NRF_DPPIC&amp;quot;, NRF_DPPIC_S, CONFIG_SPM_NRF_DPPIC_NS),

		PERIPH(&amp;quot;NRF_GPIOTE1&amp;quot;, NRF_GPIOTE1_NS,
				      CONFIG_SPM_NRF_GPIOTE1_NS),
		PERIPH(&amp;quot;NRF_REGULATORS&amp;quot;, NRF_REGULATORS_S,
				      CONFIG_SPM_NRF_REGULATORS_NS),
	};

	if (IS_ENABLED(CONFIG_SPM_NRF_DPPIC_NS)) {
		spm_dppi_configure(CONFIG_SPM_NRF_DPPIC_PERM_MASK);
	}

	PRINT(&amp;quot;Peripheral\t\tDomain\t\tStatus\n&amp;quot;);

	if (IS_ENABLED(CONFIG_SPM_NRF_P0_NS)) {
		/* Configure GPIO pins to be Non-Secure */
		NRF_SPU-&amp;gt;GPIOPORT[0].PERM = 0;
	}

	for (size_t i = 0; i &amp;lt; ARRAY_SIZE(periph); i++) {
		int err;

#ifndef CONFIG_SPM_BOOT_SILENTLY
		PRINT(&amp;quot;%02u %-21s%s&amp;quot;, i, periph[i].name,
		      periph[i].nonsecure ? &amp;quot;Non-Secure&amp;quot; : &amp;quot;Secure\t&amp;quot;);
#endif

		if (!periph[i].nonsecure) {
			PRINT(&amp;quot;\tSKIP\n&amp;quot;);
			continue;
		}

		err = spm_config_peripheral(periph[i].id, false);
		if (err) {
			PRINT(&amp;quot;\tERROR\n&amp;quot;);
		} else {
			PRINT(&amp;quot;\tOK\n&amp;quot;);
		}
	}
	PRINT(&amp;quot;\n&amp;quot;);
}


static void spm_configure_ns(const tz_nonsecure_setup_conf_t
	*spm_ns_conf)
{
	/* Configure core register block for Non-Secure state. */
	tz_nonsecure_state_setup(spm_ns_conf);
	/* Prioritize Secure exceptions over Non-Secure */
	tz_nonsecure_exception_prio_config(1);
	/* Set non-banked exceptions to target Non-Secure */
	tz_nbanked_exception_target_state_set(0);
	/* Configure if Non-Secure firmware should be allowed to issue System
	 * reset. If not it could be enabled through a secure service.
	 */
	tz_nonsecure_system_reset_req_block(
		IS_ENABLED(CONFIG_SPM_BLOCK_NON_SECURE_RESET)
	);
	/* Allow SPU to have precedence over (non-existing) ARMv8-M SAU. */
	tz_sau_configure(0, 1);

#if defined(CONFIG_ARMV7_M_ARMV8_M_FP) &amp;amp;&amp;amp; defined(CONFIG_SPM_NRF_FPU_NS)
	/* Allow Non-Secure firmware to use the FPU */
	tz_nonsecure_fpu_access_enable();
#endif /* CONFIG_ARMV7_M_ARMV8_M_FP */
}

void spm_jump(void)
{
	/* Extract initial MSP of the Non-Secure firmware image.
	 * The assumption is that the MSP is located at VTOR_NS[0].
	 */
	u32_t *vtor_ns = (u32_t *)NON_SECURE_APP_ADDRESS;

	PRINT(&amp;quot;SPM: NS image at 0x%x\n&amp;quot;, (u32_t)vtor_ns);
	PRINT(&amp;quot;SPM: NS MSP at 0x%x\n&amp;quot;, vtor_ns[0]);
	PRINT(&amp;quot;SPM: NS reset vector at 0x%x\n&amp;quot;, vtor_ns[1]);

	/* Configure Non-Secure stack */
	tz_nonsecure_setup_conf_t spm_ns_conf = {
		.vtor_ns = (u32_t)vtor_ns,
		.msp_ns = vtor_ns[0],
		.psp_ns = 0,
		.control_ns.npriv = 0, /* Privileged mode*/
		.control_ns.spsel = 0 /* Use MSP in Thread mode */
	};

	spm_configure_ns(&amp;amp;spm_ns_conf);

	/* Generate function pointer for Non-Secure function call. */
	TZ_NONSECURE_FUNC_PTR_DECLARE(reset_ns);
	reset_ns = TZ_NONSECURE_FUNC_PTR_CREATE(vtor_ns[1]);

	if (TZ_NONSECURE_FUNC_PTR_IS_NS(reset_ns)) {
		PRINT(&amp;quot;SPM: prepare to jump to Non-Secure image.\n&amp;quot;);

		/* Note: Move UARTE0 before jumping, if it is
		 * to be used on the Non-Secure domain.
		 */

		/* Configure UARTE0 as non-secure */
		spm_config_peripheral(
			NRFX_PERIPHERAL_ID_GET(NRF_UARTE0), 0);

		__DSB();
		__ISB();

		/* Jump to Non-Secure firmware */
		reset_ns();

		CODE_UNREACHABLE;

	} else {
		PRINT(&amp;quot;SPM: wrong pointer type: 0x%x\n&amp;quot;,
		      (u32_t)reset_ns);
	}
}

void spm_config(void)
{
	spm_config_flash();
	spm_config_sram();
	spm_config_peripherals();
}
&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;Kconfig (line 215)&lt;br /&gt;&lt;pre class="ui-code" data-mode="text"&gt;#
# Copyright (c) 2019 Nordic Semiconductor ASA
#
# SPDX-License-Identifier: LicenseRef-BSD-5-Clause-Nordic
#

menu &amp;quot;SPM&amp;quot;

config SPM
	bool &amp;quot;Use Secure Partition Manager&amp;quot;
	default y if TRUSTED_EXECUTION_NONSECURE
	select FW_INFO
	imply ARM_FIRMWARE_USES_SECURE_ENTRY_FUNCS

if SPM
module=SPM
source &amp;quot;${ZEPHYR_BASE}/../nrf/subsys/partition_manager/Kconfig.template.build_strategy&amp;quot;
endif


menuconfig IS_SPM
	bool &amp;quot;Current app is SPM&amp;quot;
	default n
	select TRUSTED_EXECUTION_SECURE

if IS_SPM
# Define used by partition_manager.py to deduce size of partition.
# Unable to use the size template due to non-trivial defaults.
config PM_PARTITION_SIZE_SPM
	hex &amp;quot;Flash space reserved for SPM&amp;quot;
	default 0xc000 if SPM_SERVICE_RNG # To build correctly with MCUboot.
	default 0x8000
	help
	  Flash space set aside for the SPM. Note, the name
	  of this configuration needs to match the requirements set by the
	  script &amp;#39;partition_manager.py&amp;#39;. See pm.yml.

config SPM_BOOT_SILENTLY
	bool &amp;quot;Boot silently&amp;quot;
	default n

config SPM_SECURE_SERVICES
	bool &amp;quot;Enable secure services&amp;quot;
	default y
	select ARM_FIRMWARE_HAS_SECURE_ENTRY_FUNCS
	help
	  Secure services can be invoked from the Non-Secure Firmware via
	  secure entry functions.

if SPM_SECURE_SERVICES
config SPM_SERVICE_RNG
	bool &amp;quot;Request random numbers&amp;quot;
	default y
	select NORDIC_SECURITY_BACKEND
	select FLOAT

# NORDIC_SECURITY_BACKEND is not supported on 53 yet
	depends on ! SOC_NRF5340_CPUAPP

	help
	  The Non-Secure Firmware is not allowed to use the crypto hardware.
	  This service allows it to request random numbers from the SPM.

config SPM_SERVICE_READ
	bool &amp;quot;Read from memory&amp;quot;
	default y
	help
	  The Non-Secure Firmware is not allowed to read the memory
	  marked as secure. This service allows it to request random
	  read operations within the ranges configured in
	  secure_services.c.

config SPM_SERVICE_REBOOT
	bool &amp;quot;Enable system reset as a secure service&amp;quot;
	default n
	select REBOOT
	help
	  If Non-Secure Firmware is blocked from issuing system reset, this
	  service will allow it to issue a request to do a system reset through
	  a secure service.

config SPM_SERVICE_FIND_FIRMWARE_INFO
	bool &amp;quot;Find firmware info&amp;quot;
	default y
	help
	  The Non-Secure Firmware is not allowed to read the memory
	  marked as secure. This service allows it to request firmware info
	  about image stored at a given address.

config SPM_SERVICE_PREVALIDATE
	bool &amp;quot;Prevalidate B1 upgrades (Requires Immutable Bootloader)&amp;quot;
	default n
	select SECURE_BOOT_CRYPTO
	select SECURE_BOOT_VALIDATION
	select BL_VALIDATE_FW_EXT_API_ATLEAST_OPTIONAL
	help
	  The B0 bootloader allows calls into it for prevalidating upgrades of
	  the stage it verifies. The B0 bootloader is in secure memory, so this
	  secure service is needed for the app to access the prevalidation
	  function.

endif # SPM_SECURE_SERVICES

config SPM_BLOCK_NON_SECURE_RESET
	bool &amp;quot;Block system reset calls from Non-Secure domain&amp;quot;
	default n #FIXME: Remove mention of debugger with regards to reboot in help text when NRF91-313 has been resolved
	help
	  This will block the application running in Non-Secure from being able
	  to issue a system reset of the chip without going through a secure
	  service. If not enabled, a debugger will not be able to issue a
	  system reset while the core is executing Non-Secure code.

menu &amp;quot;Configure Non-Secure peripherals&amp;quot;

config SPM_NRF_CLOCK_NS
	bool &amp;quot;Clock control is Non-Secure&amp;quot;
	default y

config SPM_NRF_RTC0_NS
	bool &amp;quot;RTC0 is Non-Secure&amp;quot;
	default y

config SPM_NRF_RTC1_NS
	bool &amp;quot;RTC1 is Non-Secure&amp;quot;
	default y

config SPM_NRF_IPC_NS
	bool &amp;quot;IPC is Non-Secure&amp;quot;
	default y

config SPM_NRF_NVMC_NS
	bool &amp;quot;NVMC is Non-Secure&amp;quot;
	default y

config SPM_NRF_VMC_NS
	bool &amp;quot;VMC is Non-Secure&amp;quot;
	default y

config SPM_NRF_P0_NS
	bool &amp;quot;GPIO is Non-Secure&amp;quot;
	default y

config SPM_NRF_GPIOTE1_NS
	bool &amp;quot;GPIOTE1 IRQ available in Non-Secure domain&amp;quot;
	default y

config SPM_NRF_UARTE1_NS
	bool &amp;quot;UARTE1 is Non-Secure&amp;quot;
	default y

config SPM_NRF_UARTE2_NS
	bool &amp;quot;UARTE2 is Non-Secure&amp;quot;
	default n

config SPM_NRF_EGU1_NS
	bool &amp;quot;EGU1 is Non-Secure&amp;quot;
	default y

config SPM_NRF_EGU2_NS
	bool &amp;quot;EGU2 is Non-Secure&amp;quot;
	default y

config SPM_NRF_FPU_NS
	bool &amp;quot;FPU is Non-Secure&amp;quot;
	default y

config SPM_NRF_TWIM2_NS
	bool &amp;quot;TWIM2 is Non-Secure&amp;quot;
	default y

config SPM_NRF_SPIM3_NS
	bool &amp;quot;SPIM3 is Non-Secure&amp;quot;
	default y

config SPM_NRF_TIMER0_NS
	bool &amp;quot;TIMER0 is Non-Secure&amp;quot;
	default y

config SPM_NRF_TIMER1_NS
	bool &amp;quot;TIMER1 is Non-Secure&amp;quot;
	default y

config SPM_NRF_TIMER2_NS
	bool &amp;quot;TIMER2 is Non-Secure&amp;quot;
	default y

config SPM_NRF_SAADC_NS
	bool &amp;quot;SAADC is Non-Secure&amp;quot;
	default y

config SPM_NRF_PWM0_NS
	bool &amp;quot;PWM0 is Non-Secure&amp;quot;
	default y

config SPM_NRF_PWM1_NS
	bool &amp;quot;PWM1 is Non-Secure&amp;quot;
	default y

config SPM_NRF_PWM2_NS
	bool &amp;quot;PWM2 is Non-Secure&amp;quot;
	default y

config SPM_NRF_PWM3_NS
	bool &amp;quot;PWM3 is Non-Secure&amp;quot;
	default y

config SPM_NRF_REGULATORS_NS
	bool &amp;quot;Regulators is Non-Secure&amp;quot;
	default y

config SPM_NRF_WDT_NS
	bool &amp;quot;WDT is Non-Secure&amp;quot;
	default y

config SPM_NRF_I2S_NS
	bool &amp;quot;I2S is Non-Secure&amp;quot;
	default y
endmenu

config SPM_NRF_DPPIC_NS
	bool &amp;quot;DPPIC is Non-Secure&amp;quot;
	default y

config SPM_NRF_DPPIC_PERM_MASK
	hex &amp;quot;Set DPPIC PERM mask for Non-secure&amp;quot;
	default 0x00000000
	depends on SPM_NRF_DPPIC_NS
	help
	  The input mask is a mirror of the permission bits set in
	  register SPU.DPPI.PERM[] to allow non-secure application to
	  control DPPIC per the given input mask.
	  The default value is to allow all DPPI channels to non-secure region.

endif # IS_SPM

# Set new default name for the veneers file.

if ARM_FIRMWARE_USES_SECURE_ENTRY_FUNCS
config ARM_ENTRY_VENEERS_LIB_NAME
	string &amp;quot;Entry Veneers symbol file&amp;quot;
	default &amp;quot;spm/libspmsecureentries.a&amp;quot;
endif

if ARM_FIRMWARE_HAS_SECURE_ENTRY_FUNCS
config ARM_ENTRY_VENEERS_LIB_NAME
	string &amp;quot;Entry Veneers symbol file&amp;quot;
	default &amp;quot;libspmsecureentries.a&amp;quot;
endif

endmenu # SPM
&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Adafruit I2S MEMS Microphone Breakout with the NRF9160 DK</title><link>https://devzone.nordicsemi.com/thread/248831?ContentTypeID=1</link><pubDate>Thu, 07 May 2020 23:00:51 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:f59ccf79-1dfe-42c6-8710-7383fcda5adc</guid><dc:creator>Nahom Abraha</dc:creator><description>&lt;p&gt;Hi Martin,&lt;/p&gt;
&lt;p&gt;I am having trouble with the i2s_configure function this is my code and overlay file. I call the recordaudio function in a different file and then I something goes wrong in i2s_init funtion&amp;nbsp; at i2s_configure. The code stops after the i2s_configure&amp;nbsp; function.&lt;/p&gt;
&lt;p&gt;Thank you in advance&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;#include &amp;lt;zephyr.h&amp;gt;
#include &amp;lt;device.h&amp;gt;
#include &amp;lt;drivers/i2s.h&amp;gt;
#include &amp;lt;sys/printk.h&amp;gt;
#include &amp;lt;stdbool.h&amp;gt;

#include &amp;quot;microphone.h&amp;quot;
#include &amp;quot;button.h&amp;quot;
#include &amp;quot;udp.h&amp;quot;

#define  MICROPHONE_SAMPLE_FREQ (8000)
#define  MICROPHONE_SAMPLE_PER_FRAME (1)
#define  MICROPHONE_NUM_CHANNELS (1)
#define  MICROPHONE_SAMPLE_BIT_WIDTH (24)
#define  MICROPHONE_SAMPLE_BYTES (2)
#define  MICROPHONE_BLOCK_SIZE (4)
#define  DEVICE_NAME  &amp;quot;I2S_0&amp;quot; 


struct k_mem_slab mic_mem_slab;
struct device *i2s_device;

K_MEM_SLAB_DEFINE(mic_mem_slab,MICROPHONE_BLOCK_SIZE,MICROPHONE_SAMPLE_FREQ,4);

void i2s_init()
{
  struct i2s_config i2s_cfg;
  int config;
  
  i2s_device=device_get_binding(DEVICE_NAME);
  
  i2s_cfg.word_size=MICROPHONE_SAMPLE_BIT_WIDTH;
  i2s_cfg.channels=MICROPHONE_NUM_CHANNELS;
  i2s_cfg.format=I2S_FMT_DATA_FORMAT_I2S;
  i2s_cfg.options=I2S_OPT_FRAME_CLK_MASTER |I2S_OPT_BIT_CLK_MASTER;//?
  i2s_cfg.frame_clk_freq=MICROPHONE_SAMPLE_FREQ;
  i2s_cfg.mem_slab=&amp;amp;mic_mem_slab;
  i2s_cfg.block_size=MICROPHONE_BLOCK_SIZE*MICROPHONE_SAMPLE_FREQ;
  i2s_cfg.timeout=K_FOREVER;
  
  config=i2s_configure(i2s_device,I2S_DIR_RX,&amp;amp;i2s_cfg);
  if(config!=0){
      printk(&amp;quot;i2s_configure failed with %d error&amp;quot;, config);
  }
 

}

void recordaudio(void)
{
  int ret;
  int trigger;
  void *buf;  //uint32_t
  size_t size;
  //configure i2s and start
  i2s_init();
  printk(&amp;quot;Starting recording...&amp;quot;);
  
  trigger=i2s_trigger(i2s_device,I2S_DIR_RX,I2S_TRIGGER_START); 
  if(trigger!=0){
    printk(&amp;quot;TRIGGER_START failed with %d error&amp;quot;, trigger);
  }
  
  while(startrecording==true){
    ret=i2s_read(i2s_device,&amp;amp;buf,&amp;amp;size);
    if(ret!=0){
      printk(&amp;quot;i2s_read failed with %d error&amp;quot;, ret);
    }
  }
    i2s_trigger(i2s_device,I2S_DIR_RX,I2S_TRIGGER_STOP);
    if(trigger!=0){
      printk(&amp;quot;TRIGGER_STOP failed with %d error&amp;quot;, trigger);
    }

    i2s_trigger(i2s_device,I2S_DIR_RX,I2S_TRIGGER_DROP);
    if(trigger!=0){
      printk(&amp;quot;TRIGGER_DROP failed with %d error&amp;quot;, trigger);
    }
  printk(&amp;quot;Exiting program...&amp;quot;);
}


&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;&amp;amp;i2s0 {
	    status = &amp;quot;okay&amp;quot;;
        sdout-pin=&amp;lt;8&amp;gt;;
	    lrck-pin=&amp;lt;9&amp;gt;;
        sck-pin=&amp;lt;10&amp;gt;;
        sdin-pin=&amp;lt;11&amp;gt;;
        mck-pin=&amp;lt;12&amp;gt;;
};
&lt;/pre&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Adafruit I2S MEMS Microphone Breakout with the NRF9160 DK</title><link>https://devzone.nordicsemi.com/thread/247532?ContentTypeID=1</link><pubDate>Thu, 30 Apr 2020 11:55:55 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:603c9649-485e-4fdc-8979-5846a013128c</guid><dc:creator>Martin Lesund</dc:creator><description>&lt;p&gt;Hi Nahom,&lt;/p&gt;
&lt;p&gt;You can configure any of the available GPIO pins for the nrf9160.&lt;/p&gt;
&lt;p&gt;So you could use the&amp;nbsp;command&amp;nbsp;&lt;a href="https://developer.nordicsemi.com/nRF_Connect_SDK/doc/latest/zephyr/reference/peripherals/i2s.html#_CPPv413i2s_configureP6device7i2s_dirP10i2s_config"&gt;https://developer.nordicsemi.com/nRF_Connect_SDK/doc/latest/zephyr/reference/peripherals/i2s.html#_CPPv413i2s_configureP6device7i2s_dirP10i2s_config&lt;/a&gt;&amp;nbsp;and in the .overlay file select which pins it should get.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;See the device tree chapter in the NCS tutorials.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Adafruit I2S MEMS Microphone Breakout with the NRF9160 DK</title><link>https://devzone.nordicsemi.com/thread/247426?ContentTypeID=1</link><pubDate>Wed, 29 Apr 2020 23:11:06 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:f00da1e3-3b62-4af1-be38-ccb20e9aa4b0</guid><dc:creator>Nahom Abraha</dc:creator><description>&lt;p&gt;Hi Martin,&lt;/p&gt;
&lt;p&gt;Thank you for your answer, but I have another question. How does the nrf9160 dk know which pin to use for the I2S, because in the zephyr documentation there aren&amp;#39;t any pin configuration for I2S. What I did saw were documentation for pin configuration for the nrfx i2s driver.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Thank you in advance&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Adafruit I2S MEMS Microphone Breakout with the NRF9160 DK</title><link>https://devzone.nordicsemi.com/thread/246554?ContentTypeID=1</link><pubDate>Fri, 24 Apr 2020 14:03:25 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:9edce305-1f51-4cef-bde3-49de4a28e7d5</guid><dc:creator>Martin Lesund</dc:creator><description>&lt;p&gt;Hi Nahom,&lt;/p&gt;
&lt;p&gt;Here is the &lt;a href="https://infocenter.nordicsemi.com/index.jsp?topic=%2Fps_nrf9160%2Fi2s.html&amp;amp;cp=2_0_0_5_6" rel="noopener noreferrer" target="_blank"&gt;I2S peripheral documentation in nRF9160.&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;If you have issues following the &lt;a href="https://developer.nordicsemi.com/nRF_Connect_SDK/doc/latest/zephyr/reference/peripherals/i2s.html" rel="noopener noreferrer" target="_blank"&gt;zephyr doc on the I2S peripheral&lt;/a&gt;. then another option is that you&amp;nbsp;&lt;em&gt;can&amp;nbsp;&lt;/em&gt;use the &lt;a href="https://github.com/NordicSemiconductor/nrfx/blob/master/drivers/include/nrfx_i2s.h" rel="noopener noreferrer" target="_blank"&gt;nrfx_i2s driver directly&lt;/a&gt;&amp;nbsp;using the &lt;a href="https://github.com/NordicPlayground/fw-nrfconnect-zephyr/tree/master/samples/boards/nrf/nrfx" rel="noopener noreferrer" target="_blank"&gt;nRF91 nrfx sample as reference.&lt;br /&gt;&lt;br /&gt;T&lt;/a&gt;he pins are programmable (GPIOS) so &lt;a href="https://infocenter.nordicsemi.com/index.jsp?topic=%2Fps_nrf9160%2Fpin.html&amp;amp;cp=2_0_0_9_0" rel="noopener noreferrer" target="_blank"&gt;just use those&lt;/a&gt;.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;/p&gt;
&lt;p&gt;I recommend checking out:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a title="https://devzone.nordicsemi.com/nordic/cellular-iot-guides/b/getting-started-cellular/posts/nrf-connect-sdk-tutorial" href="https://devzone.nordicsemi.com/nordic/cellular-iot-guides/b/getting-started-cellular/posts/nrf-connect-sdk-tutorial" rel="noopener noreferrer" target="_blank"&gt;NCS Tutorial - Part 0&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a title="https://devzone.nordicsemi.com/nordic/cellular-iot-guides/b/getting-started-cellular/posts/ncs-tutorial---temporary" href="https://devzone.nordicsemi.com/nordic/cellular-iot-guides/b/getting-started-cellular/posts/ncs-tutorial---temporary" rel="noopener noreferrer" target="_blank"&gt;NCS Tutorial - Part 1&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a title="https://devzone.nordicsemi.com/nordic/cellular-iot-guides/b/getting-started-cellular/posts/nrf-connect-sdk-tutorial---part-2-1478313418" href="https://devzone.nordicsemi.com/nordic/cellular-iot-guides/b/getting-started-cellular/posts/nrf-connect-sdk-tutorial---part-2-1478313418" rel="noopener noreferrer" target="_blank"&gt;NCS Tutorial - Part 2&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a title="https://devzone.nordicsemi.com/nordic/cellular-iot-guides/b/getting-started-cellular/posts/nrf-connect-sdk-tutorial---part-3-temporary" href="https://devzone.nordicsemi.com/nordic/cellular-iot-guides/b/getting-started-cellular/posts/nrf-connect-sdk-tutorial---part-3-temporary" rel="noopener noreferrer" target="_blank"&gt;NCS Tutorial - Part 3&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>