<?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>SPH0645 I2S MIC DATA FORMAT</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/115390/sph0645-i2s-mic-data-format</link><description>Hi,I have been using nrf5340 audio DK Board to access the I2S .I am using SPH0645 mic with that i need to get mic data .My Mic datasheet specifies that &amp;quot;The Data Format is I2S, 24-bit, 2’s compliment, MSB first. The data precision is 18 bits; unused bits</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Fri, 25 Oct 2024 08:22:49 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/115390/sph0645-i2s-mic-data-format" /><item><title>RE: SPH0645 I2S MIC DATA FORMAT</title><link>https://devzone.nordicsemi.com/thread/507872?ContentTypeID=1</link><pubDate>Fri, 25 Oct 2024 08:22:49 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:112d9632-3db8-4936-9254-bde2f188a00b</guid><dc:creator>Elfving</dc:creator><description>&lt;p&gt;Great to see that you&amp;#39;ve gotten further and also shared this solution&amp;nbsp;Kashyap.&lt;/p&gt;
[quote user="Kashyap23"]But I dont know what size can I give in that.[/quote]
&lt;p&gt;I am not sure if I understand the problem, but&amp;nbsp;&lt;span&gt;&lt;a href="https://docs.nordicsemi.com/bundle/ncs-latest/page/kconfig/index.html#CONFIG_SEGGER_RTT_BUFFER_SIZE_UP"&gt;CONFIG_SEGGER_RTT_BUFFER_SIZE_UP &lt;/a&gt;doesn&amp;#39;t seem to have a max but several samples increase it from the default&amp;nbsp;1024 to&amp;nbsp;4096.&amp;nbsp;&lt;a href="https://docs.nordicsemi.com/bundle/ncs-latest/page/kconfig/index.html#CONFIG_LOG_BUFFER_SIZE"&gt;CONFIG_LOG_BUFFER_SIZE&lt;/a&gt;&amp;nbsp;is often increased to&amp;nbsp;4096 as well.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Maybe it seems practical at the moment, though logging every single measurement doesn&amp;#39;t seem necessary in a final application to me. So I guess this isn&amp;#39;t a big issue either way, no matter what you increase it to for the time being.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Regards,&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Elfving&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: SPH0645 I2S MIC DATA FORMAT</title><link>https://devzone.nordicsemi.com/thread/507665?ContentTypeID=1</link><pubDate>Thu, 24 Oct 2024 01:54:36 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:b02b6a20-6e8e-4190-a6de-ab906484f3d3</guid><dc:creator>Kashyap23</dc:creator><description>&lt;p&gt;Hi,I able to solve the issue ,the main thing is by logging data by RTT the buffer size is very low 1024 which is default once I increased size it works this is done by increasing&amp;nbsp;&lt;span&gt;CONFIG_SEGGER_RTT_BUFFER_SIZE_UP,CONFIG_LOG_BUFFER_SIZE&lt;/span&gt;&lt;/p&gt;
&lt;div&gt;&lt;br /&gt;
&lt;div&gt;&lt;span&gt;CONFIG_LOG_MODE_OVERFLOW&lt;/span&gt;&lt;span&gt;=n&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt;CONFIG_SEGGER_RTT_BUFFER_SIZE_UP&lt;/span&gt;&lt;span&gt;=1024&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt;CONFIG_LOG_BUFFER_SIZE&lt;/span&gt;&lt;span&gt;=1024&lt;/span&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;div&gt;&lt;span&gt;CONFIG_LOG_PROCESS_THREAD_STACK_SIZE&lt;/span&gt;&lt;span&gt;=2048&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt;But I dont know what size can I give in that.I increased it randomly by keeping 50k my sampling rate is 16k and each sample 16bits .Can you help me what size do I need to define correctly.&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: SPH0645 I2S MIC DATA FORMAT</title><link>https://devzone.nordicsemi.com/thread/507128?ContentTypeID=1</link><pubDate>Mon, 21 Oct 2024 12:23:06 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:8ede5297-cc63-4fb7-bf4f-66ad3787d69e</guid><dc:creator>Kashyap23</dc:creator><description>&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;Sample 1578: -1755
Sample 1579: -1748
Sample 1580: -1735
Sample 1581: -1717
Sample 1582: -1701
Sample 1583: -1688
Sample 1584: -1679
Sample 1585: -1676
Sample 1586: -1683
Sample 1587: -1695
Sample 1588: -1695
Sample 1589: -1685
Sample 1590: -1676
Sample 1591: -1682
Sample 1592: -1707
Sample 1593: -1719
Sample 1594: -1708
Sample 1595: -1702
Sample 1596: -1719
Sample 1597: -1741
Sample 1598: -1757
Sample 1599: -1760
Sample 1568: -1752
--- 1568 messages dropped ---
Sample 1569: -1752
Sample 1570: -1743
Sample 1571: -1731
Sample 1572: -1722
Sample 1573: -1713
Sample 1574: -1699
Sample 1575: -1683
Sample 1576: -1661
Sample 1577: -1643
Sample 1578: -1640
Sample 1579: -1647
Sample 1580: -1661
Sample 1581: -1670
Sample 1582: -1674
Sample 1583: -1691
Sample 1584: -1722
Sample 1585: -1747
Sample 1586: -1759
Sample 1587: -1760
Sample 1588: -1748
Sample 1589: -1745
Sample 1590: -1752
Sample 1591: -1748
Sample 1592: -1752
Sample 1593: -1769
Sample 1594: -1780
Sample 1595: -1783
Sample 1596: -1786
Sample 1597: -1789
Sample 1598: -1792
Sample 1599: -1797
Sample 1568: -1738
--- 1568 messages dropped ---
Sample 1569: -1723
Sample 1570: -1720
Sample 1571: -1700
Sample 1572: -1655
Sample 1573: -1617
Sample 1574: -1606
Sample 1575: -1616
Sample 1576: -1609
Sample 1577: -1589
Sample 1578: -1577
Sample 1579: -1584
Sample 1580: -1603
Sample 1581: -1606
Sample 1582: -1621
Sample 1583: -1650
Sample 1584: -1665
Sample 1585: -1678
Sample 1586: -1699
Sample 1587: -1711
Sample 1588: -1712
Sample 1589: -1721
Sample 1590: -1731
Sample 1591: -1733
Sample 1592: -1737
Sample 1593: -1734
Sample 1594: -1743
Sample 1595: -1768
Sample 1596: -1787
Sample 1597: -1801
Sample 1598: -1815
Sample 1599: -1823
Sample 1568: -1735
--- 1568 messages dropped ---
Sample 1569: -1770
Sample 1570: -1783
Sample 1571: -1805
Sample 1572: -1837
Sample 1573: -1828
Sample 1574: -1794
Sample 1575: -1785
Sample 1576: -1820
Sample 1577: -1837
Sample 1578: -1773
Sample 1579: -1703
Sample 1580: -1716
Sample 1581: -1759
Sample 1582: -1747
Sample 1583: -1660
Sample 1584: -1597
Sample 1585: -1646
Sample 1586: -1710
Sample 1587: -1706
Sample 1588: -1696
Sample 1589: -1722
Sample 1590: -1727
Sample 1591: -1675
Sample 1592: -1631
Sample 1593: -1609
Sample 1594: -1604
Sample 1595: -1662
Sample 1596: -1704
Sample 1597: -1713
Sample 1598: -1723
Sample 1599: -1699
Sample 1568: -1776
--- 1568 messages dropped ---
Sample 1569: -1795
Sample 1570: -1772
Sample 1571: -1772
Sample 1572: -1821
Sample 1573: -1828
Sample 1574: -1748
Sample 1575: -1688
Sample 1576: -1690
Sample 1577: -1703
Sample 1578: -1695
Sample 1579: -1677
Sample 1580: -1675
Sample 1581: -1663
Sample 1582: -1637
Sample 1583: -1613
Sample 1584: -1601
Sample 1585: -1628
Sample 1586: -1658
Sample 1587: -1644
Sample 1588: -1647
Sample 1589: -1687
Sample 1590: -1701
Sample 1591: -1676
Sample 1592: -1675
Sample 1593: -1714
Sample 1594: -1724
Sample 1595: -1703
Sample 1596: -1717
Sample 1597: -1752
Sample 1598: -1771
Sample 1599: -1766
Sample 1568: -1763
--- 1568 messages dropped ---
Sample 1569: -1745
Sample 1570: -1728
Sample 1571: -1726
Sample 1572: -1732
Sample 1573: -1749
Sample 1574: -1769
Sample 1575: -1767&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;&amp;amp;pinctrl {
i2s0_default: i2s0_default {
group1 {
psels = &amp;lt;NRF_PSEL(I2S_SCK_M, 0, 26)&amp;gt;,
&amp;lt;NRF_PSEL(I2S_LRCK_M, 0, 25)&amp;gt;,
&amp;lt;NRF_PSEL(I2S_SDIN, 0, 7)&amp;gt;,
&amp;lt;NRF_PSEL(I2S_SDOUT, 0, 6)&amp;gt;;
};
};
i2s0_sleep: i2s0_sleep {
group1 {
psels = &amp;lt;NRF_PSEL(I2S_SCK_M, 0, 26)&amp;gt;,
&amp;lt;NRF_PSEL(I2S_LRCK_M, 0, 25)&amp;gt;,
&amp;lt;NRF_PSEL(I2S_SDIN, 0, 7)&amp;gt;,
&amp;lt;NRF_PSEL(I2S_SDOUT, 0, 6)&amp;gt;;
};
};
};

