<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="https://devzone.nordicsemi.com/cfs-file/__key/system/syndication/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>I2S peripheral&amp;#39;s decoding of 32 bit data in slave mode</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/65395/i2s-peripheral-s-decoding-of-32-bit-data-in-slave-mode</link><description>I&amp;#39;m using a nRF52480 DK board with an adafruit 3421 I2S microphone breakout board attached. I am on Ubuntu 20.04 with SES 5.42c and SDK 16. 
 I am using a variant of the usbd_cdc_acm example along with a Python3 script that provides communication with</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Thu, 03 Sep 2020 13:11:56 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/65395/i2s-peripheral-s-decoding-of-32-bit-data-in-slave-mode" /><item><title>RE: I2S peripheral's decoding of 32 bit data in slave mode</title><link>https://devzone.nordicsemi.com/thread/267853?ContentTypeID=1</link><pubDate>Thu, 03 Sep 2020 13:11:56 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:53125efe-468d-4372-acbb-13cacb3c81e4</guid><dc:creator>matty</dc:creator><description>&lt;p&gt;Thank you.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: I2S peripheral's decoding of 32 bit data in slave mode</title><link>https://devzone.nordicsemi.com/thread/267791?ContentTypeID=1</link><pubDate>Thu, 03 Sep 2020 09:56:09 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:c002f228-5912-42c7-8a8f-28d53e29e3bc</guid><dc:creator>H&amp;#229;kon Alseth</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;There is a indication that something is wrong, as there is a difference between what Salaea detects (although I do not know your i2s parser settings there) and what your graph on the PC side shows. I do not have this sensor, so I cannot reproduce your findings, or validate your algorithm.&lt;/p&gt;
