<?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>How do I use the I2S interface on the 9160</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/72483/how-do-i-use-the-i2s-interface-on-the-9160</link><description>I want to realize audio playing function in 9160, according to the specification, there are 9160 I2S interface. However, the specification only describe the definition of some registers in the book, I didn&amp;#39;t find related sample code in ncs1.2, and I don</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Tue, 09 Mar 2021 09:36:46 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/72483/how-do-i-use-the-i2s-interface-on-the-9160" /><item><title>RE: How do I use the I2S interface on the 9160</title><link>https://devzone.nordicsemi.com/thread/298606?ContentTypeID=1</link><pubDate>Tue, 09 Mar 2021 09:36:46 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:31ebb93b-5c99-466b-b512-fb7fae318194</guid><dc:creator>duxinglang</dc:creator><description>&lt;p&gt;yes, I used the variable to look at the actual address, and found a problem,&amp;nbsp;&lt;span&gt;When the program goes here, I see reg_addr=0x40028104, and the program is work well,&amp;nbsp;like this:&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;NRF_STATIC_INLINE void nrf_i2s_event_clear(NRF_I2S_Type * p_reg,
nrf_i2s_event_t event)
{
reg_addr = ((uint8_t *)p_reg + (uint32_t)event);
*((volatile uint32_t *)((uint8_t *)p_reg + (uint32_t)event)) = 0x0UL;
#if __CORTEX_M == 0x04
volatile uint32_t dummy = *((volatile uint32_t *)((uint8_t *)p_reg + (uint32_t)event));
(void)dummy;
#endif
}