&amp;amp;clock {
status = &amp;quot;okay&amp;quot;;
hfclkaudio-frequency = &amp;lt;12288000&amp;gt;;
};


i2s_rxtx: &amp;amp;i2s0 {
status = &amp;quot;okay&amp;quot;;
pinctrl-0 = &amp;lt;&amp;amp;i2s0_default&amp;gt;;
pinctrl-1 = &amp;lt;&amp;amp;i2s0_sleep&amp;gt;;
clock-source = &amp;quot;ACLK&amp;quot;;
pinctrl-names = &amp;quot;default&amp;quot;,&amp;quot;sleep&amp;quot;;
};&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;Ok,In that case help me with getting data as I am not able to get mic data correctly.Here I am just reading and logging manually and&amp;nbsp;using that i iam converting to wav file externally to check audio.But using this I am not getting all data,some data is not printing and dont know it is correct data or not&lt;pre class="ui-code" data-mode="text"&gt;#include &amp;lt;zephyr/kernel.h&amp;gt;
#include &amp;lt;zephyr/sys/printk.h&amp;gt;
#include &amp;lt;zephyr/drivers/i2s.h&amp;gt;
#include &amp;lt;zephyr/drivers/gpio.h&amp;gt;
#include &amp;lt;string.h&amp;gt;
#include &amp;lt;zephyr/drivers/uart.h&amp;gt;

