<?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>Data shifting I2S</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/116199/data-shifting-i2s</link><description>Hi,I have been using NRF5340 Audio DK and I able to get data using SPH0645 using i2s_read function and able to transmit data to amplifier TAS2562 using i2s_write function .But the issue is I am reading a data of 32 bit of each sample ,need to right shift</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Wed, 27 Nov 2024 14:32:13 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/116199/data-shifting-i2s" /><item><title>RE: Data shifting I2S</title><link>https://devzone.nordicsemi.com/thread/512399?ContentTypeID=1</link><pubDate>Wed, 27 Nov 2024 14:32:13 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:d6d95dec-60b6-46d5-9a9c-243905f365f2</guid><dc:creator>Edvin</dc:creator><description>&lt;p&gt;There are some special components that are placed on the nRF53 Audio DK that are not present on the nRF54L15 DK (also not present on the nRF5340 DK). Also the sample application is not ported to the nRF54, so the short answer is no. Not at this point in time.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;I think there is planned to support it in the future, but I don&amp;#39;t know&amp;nbsp;when that will come. Also, the lack of the AudioPLL on the nRF54L may cause the I2S Sampling clock to drift, which may or may not be an issue in your case, depending on the application (particularly the length of your samples).&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Best regards,&lt;/p&gt;
&lt;p&gt;Edvin&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Data shifting I2S</title><link>https://devzone.nordicsemi.com/thread/511592?ContentTypeID=1</link><pubDate>Fri, 22 Nov 2024 05:11:24 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:fe61db99-0cc8-4da0-bb7a-4040b5567c53</guid><dc:creator>Kashyap23</dc:creator><description>&lt;p&gt;Hi Edvin ,we have received samples of nrf54L15 series evm ,will this audio sample with lc3 codec woks here also?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Data shifting I2S</title><link>https://devzone.nordicsemi.com/thread/510536?ContentTypeID=1</link><pubDate>Thu, 14 Nov 2024 15:02:18 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:49d33427-cb41-41de-b63b-86d300cebaed</guid><dc:creator>Edvin</dc:creator><description>&lt;p&gt;I suggest that you study the sample application, NCS\nrf\applications\nrf5340_audio, as this is a complex subject. Also see the &lt;a href="https://docs.nordicsemi.com/bundle/ncs-latest/page/nrf/applications/nrf5340_audio/doc/firmware_architecture.html"&gt;documentation for this application&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;It is not standard BLE, but BLE Audio, which is fairly new. The LC3 codec is automatically used, unless you specify something else.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Regarding the delay, I don&amp;#39;t know any way to do this more efficiently, if it is a possibility to use another sample bit width than 18, or a different microphone.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Best regards,&lt;/p&gt;
&lt;p&gt;Edvin&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Data shifting I2S</title><link>https://devzone.nordicsemi.com/thread/510429?ContentTypeID=1</link><pubDate>Thu, 14 Nov 2024 09:30:17 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:ca31e7e9-dde0-4f5b-a502-f76fa60acacf</guid><dc:creator>Kashyap23</dc:creator><description>&lt;p&gt;Thanks for that Edvin,this definitely helps and works for me but I have tried with i2s_buff_r/w function which solved my issue in shifting and writing to i2s_buff_write with a minimal delay I can able to listen audio&amp;nbsp; in Amplifier .Can this delay be reduced ?if yes ,suggest me the way and now I need to transfer shifted data over BLE.In order to achieve that ,guide me the way.My sampling rate is 16000.I saw the audio sample is incorporated with LC3 codec but not understanding to achieve blewith my audio data.&lt;/p&gt;
&lt;p&gt;Thanks&lt;/p&gt;
&lt;p&gt;Kashyap&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Data shifting I2S</title><link>https://devzone.nordicsemi.com/thread/510328?ContentTypeID=1</link><pubDate>Wed, 13 Nov 2024 14:29:09 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:346bbe27-244f-431b-ad16-4987c026fa96</guid><dc:creator>Edvin</dc:creator><description>&lt;p&gt;These pointer bit-handling is always a bit tricky. Particularly with void * buffers. I added this to one of our samples (I used the central_uart from ncs\nrf\samples\bluetooth\central_uart, since I recently used it for something else). I added these functions, and called it from the start of main:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;void print_blob(int *int_blob, int16_t num_elements)
{
    for (int i=0; i&amp;lt;num_elements; i++) {
        LOG_INF(&amp;quot;blob [%d] = 0x%08x&amp;quot;, i, int_blob[i]);
    }
}

void process_blob(void *blob, int16_t num_elements)
{
    uint32_t *int_blob = blob;
    for (int i=0; i&amp;lt;num_elements;i++){
        int_blob[i] = int_blob[i]&amp;gt;&amp;gt;16;
    }
}