&lt;p&gt;I would recommend that you add debug prints on both sides, to see how the raw data is presented and interpreted.&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Kind regards,&lt;/p&gt;
&lt;p&gt;Håkon&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: I2S peripheral's decoding of 32 bit data in slave mode</title><link>https://devzone.nordicsemi.com/thread/267712?ContentTypeID=1</link><pubDate>Thu, 03 Sep 2020 00:54:12 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:2e610b75-e1fc-44f1-abc4-e4e5e2382e4f</guid><dc:creator>matty</dc:creator><description>&lt;p&gt;Hello,&lt;/p&gt;
&lt;p&gt;I tried to explain my handling of the I2S peripheral&amp;#39;s data in the 80 lines of code at the beginning of the question. That code is commented step by step and try&amp;#39;s to explain my reasoning and methods. For&amp;nbsp;that code,&amp;nbsp;the high ordered bits are always the the left most so in a uint32_t, bit 31 is the leftmost bit and the Most Significant Bit while bit 0 is the right most bit and the Least Significant Bit. I would greatly appreciate it if you could look at that commented code and tell me if my reasoning is correct. Particularly in regards to the questions I asked since they&amp;#39;&amp;nbsp;originate in that code. I appreciate your help. Thank you.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: I2S peripheral's decoding of 32 bit data in slave mode</title><link>https://devzone.nordicsemi.com/thread/267621?ContentTypeID=1</link><pubDate>Wed, 02 Sep 2020 12:09:00 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:c7fafea5-a6b1-41db-8c2b-18f2dd7fa03f</guid><dc:creator>H&amp;#229;kon Alseth</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Good that you&amp;#39;re using the HFCLK now, I feared that it wouldn&amp;#39;t help the scenario this much however.. Normally you&amp;#39;d see approx. 1-5 % variance with the RC oscillator, where as your frequency deviation is ~20-30 %.&lt;/p&gt;
&lt;p&gt;If you take this screenshot:&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
[quote user="matty"]&lt;p&gt;&lt;/p&gt;&lt;p&gt;Here is a logic analyzer screen shot:&lt;/p&gt;&lt;p&gt;&lt;img src="https://devzone.nordicsemi.com/resized-image/__size/320x240/__key/communityserver-discussions-components-files/4/hfclkstart1.png" alt=" " style="cursor:zoom-in;" /&gt;&lt;/p&gt;&lt;p&gt;&lt;/p&gt;[/quote]
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Since this bit stream is 2&amp;#39;s compliment, salaea detects this as -31660. The range that you are plotting doesn&amp;#39;t seem to touch into this value. How are you handling this on the PC side?&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Kind regards,&lt;/p&gt;
&lt;p&gt;Håkon&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: I2S peripheral's decoding of 32 bit data in slave mode</title><link>https://devzone.nordicsemi.com/thread/267305?ContentTypeID=1</link><pubDate>Mon, 31 Aug 2020 17:08:14 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:803cda79-99c0-48b4-9af8-ca0fcaa63112</guid><dc:creator>matty</dc:creator><description>&lt;p&gt;I&amp;nbsp;put my timer initialization back the way it was and added the NRF_CLOCK calls so everything looks like:&lt;/p&gt;
&lt;p&gt;ret = nrf_drv_clock_init();&lt;br /&gt; APP_ERROR_CHECK(ret);&lt;/p&gt;
&lt;p&gt;nrf_drv_clock_lfclk_request(NULL);&lt;br /&gt; while(!nrf_drv_clock_lfclk_is_running())&lt;br /&gt; {&lt;br /&gt; /* Just waiting */&lt;br /&gt; }&lt;/p&gt;
&lt;p&gt;NRF_CLOCK-&amp;gt;TASKS_HFCLKSTART = 1;&lt;br /&gt; while(!NRF_CLOCK-&amp;gt;EVENTS_HFCLKSTARTED)&lt;br /&gt; {&lt;br /&gt; /* Just waiting */&lt;br /&gt; }&lt;/p&gt;
&lt;p&gt;Here is a logic analyzer screen shot:&lt;/p&gt;
&lt;p&gt;&lt;img src="https://devzone.nordicsemi.com/resized-image/__size/320x240/__key/communityserver-discussions-components-files/4/hfclkstart1.png" alt=" " /&gt;&lt;/p&gt;
&lt;p&gt;Here is&lt;span&gt;&amp;nbsp;a matplotlib.pyplot.plot of&amp;nbsp;224 of the I2S peripheral&amp;#39;s output values of the phone&amp;#39;s signal.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;img src="https://devzone.nordicsemi.com/resized-image/__size/320x240/__key/communityserver-discussions-components-files/4/raw_5F00_i2s_5F00_data_5F00_hfclkstart1.png" alt=" " /&gt;&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: I2S peripheral's decoding of 32 bit data in slave mode</title><link>https://devzone.nordicsemi.com/thread/267297?ContentTypeID=1</link><pubDate>Mon, 31 Aug 2020 16:27:44 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:e4991716-cfb4-4b90-bc70-7ced891ec69f</guid><dc:creator>matty</dc:creator><description>&lt;p&gt;I am making the following timer calls in main&amp;#39;s initialization sequence:&lt;/p&gt;
&lt;p&gt;ret = nrf_drv_clock_init();&lt;br /&gt; APP_ERROR_CHECK(ret);&lt;br /&gt; nrf_drv_clock_lfclk_request(NULL);&lt;br /&gt; while(!nrf_drv_clock_lfclk_is_running())&lt;br /&gt; {&lt;br /&gt; /* Just waiting */&lt;br /&gt; }&lt;/p&gt;
&lt;p&gt;I&amp;#39;m guessing that a call to&amp;nbsp;nrf_drv_clock_hfclk_request(NULL) would be the same as&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;NRF_CLOCK-&amp;gt;TASKS_HFCLKSTART = 1;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Can I replace&amp;nbsp;nrf_drv_clock_lfclk_request(NULL); with&amp;nbsp;nrf_drv_clock_hfclk_request(NULL); and&amp;nbsp;nrf_drv_clock_lfclk_is_running() with&amp;nbsp;nrf_drv_clock_hfclk_is_running() ? Will I get the same timer functionality throughout the rest of the program?&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;I&amp;#39;ve done that and it has broken something in my communications which is annoying but here&amp;nbsp;is&amp;nbsp;a screen shot from the logic analyzer when I use&amp;nbsp;nrf_drv_clock_hfclk_request(NULL);&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&amp;nbsp;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;img src="https://devzone.nordicsemi.com/resized-image/__size/320x240/__key/communityserver-discussions-components-files/4/highfreq_5F00_clock1.png" alt=" " /&gt;&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: I2S peripheral's decoding of 32 bit data in slave mode</title><link>https://devzone.nordicsemi.com/thread/267278?ContentTypeID=1</link><pubDate>Mon, 31 Aug 2020 14:01:57 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:d72b1f98-3b6f-484c-a4cb-69a8bfa95461</guid><dc:creator>H&amp;#229;kon Alseth</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Thanks for posting the pictures.&lt;/p&gt;
&lt;p&gt;Amplitude is a bit low, but that might be &amp;quot;low volume&amp;quot; on the source. Approx. 100 samples for one period (31,25k / num_of_samples) = ~312 Hz, which is ~25% off.&lt;/p&gt;
&lt;p&gt;The WS signal looks to be approx. 16.5 us, which gives a period of 2*16.5 = 33 us -&amp;gt; ~30 kHz.&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;The timing here is a bit off. Can you confirm if you&amp;#39;re using the HFCLK or not?&lt;/p&gt;
&lt;p&gt;Again; it is _very important_ that you run using the external HFCLK when testing I2S. The internal 64 MHz RC oscillator can be quite inaccurate..&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Kind regards,&lt;/p&gt;
&lt;p&gt;Håkon&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: I2S peripheral's decoding of 32 bit data in slave mode</title><link>https://devzone.nordicsemi.com/thread/267265?ContentTypeID=1</link><pubDate>Mon, 31 Aug 2020 13:30:13 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:29031602-4c88-45a5-b817-c20c8e4e1ea2</guid><dc:creator>matty</dc:creator><description>&lt;p&gt;I will try re-posting the pictures here.&lt;/p&gt;
&lt;p&gt;&lt;span&gt;One of the following screen shots is of the low LRCK with SCK and DOUT, (top channel is SCK, next is DOUT, and bottom is LRCK). The other screen shot is a zoom of the same.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;img src="https://devzone.nordicsemi.com/resized-image/__size/320x240/__key/communityserver-discussions-components-files/4/i2s_5F00_sck_5F00_data_5F00_lrck_5F00_one_5F00_whole_5F00_left.png" alt=" " /&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;&lt;img src="https://devzone.nordicsemi.com/resized-image/__size/320x240/__key/communityserver-discussions-components-files/4/i2s_5F00_sck_5F00_data_5F00_lrck_5F00_zoom_5F00_in_5F00_left.png" alt=" " /&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;The following screen shot is a matplotlib.pyplot.plot of&amp;nbsp;224 of the I2S peripheral&amp;#39;s output values of the phone&amp;#39;s signal.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;img src="https://devzone.nordicsemi.com/resized-image/__size/320x240/__key/communityserver-discussions-components-files/4/raw_5F00_i2s_5F00_data.png" alt=" " /&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Thank you for your response. I&amp;#39;m still reading it. Let me know if I can provide anything else.&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: I2S peripheral's decoding of 32 bit data in slave mode</title><link>https://devzone.nordicsemi.com/thread/267262?ContentTypeID=1</link><pubDate>Mon, 31 Aug 2020 13:21:37 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:a430fb29-5003-405e-bb8a-2c9bc59677e7</guid><dc:creator>H&amp;#229;kon Alseth</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;The pictures seems to be missing in your post. Could you re-upload them, so I can see how things are looking?&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Based on the sensor, it looks like it assumes &amp;quot;i2s left-justified&amp;quot; data format, and you&amp;#39;re using the firmware &amp;quot;algorithm&amp;quot; to emulate support for 32 bit frames in I2S (on nRF52-series devices) from this post?&lt;/p&gt;
&lt;p&gt;&lt;a href="https://devzone.nordicsemi.com/f/nordic-q-a/15713/i2s-32-bit-word-size/59992#59992"&gt;https://devzone.nordicsemi.com/f/nordic-q-a/15713/i2s-32-bit-word-size/59992#59992&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Note that the above linked project,&amp;nbsp;&lt;a href="https://github.com/gregtomasch/nRF52_24-bit-_I2S_Microphone_Audio_Recording_Utility"&gt;https://github.com/gregtomasch/nRF52_24-bit-_I2S_Microphone_Audio_Recording_Utility&lt;/a&gt;, isn&amp;#39;t made by nordic, and I haven&amp;#39;t tried it myself.&amp;nbsp;&amp;nbsp;&lt;/p&gt;
[quote user=""]Question 1:&amp;nbsp;From the documentation,&amp;nbsp;The EasyDMA &amp;quot;...32-bit memory word can&amp;nbsp;... contain&amp;nbsp;one right-aligned 24-bit sample sign extended to 32 bit.&amp;quot; Does sign extended mean that the 23rd bit is repeated 8 times in bits 24 through 31? If the Knowles microphone produces a 24 bit value whose&amp;nbsp;MSB is one, (indicating a negative value), are bits 24 through 31 assigned a value of one? The reason i&amp;#39;m asking is that every negative I2S peripheral value has ff in the most significant 8 bits.[/quote]
&lt;p&gt;&amp;nbsp;Based on the datasheet:&amp;nbsp;&lt;a href="https://media.digikey.com/pdf/Data%20Sheets/Knowles%20Acoustics%20PDFs/SPH0645LM4H-B.pdf"&gt;https://media.digikey.com/pdf/Data%20Sheets/Knowles%20Acoustics%20PDFs/SPH0645LM4H-B.pdf&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;It looks like it tristates the lines after the 24th bit, and keeps 19 to 23 as &amp;#39;0&amp;#39;, but I might be misinterpreting things here.&lt;/p&gt;
[quote user=""]Question 2:&amp;nbsp;Am I right that the I2S peripheral&amp;#39;s value has the microphone&amp;#39;s value in bits 23 down to bit 0? Where bit 23 is the MSB and bit 0 is LSB?[/quote]
&lt;p&gt;Left-justified format. First bit is MSB.&lt;/p&gt;
&lt;p&gt;We might be talking &amp;quot;around each other&amp;quot; - Depends on which way you read (left to right, right to left).&lt;/p&gt;
[quote user=""]Question 3: Is this 24 bit thing the same as the 24 bit value that the Knowles microphone is providing or is it a &amp;quot;translation&amp;quot; of some sort, (as with a PDM microphone)? If it is a &amp;quot;translation&amp;quot; are all 24 bits used and what do they represent?[/quote]
&lt;p&gt;Note, this is left-aligned format, as an example shown in figure 5 in the nRF52832 PS:&lt;/p&gt;
&lt;p&gt;&lt;a href="https://infocenter.nordicsemi.com/topic/com.nordic.infocenter.nrf52832.ps.v1.1/i2s.html?cp=4_2_0_43_5#concept_vz5_fty_vr"&gt;https://infocenter.nordicsemi.com/topic/com.nordic.infocenter.nrf52832.ps.v1.1/i2s.html?cp=4_2_0_43_5#concept_vz5_fty_vr&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
[quote user=""]Question 4: If the I2S peripheral&amp;#39;s bit 0 through 23 is the same as the Knowles microphones&amp;#39;s 24 bit value, then bits 0 through 5 are the zero padding mentioned in the Knowles data sheet and can be discarded?&amp;nbsp;[/quote]
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
[quote user=""]Question 5: Could I have a syncing problem between my SCK and LRCK? Is it correct to think that as long as LRCK is low and low long enough to accommodate 32 SCK pulses, the microphone will transmit all of it&amp;#39;s data? You&amp;#39;ll notice in my initialization of the LRCK PWM, I lengthen the duty cycle by one. So the LRCK&amp;#39;s duty cycle is 51%. I did this because the tracings showed some LRCK low periods were questionably encompassing 32 separate SCK pulses on a 50% duty cycle.I thought this 51% duty cycle would be acceptable since I am mono and configure the I2S peripheral as just left channel. My thinking is that since the I2S peripheral is ignoring the right channel, the length of time that LRCK is highr can be a bit shorter. As far as I can make out the microphone doesn&amp;#39;t even respond to LRCK high when SEL is grounded. I&amp;#39;m thinking that while the microphone may not mind, the Nordic I2S peripheral is adversely effected[/quote]
&lt;p&gt;Yes, you need the SCK and L/RCK to be aligned. Our serial modules try to sample &amp;quot;in between&amp;quot; a clock cycle, in case of lagging in the signal path, but if you have a 4MHz input signal, that&amp;#39;s a maximum of 125 ns (minus SETUP time, 40 ns -&amp;gt; 125-40 = 85ns) delay.&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Are you starting the HFCLK? If not, you&amp;#39;re running on internal RC oscillator, which has a tolerance in the percentage area.&lt;/p&gt;
&lt;p&gt;Try calling &amp;quot;NRF_CLOCK-&amp;gt;TASKS_HFCLKSTART = 1;&amp;quot;, then wait for the NRF_CLOCK-&amp;gt;EVENTS_HFCLKSTARTED.&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Kind regards,&lt;/p&gt;
&lt;p&gt;Håkon&lt;/p&gt;
&lt;p&gt;Do you have some logic analyzer traces I can look at? I&amp;#39;m not sure I&amp;nbsp;fully understand the setup.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: I2S peripheral's decoding of 32 bit data in slave mode</title><link>https://devzone.nordicsemi.com/thread/267224?ContentTypeID=1</link><pubDate>Mon, 31 Aug 2020 11:59:26 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:b34ab8db-d399-4e18-85af-8b2fc659458f</guid><dc:creator>matty</dc:creator><description>&lt;p&gt;I forgot to supply the Knowles Microphone model. The Microphone is the Knowles SPH0645LM4H.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>