<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Understanding I2S SDK example in MCUXpresso SDK</title>
    <link>https://community.nxp.com/t5/MCUXpresso-SDK/Understanding-I2S-SDK-example/m-p/976763#M1902</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi, Rory,&lt;/P&gt;&lt;P&gt;I suppose that you use the ..._i2s_interrupt_transfer example to have a test, for the example, I think this is the the architecture of the example.&lt;/P&gt;&lt;P&gt;First of all, a handler is declared as static i2s_handle_t s_TxHandle; for i2s transmitter, the s_TxHandle-&amp;gt;i2sQueue[handle-&amp;gt;queueDriver] is a component with structure i2s_transfer_t, it contains the sample pointer and data size.&lt;/P&gt;&lt;P&gt;The example use interrupt mechanism to transfer sample to I2S transmitter FIFO, so in the ISR void I2S_TxHandleIRQ(I2S_Type *base, i2s_handle_t *handle) is called. NOTE the I2S_TxHandleIRQ() not exact ISR, it is&amp;nbsp; called by real ISR of FC7. when a bunch of&amp;nbsp; data defined in the s_TxHandle-&amp;gt;i2sQueue[handle-&amp;gt;queueDriver]&amp;nbsp; is completed, the callback function&amp;nbsp; static void TxCallback(I2S_Type *base, i2s_handle_t *handle, status_t completionStatus, void *userData) is called.&amp;nbsp; in the TxCallback() function, you need fill NEW data, the NEW data will update the s_TxHandle-&amp;gt;i2sQueue[handle-&amp;gt;queueDriver] structure.&lt;/P&gt;&lt;P&gt;In conclusion, you are required to just write the callback function TxCallback(), it is okay.&lt;/P&gt;&lt;P&gt;For your application, this is the pseudo code:&lt;/P&gt;&lt;P&gt;assume the data size is 100&lt;/P&gt;&lt;P&gt;uint8_t sample[100]&lt;/P&gt;&lt;P&gt;uint32_t data_size=100;&lt;/P&gt;&lt;P&gt;static void TxCallback(I2S_Type *base, i2s_handle_t *handle, status_t completionStatus, void *userData)&lt;BR /&gt;{&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; //read data from file&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; read(filePointer, &amp;amp;sample[0],data_size);&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; /* Enqueue the same original s_Buffer all over again */&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; i2s_transfer_t *transfer;&lt;/P&gt;&lt;P&gt;transfer-&amp;gt;data=sample&lt;/P&gt;&lt;P&gt;transfer-&amp;gt;dataSize=100;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; I2S_TxTransferNonBlocking(base, handle, *transfer);&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;Hope it can help you&lt;/P&gt;&lt;P&gt;BR&lt;/P&gt;&lt;P&gt;XiangJun Rong&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 06 Feb 2020 09:13:23 GMT</pubDate>
    <dc:creator>xiangjun_rong</dc:creator>
    <dc:date>2020-02-06T09:13:23Z</dc:date>
    <item>
      <title>Understanding I2S SDK example</title>
      <link>https://community.nxp.com/t5/MCUXpresso-SDK/Understanding-I2S-SDK-example/m-p/976762#M1901</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I do not understand properly how to actually use the I2S example provided with the SDK for the LPC55S69 EVK board.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Once an I2S transfer has occurred, the function TxCallback is called.&amp;nbsp; In the example software, within TxCallback, the following code is called:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P class=""&gt;&lt;SPAN class=""&gt;&amp;nbsp; &amp;nbsp; &lt;/SPAN&gt;&lt;SPAN class=""&gt;i2s_transfer_t&lt;/SPAN&gt; *transfer = (&lt;SPAN class=""&gt;i2s_transfer_t&lt;/SPAN&gt; *)userData;&lt;/P&gt;&lt;P class=""&gt;&lt;SPAN class=""&gt;&amp;nbsp; &amp;nbsp; &lt;/SPAN&gt;I2S_TxTransferNonBlocking(base, handle, *transfer);&lt;/P&gt;&lt;P class=""&gt;&lt;/P&gt;&lt;P class=""&gt;Stepping through from this point in the debugger then brings us to&amp;nbsp;&lt;/P&gt;&lt;P class=""&gt;&lt;STRONG&gt;I2S_TxHandleIRQ()&amp;nbsp;&lt;/STRONG&gt;within fsl_i2s.c.&amp;nbsp; We do not come back into TxCallback until a transfer has completed, and we do not exit I2S_TxHandleIRQ() until this point either.&lt;/P&gt;&lt;P class=""&gt;&lt;/P&gt;&lt;P class=""&gt;My question is - where am I supposed to do other processing?&amp;nbsp; Since I am attempting to read data bytes from an SD card, and then send these to I2S sample by sample via arrays, (in a custom ping-pong style arrangement), I do not understand whereabouts I am meant to perform these reads.&amp;nbsp; At the end of my main code, I have a while() loop, which is true always.&amp;nbsp; If I have a breakpoint within TxCallback, and another within this while loop, the program will never enter the while loop upon subsequent runs, but if I remove the breakpoint from TxCallback, it will enter the while loop, multiple times.&lt;/P&gt;&lt;P class=""&gt;&lt;/P&gt;&lt;P class=""&gt;Does anyone understand how to use this and to set this up for audio transfer from an sd card?&lt;/P&gt;&lt;P class=""&gt;&lt;/P&gt;&lt;P class=""&gt;Cheers&lt;/P&gt;&lt;P class=""&gt;&lt;/P&gt;&lt;P class=""&gt;Rory##&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 03 Feb 2020 22:20:25 GMT</pubDate>
      <guid>https://community.nxp.com/t5/MCUXpresso-SDK/Understanding-I2S-SDK-example/m-p/976762#M1901</guid>
      <dc:creator>rory78</dc:creator>
      <dc:date>2020-02-03T22:20:25Z</dc:date>
    </item>
    <item>
      <title>Re: Understanding I2S SDK example</title>
      <link>https://community.nxp.com/t5/MCUXpresso-SDK/Understanding-I2S-SDK-example/m-p/976763#M1902</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi, Rory,&lt;/P&gt;&lt;P&gt;I suppose that you use the ..._i2s_interrupt_transfer example to have a test, for the example, I think this is the the architecture of the example.&lt;/P&gt;&lt;P&gt;First of all, a handler is declared as static i2s_handle_t s_TxHandle; for i2s transmitter, the s_TxHandle-&amp;gt;i2sQueue[handle-&amp;gt;queueDriver] is a component with structure i2s_transfer_t, it contains the sample pointer and data size.&lt;/P&gt;&lt;P&gt;The example use interrupt mechanism to transfer sample to I2S transmitter FIFO, so in the ISR void I2S_TxHandleIRQ(I2S_Type *base, i2s_handle_t *handle) is called. NOTE the I2S_TxHandleIRQ() not exact ISR, it is&amp;nbsp; called by real ISR of FC7. when a bunch of&amp;nbsp; data defined in the s_TxHandle-&amp;gt;i2sQueue[handle-&amp;gt;queueDriver]&amp;nbsp; is completed, the callback function&amp;nbsp; static void TxCallback(I2S_Type *base, i2s_handle_t *handle, status_t completionStatus, void *userData) is called.&amp;nbsp; in the TxCallback() function, you need fill NEW data, the NEW data will update the s_TxHandle-&amp;gt;i2sQueue[handle-&amp;gt;queueDriver] structure.&lt;/P&gt;&lt;P&gt;In conclusion, you are required to just write the callback function TxCallback(), it is okay.&lt;/P&gt;&lt;P&gt;For your application, this is the pseudo code:&lt;/P&gt;&lt;P&gt;assume the data size is 100&lt;/P&gt;&lt;P&gt;uint8_t sample[100]&lt;/P&gt;&lt;P&gt;uint32_t data_size=100;&lt;/P&gt;&lt;P&gt;static void TxCallback(I2S_Type *base, i2s_handle_t *handle, status_t completionStatus, void *userData)&lt;BR /&gt;{&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; //read data from file&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; read(filePointer, &amp;amp;sample[0],data_size);&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; /* Enqueue the same original s_Buffer all over again */&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; i2s_transfer_t *transfer;&lt;/P&gt;&lt;P&gt;transfer-&amp;gt;data=sample&lt;/P&gt;&lt;P&gt;transfer-&amp;gt;dataSize=100;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; I2S_TxTransferNonBlocking(base, handle, *transfer);&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;Hope it can help you&lt;/P&gt;&lt;P&gt;BR&lt;/P&gt;&lt;P&gt;XiangJun Rong&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 06 Feb 2020 09:13:23 GMT</pubDate>
      <guid>https://community.nxp.com/t5/MCUXpresso-SDK/Understanding-I2S-SDK-example/m-p/976763#M1902</guid>
      <dc:creator>xiangjun_rong</dc:creator>
      <dc:date>2020-02-06T09:13:23Z</dc:date>
    </item>
    <item>
      <title>Re: Understanding I2S SDK example</title>
      <link>https://community.nxp.com/t5/MCUXpresso-SDK/Understanding-I2S-SDK-example/m-p/976764#M1903</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P class=""&gt;Hi&amp;nbsp;&lt;A class="jx-jive-macro-user" href="https://community.nxp.com/people/xiangjun.rong"&gt;xiangjun.rong&lt;/A&gt;&amp;nbsp;-&amp;nbsp;&lt;/P&gt;&lt;P class=""&gt;&lt;/P&gt;&lt;P class=""&gt;Thank you for the help.&amp;nbsp; Unfortunately I am still having issues, due to odd behaviour from the f_read function in the FatFS library.&amp;nbsp; (btw, using your example, i can get this to work if I simply initialise transfer-&amp;gt;data to the values inside data1, if I do not read more data into data1.&amp;nbsp; So thank you for helping me getting this much at least to work).&lt;/P&gt;&lt;P class=""&gt;&lt;/P&gt;&lt;P class=""&gt;Inside my TxCallback function i have:&lt;/P&gt;&lt;P class=""&gt;&lt;/P&gt;&lt;P class=""&gt;&lt;SPAN class=""&gt; &lt;/SPAN&gt;error = f_read(&amp;amp;g_fileObject1,&amp;amp;data1,&lt;SPAN class=""&gt;&lt;STRONG&gt;sizeof&lt;/STRONG&gt;&lt;/SPAN&gt;(data1),&amp;amp;bytesRead);&lt;/P&gt;&lt;P class=""&gt;&lt;SPAN class=""&gt; &lt;/SPAN&gt;&lt;SPAN class=""&gt;i2s_transfer_t&lt;/SPAN&gt; *transfer = &lt;SPAN class=""&gt;&lt;STRONG&gt;malloc&lt;/STRONG&gt;&lt;/SPAN&gt;(&lt;SPAN class=""&gt;&lt;STRONG&gt;sizeof&lt;/STRONG&gt;&lt;/SPAN&gt;(*transfer));&lt;/P&gt;&lt;P class=""&gt;&lt;SPAN class=""&gt; &lt;/SPAN&gt;transfer-&amp;gt;&lt;SPAN class=""&gt;data&lt;/SPAN&gt; = &amp;amp;data1[0];&lt;/P&gt;&lt;P class=""&gt;&lt;SPAN class=""&gt; &lt;/SPAN&gt;transfer-&amp;gt;&lt;SPAN class=""&gt;dataSize&lt;/SPAN&gt;=&lt;SPAN class=""&gt;&lt;STRONG&gt;sizeof&lt;/STRONG&gt;&lt;/SPAN&gt;(data1);&lt;/P&gt;&lt;P class=""&gt;&lt;SPAN class=""&gt; &lt;/SPAN&gt;&lt;SPAN class=""&gt;&lt;STRONG&gt;free&lt;/STRONG&gt;&lt;/SPAN&gt;(transfer);&lt;/P&gt;&lt;P class=""&gt;&lt;/P&gt;&lt;P class=""&gt;(data1 is an array of n elements long, of type uint8_t).&lt;/P&gt;&lt;P class=""&gt;&lt;/P&gt;&lt;P class=""&gt;&lt;/P&gt;&lt;P class=""&gt;If I make the size of data1, be 100 elements long, I can only go into TxCallback 5&amp;nbsp; times, before I end up with a failure inside "f_read".&lt;/P&gt;&lt;P class=""&gt;&lt;/P&gt;&lt;P class=""&gt;However, if I perform this "f_read" inside a while(1) loop, further up inside the code (before calling the appropriate i2s initialise functions), I can do more reads than this.&amp;nbsp; I have tracked it down to a variable called "rcnt" within "f_read" which gets initialised differently if I perform "f_read" in the main code, as opposed to when I perform it inside my callback.&amp;nbsp; However, i cannot see how "rcnt" gets initialised (it just happens to be holding some value when I step into "f_read").&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P class=""&gt;&lt;/P&gt;&lt;P class=""&gt;If preferred, I can post this as a new question, as I'm not sure its directly related to I2S operation.&lt;/P&gt;&lt;P class=""&gt;&lt;/P&gt;&lt;P class=""&gt;Many thanks for the help so far,&lt;/P&gt;&lt;P class=""&gt;&lt;/P&gt;&lt;P class=""&gt;Cheers,&lt;/P&gt;&lt;P class=""&gt;&lt;/P&gt;&lt;P class=""&gt;Rory&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 12 Feb 2020 18:44:01 GMT</pubDate>
      <guid>https://community.nxp.com/t5/MCUXpresso-SDK/Understanding-I2S-SDK-example/m-p/976764#M1903</guid>
      <dc:creator>rory78</dc:creator>
      <dc:date>2020-02-12T18:44:01Z</dc:date>
    </item>
  </channel>
</rss>