#define I2S_RX_NODE DT_NODELABEL(i2s_rxtx)

#define SAMPLE_FREQUENCY 16000
#define SAMPLE_BIT_WIDTH 32
#define BYTES_PER_SAMPLE sizeof(int16_t)
#define NUMBER_OF_CHANNELS 1
#define SAMPLES_PER_BLOCK ((SAMPLE_FREQUENCY / 10) * NUMBER_OF_CHANNELS)
#define INITIAL_BLOCKS 2
#define TIMEOUT 1000

#define BLOCK_SIZE (BYTES_PER_SAMPLE * SAMPLES_PER_BLOCK)
#define BLOCK_COUNT (INITIAL_BLOCKS + 2)
K_MEM_SLAB_DEFINE_STATIC(mem_slab, BLOCK_SIZE, BLOCK_COUNT, 4);

const struct device *const i2s_dev_rx = DEVICE_DT_GET(I2S_RX_NODE);
struct i2s_config config;

static int16_t echo_block[SAMPLES_PER_BLOCK];
uint8_t loopCnt = 0;

static void process_block_data(void *mem_block, uint32_t number_of_samples)
{
	for (int i = 0; i &amp;lt; number_of_samples; ++i)
	{
		int16_t *sample = &amp;amp;((int16_t *)mem_block)[i];
		echo_block[i] = *sample;
	  }
	 
}

static bool configure_streams(const struct device *i2s_dev_rx, const struct i2s_config *config)
{
	int ret = i2s_configure(i2s_dev_rx, I2S_DIR_RX, config);
	if (ret == 0)
	{
		printk(&amp;quot;Configure Stream Successful.\n&amp;quot;);
		return true;
	}
	printk(&amp;quot;Failed to configure streams: %d\n&amp;quot;, ret);
	return false;
}

static bool trigger_command(const struct device *i2s_dev_rx, enum i2s_trigger_cmd cmd)
{
	int ret = i2s_trigger(i2s_dev_rx, I2S_DIR_RX, cmd);
	if (ret == 0)
	{
		printk(&amp;quot;Trigger Command Successful.\n&amp;quot;);
		return true;
	}
	printk(&amp;quot;Failed to trigger command %d: %d\n&amp;quot;, cmd, ret);
	return false;
}

static void i2sStreamInit(void){

	printk(&amp;quot;I2S echo sample\n&amp;quot;);

	if (!device_is_ready(i2s_dev_rx))
	{
		printk(&amp;quot;%s is not ready\n&amp;quot;, i2s_dev_rx-&amp;gt;name);
		return 0;
	}

	config.word_size = SAMPLE_BIT_WIDTH;
	config.channels = NUMBER_OF_CHANNELS;
	config.format = I2S_FMT_DATA_FORMAT_I2S;
	config.options = I2S_OPT_BIT_CLK_MASTER | I2S_OPT_FRAME_CLK_MASTER;
	config.frame_clk_freq = SAMPLE_FREQUENCY;
	config.mem_slab = &amp;amp;mem_slab;
	config.block_size = BLOCK_SIZE;
	config.timeout = TIMEOUT;

	if (!configure_streams(i2s_dev_rx, &amp;amp;config))
	{
		return 0;
	}

	if (!trigger_command(i2s_dev_rx, I2S_TRIGGER_START))
	{
		return 0;
	}
}