void test_function(void)
{
    LOG_INF(&amp;quot;test_blob&amp;quot;);
    void *blob;
    blob = k_malloc(3*sizeof(uint32_t));
    if (blob) {
        uint32_t *int_blob = (uint32_t*)blob;
        LOG_INF(&amp;quot;k_malloc success&amp;quot;);
        int_blob[0] = 0x11111111;
        int_blob[1] = 0xFFFFFFFF;
        int_blob[2] = 0x0000FFFF;
        LOG_INF(&amp;quot;pre processing********&amp;quot;);
        print_blob(blob, 3);
        process_blob(blob,3);
        LOG_INF(&amp;quot;post processing*******&amp;quot;);
        print_blob(blob, 3);

        //blob = int_blob;
        LOG_INF(&amp;quot;blob = %p&amp;quot;, blob);
        LOG_INF(&amp;quot;int_blob = %p&amp;quot;, int_blob);
    } 
    else {
        LOG_ERR(&amp;quot;k_malloc fail&amp;quot;);
    }
    
}

int main(void)
{
    test_function();
&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;Note that I casted the pointer to a uint32_t pointer before doing modifications to it. As long as it is a pointer that is set to the same address, the content of my &amp;quot;blob&amp;quot; void pointer is also changed.&lt;/p&gt;
&lt;p&gt;This produced the following log:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;[00:00:00.000,640] &amp;lt;inf&amp;gt; central_uart: test_blob
[00:00:00.000,701] &amp;lt;inf&amp;gt; central_uart: k_malloc success
[00:00:00.000,701] &amp;lt;inf&amp;gt; central_uart: pre processing********
[00:00:00.000,732] &amp;lt;inf&amp;gt; central_uart: blob [0] = 0x11111111
[00:00:00.000,732] &amp;lt;inf&amp;gt; central_uart: blob [1] = 0xffffffff
[00:00:00.000,762] &amp;lt;inf&amp;gt; central_uart: blob [2] = 0x0000ffff
[00:00:00.000,762] &amp;lt;inf&amp;gt; central_uart: post processing*******
[00:00:00.000,793] &amp;lt;inf&amp;gt; central_uart: blob [0] = 0x00001111
[00:00:00.000,793] &amp;lt;inf&amp;gt; central_uart: blob [1] = 0x0000ffff
[00:00:00.000,793] &amp;lt;inf&amp;gt; central_uart: blob [2] = 0x00000000
[00:00:00.000,823] &amp;lt;inf&amp;gt; central_uart: blob = 0x20008f48
[00:00:00.000,915] &amp;lt;wrn&amp;gt; cbprintf_package: (unsigned) char * used for %p argument. It&amp;#39;s recommended to cast it to void * because it may cause misbehavior in certain configurations. String:&amp;quot;int_blob = %p&amp;quot; argument:0
[00:00:00.000,915] &amp;lt;inf&amp;gt; central_uart: int_blob = 0x20008f48
&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;Try something similar for your processing function.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Best regards,&lt;/p&gt;
&lt;p&gt;Edvin&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Data shifting I2S</title><link>https://devzone.nordicsemi.com/thread/510018?ContentTypeID=1</link><pubDate>Tue, 12 Nov 2024 06:39:48 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:3e2ea08a-398f-4799-afc5-0e9e177fec53</guid><dc:creator>Kashyap23</dc:creator><description>&lt;p&gt;Data will be in 18 MSB,so I am shifting 16 bits to get 16 bit of each mic sample&lt;/p&gt;
[quote userid="26071" url="~/f/nordic-q-a/116199/data-shifting-i2s/509905"] Does it work? What do you see?[/quote]
&lt;p&gt;Data is not shifting .How can I achieve and pass to amplifier of only one mic data of 16000 samples(I will use second mic data for ANC )So I need output of only one mic .How can I do that&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Data shifting I2S</title><link>https://devzone.nordicsemi.com/thread/509905?ContentTypeID=1</link><pubDate>Mon, 11 Nov 2024 13:48:49 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:b3440a8c-cac8-42dc-a201-2c7c610f40af</guid><dc:creator>Edvin</dc:creator><description>&lt;p&gt;You say that your bitlength is 18 bit. What does it look like when it enters the application?&amp;nbsp;&lt;/p&gt;
&lt;p&gt;I see that you are doing some bit shifting in your handler. Does it work? What do you see? And in each of your samples (32bit, I guess). Where is the data? Is it occupying the 18 least significant bits (lower bits), or the 18 most significant bits(upper bits)?&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Best regards,&lt;/p&gt;
&lt;p&gt;Edvin&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Data shifting I2S</title><link>https://devzone.nordicsemi.com/thread/509834?ContentTypeID=1</link><pubDate>Mon, 11 Nov 2024 09:44:21 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:97a2160c-ec72-4a60-b405-5c82717fee03</guid><dc:creator>Kashyap23</dc:creator><description>&lt;p&gt;In addition that I want to know that can we use i2s_read for getting data and loading into buffer and doing shifting then use&amp;nbsp; i2s_buf_write for sending data out?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>