&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;when the program goes here, I see reg_addr=0x40028000, and the program crashes, like this:&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;pre class="ui-code" data-mode="text"&gt;NRF_STATIC_INLINE void nrf_i2s_task_trigger(NRF_I2S_Type * p_reg,
                                            nrf_i2s_task_t task)
{
	reg_addr = ((uint8_t *)p_reg + (uint32_t)task);
    *((volatile uint32_t *)((uint8_t *)p_reg + (uint32_t)task)) = 0x1UL;
}
&lt;/pre&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;/span&gt;&lt;span&gt;&lt;span class="transSent"&gt;So, what&amp;#39;s the reason?&amp;nbsp;&lt;/span&gt;&lt;span class="transSent"&gt;The two addresses may not seem very different, but they lead to completely different results.&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How do I use the I2S interface on the 9160</title><link>https://devzone.nordicsemi.com/thread/298584?ContentTypeID=1</link><pubDate>Tue, 09 Mar 2021 08:41:46 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:b2b6301e-c45e-44e7-ac23-8329faa6dae5</guid><dc:creator>Kenneth</dc:creator><description>&lt;p&gt;I suggest to put the &amp;#39;(volatile uint32_t *)((uint8_t *)p_reg + (uint32_t)task)&amp;#39; into a variable, so you can see what memory/pointer address you are actually trying to write to.&lt;/p&gt;
&lt;p&gt;Kenneth&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How do I use the I2S interface on the 9160</title><link>https://devzone.nordicsemi.com/thread/298561?ContentTypeID=1</link><pubDate>Tue, 09 Mar 2021 06:46:20 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:4bf0aeb1-cb99-4870-9fbe-9735da312519</guid><dc:creator>duxinglang</dc:creator><description>&lt;p&gt;&lt;span class="transSent"&gt;Now I&amp;#39;m using&amp;nbsp;nrfx directly can initialize I2s, but I find that when I start I2s, the program crashes.&lt;/span&gt;&lt;span class="transSent"&gt;I tracked it down and it crashed here, I can&amp;#39;t see what&amp;#39;s wrong with it.like this:&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span class="transSent"&gt;&lt;pre class="ui-code" data-mode="text"&gt;NRF_STATIC_INLINE void nrf_i2s_task_trigger(NRF_I2S_Type * p_reg,
                                            nrf_i2s_task_t task)
{
    *((volatile uint32_t *)((uint8_t *)p_reg + (uint32_t)task)) = 0x1UL;
}
&lt;/pre&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span class="transSent"&gt;This is my code:&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span class="transSent"&gt;&lt;pre class="ui-code" data-mode="text"&gt;void test_i2s(void)
{
	uint32_t err_code = NRFX_SUCCESS;
	
	nrfx_i2s_config_t config = NRFX_I2S_DEFAULT_CONFIG(I2S_BCK,I2S_LRCK,I2S_MCK,I2S_DO,I2S_DI);
	// In Master mode the MCK frequency and the MCK/LRCK ratio should be
	// set properly in order to achieve desired audio sample rate (which
	// is equivalent to the LRCK frequency).
	// For the following settings we&amp;#39;ll get the LRCK frequency equal to
	// 15873 Hz (the closest one to 16 kHz that is possible to achieve).
	config.mode         = NRF_I2S_MODE_MASTER;
	config.format       = NRF_I2S_FORMAT_I2S;
	config.alignment    = NRF_I2S_ALIGN_LEFT;
	config.sample_width = NRF_I2S_SWIDTH_16BIT;
	config.channels     = NRF_I2S_CHANNELS_LEFT;
	config.mck_setup    = NRF_I2S_MCK_32MDIV8;
	config.ratio        = NRF_I2S_RATIO_32X;

	err_code = nrfx_i2s_init(&amp;amp;config, data_handler);
	__ASSERT(err_code == NRFX_SUCCESS, &amp;quot;i2s init error&amp;quot;);

	for (;;)
	{
		m_blocks_transferred = 0;
		mp_block_to_fill  = NULL;
		mp_block_to_check = NULL;

		prepare_tx_data(m_buffer_tx[0]);

		nrfx_i2s_buffers_t const initial_buffers = {
		    .p_tx_buffer = m_buffer_tx[0],
		    .p_rx_buffer = m_buffer_rx[0],
		};
		err_code = nrfx_i2s_start(&amp;amp;initial_buffers, I2S_DATA_BLOCK_WORDS, 0);
		__ASSERT(err_code == NRFX_SUCCESS, &amp;quot;i2s start error!&amp;quot;);

		do {
		    // Wait for an event.
		    __WFE();
		    // Clear the event register.
		    __SEV();
		    __WFE();

		    if (mp_block_to_fill)
		    {
		        prepare_tx_data(mp_block_to_fill);
		        mp_block_to_fill = NULL;
		    }
		    if (mp_block_to_check)
		    {
		        check_rx_data(mp_block_to_check);
		        mp_block_to_check = NULL;
		    }
		} while (m_blocks_transferred &amp;lt; BLOCKS_TO_TRANSFER);

		nrfx_i2s_stop();

		k_sleep(K_MSEC(PAUSE_TIME));
    }
}
&lt;/pre&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span class="transSent"&gt;&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How do I use the I2S interface on the 9160</title><link>https://devzone.nordicsemi.com/thread/298395?ContentTypeID=1</link><pubDate>Mon, 08 Mar 2021 13:36:49 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:0ee7e35b-a026-4809-a9d9-4c143c254f29</guid><dc:creator>Kenneth</dc:creator><description>&lt;p&gt;Hello,&lt;/p&gt;
&lt;p&gt;There is no&amp;nbsp;nrf i2s driver support available for zephyr&amp;nbsp;yet (zephyr/drivers/i2s does not contain any &amp;#39;nrf&amp;#39; implementation). So you would need to use nrfx directly, however I can&amp;#39;t find any example for it, but I can find some have been looking into it here:&lt;br /&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;&lt;/p&gt;
&lt;p&gt;If possible I highly recommend to update to&amp;nbsp;newer ncs version.&lt;/p&gt;
&lt;p&gt;Kenneth&lt;/p&gt;
&lt;p&gt;&lt;br /&gt;&lt;br /&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>