int main(void)
{
	i2sStreamInit();
	printk(&amp;quot;Streams started\n&amp;quot;);

	while (1)
	{
		void *mem_block;
		uint32_t block_size;
		int ret;

		ret = i2s_read(i2s_dev_rx, &amp;amp;mem_block, &amp;amp;block_size);
		if (ret &amp;lt; 0)
		{
			printk(&amp;quot;Failed to read data: %d\n&amp;quot;, ret);
			break;
		}

		process_block_data(mem_block, SAMPLES_PER_BLOCK);
		k_mem_slab_free(&amp;amp;mem_slab, mem_block);

	}
	printk(&amp;quot;Exiting main loop\n&amp;quot;);
	return 0;
}&lt;/pre&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: SPH0645 I2S MIC DATA FORMAT</title><link>https://devzone.nordicsemi.com/thread/507108?ContentTypeID=1</link><pubDate>Mon, 21 Oct 2024 10:34:54 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:f120ebe7-f4bf-47d8-bf41-daf28b2ad9cc</guid><dc:creator>Elfving</dc:creator><description>[quote user="Kashyap23"]Can I use directly what I get without converting 2&amp;#39;s complement value?[/quote]
&lt;p&gt;That&amp;nbsp;should be fine, 2&amp;#39;s complement is normal.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Regards,&lt;/p&gt;
&lt;p&gt;Elfving&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: SPH0645 I2S MIC DATA FORMAT</title><link>https://devzone.nordicsemi.com/thread/506593?ContentTypeID=1</link><pubDate>Thu, 17 Oct 2024 03:09:14 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:d63d36da-dcca-4858-851c-d215e47ed86b</guid><dc:creator>Kashyap23</dc:creator><description>[quote userid="134881" url="~/f/nordic-q-a/115390/sph0645-i2s-mic-data-format"]data of 2&amp;#39;s complement value in order to get original mic data or it will be internally converted by the nrf5340 controller[/quote]
&lt;p&gt;Ok,thank&amp;#39;s for that .I have doubt regard data ,I am trying to print data and convert to wav file,in this case do i need any conversion of 2&amp;#39;s complement value to get original audio or this wont be necessary thing.Can I use directly what I get without converting 2&amp;#39;s complement value?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: SPH0645 I2S MIC DATA FORMAT</title><link>https://devzone.nordicsemi.com/thread/506553?ContentTypeID=1</link><pubDate>Wed, 16 Oct 2024 14:15:55 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:a4c16da5-c873-48ba-b549-e19425cc8080</guid><dc:creator>Elfving</dc:creator><description>&lt;p&gt;Understood.&lt;/p&gt;
[quote user=""]The Data Format is I2S, 24-bit, 2’s compliment, MSB first. The data precision is 18 bits; unused bits are zeros&amp;quot;.[/quote]
&lt;p&gt;The data looks fine. The i2s should support all of that, and 24-bits.&amp;nbsp;If you want to use LE Audio however, I believe that the LC3 codec only uses 16 bits at the moment, but that is not a real problem.&lt;/p&gt;
&lt;p&gt;For more on i2s on the 5340, &lt;a href="https://docs.nordicsemi.com/bundle/ps_nrf5340/page/i2s.html#ariaid-title1"&gt;see here&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;Regards,&lt;/p&gt;
&lt;p&gt;Elfving&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: SPH0645 I2S MIC DATA FORMAT</title><link>https://devzone.nordicsemi.com/thread/506218?ContentTypeID=1</link><pubDate>Tue, 15 Oct 2024 06:04:35 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:59fdc5f1-4905-49d0-a8e9-ab359c1bb95a</guid><dc:creator>Kashyap23</dc:creator><description>&lt;p&gt;That&amp;#39;s related to a different thing but here it&amp;#39;s regarding the data format .I want to know how data is available using nrf5340.Can we use data directly?or we need to conert back from 2&amp;#39;s complement.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: SPH0645 I2S MIC DATA FORMAT</title><link>https://devzone.nordicsemi.com/thread/505883?ContentTypeID=1</link><pubDate>Fri, 11 Oct 2024 12:35:15 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:e3c92e2d-c378-4210-a59f-d5dd07d4f8c1</guid><dc:creator>Elfving</dc:creator><description>&lt;p&gt;Hello&amp;nbsp;Kashyap,&lt;/p&gt;
&lt;p&gt;I see that the last case you&amp;#39;ve opened was a bit similar to this one, and it was recently answered as well. I assume this is somewhat of a duplicate then.&lt;/p&gt;
&lt;p&gt;Regards,&lt;/p&gt;
&lt;p&gt;Elfving&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>