<?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 Efficient circular buffer for use with CMSIS-DSP lib K64 in Kinetis Microcontrollers</title>
    <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/Efficient-circular-buffer-for-use-with-CMSIS-DSP-lib-K64/m-p/420907#M24090</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello all, &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I'm trying to figure out an efficient method to pass my (our any version of circular buffer) to the CMSIS-DSPs functions. Specifically, I'm targeting the arm_cfft_f32 function. The issue here is that it requires a source pointer to a contiguous memory space. Yet, the design of a ring or circular buffer makes that difficult. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I'm using a K64, using 32 bit floats, with 32 point input buffer.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;My current buffer code is:&lt;/P&gt;&lt;PRE __default_attr="c++" __jive_macro_name="code" class="jive_macro_code _jivemacro_uid_14389017070687132 jive_text_macro" data-renderedposition="197_8_1232_400" jivemacro_uid="_14389017070687132"&gt;&lt;P&gt;#define BUFF_SIZE 32&lt;/P&gt;&lt;P&gt;#define BUFF_SIZE_MASK (BUFF_SIZE-1)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;typedef struct filbuffer{&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; float buff[BUFF_SIZE];&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; int writeIndex;&lt;/P&gt;&lt;P&gt;}filbuffer;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;void initBuffer(filbuffer* buffer){&lt;/P&gt;&lt;P&gt;&amp;nbsp; int i;&lt;/P&gt;&lt;P&gt;&amp;nbsp; buffer-&amp;gt;writeIndex = 0;&lt;/P&gt;&lt;P&gt;&amp;nbsp; for(i=0;i&amp;lt;BUFF_SIZE;i++){&lt;/P&gt;&lt;P&gt;&amp;nbsp; buffer-&amp;gt;buff[i]=0;&lt;/P&gt;&lt;P&gt;&amp;nbsp; }&lt;/P&gt;&lt;P&gt;}&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;/* Write to the buffer */&lt;/P&gt;&lt;P&gt;void write(filbuffer* buffer, float value){&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; buffer-&amp;gt;buff[(buffer-&amp;gt;writeIndex++) &amp;amp; BUFF_SIZE_MASK] = value;&lt;/P&gt;&lt;P&gt;}&lt;/P&gt;&lt;P&gt;/* Read from the buffer -- probably not needed */&lt;/P&gt;&lt;P&gt;float readn(filbuffer* buffer, int Xn){&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; return buffer-&amp;gt;buff[(buffer-&amp;gt;writeIndex + (~Xn)) &amp;amp; BUFF_SIZE_MASK];&lt;/P&gt;&lt;P&gt;}&lt;/P&gt;&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 06 Aug 2015 22:55:52 GMT</pubDate>
    <dc:creator>jparrish88</dc:creator>
    <dc:date>2015-08-06T22:55:52Z</dc:date>
    <item>
      <title>Efficient circular buffer for use with CMSIS-DSP lib K64</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/Efficient-circular-buffer-for-use-with-CMSIS-DSP-lib-K64/m-p/420907#M24090</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello all, &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I'm trying to figure out an efficient method to pass my (our any version of circular buffer) to the CMSIS-DSPs functions. Specifically, I'm targeting the arm_cfft_f32 function. The issue here is that it requires a source pointer to a contiguous memory space. Yet, the design of a ring or circular buffer makes that difficult. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I'm using a K64, using 32 bit floats, with 32 point input buffer.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;My current buffer code is:&lt;/P&gt;&lt;PRE __default_attr="c++" __jive_macro_name="code" class="jive_macro_code _jivemacro_uid_14389017070687132 jive_text_macro" data-renderedposition="197_8_1232_400" jivemacro_uid="_14389017070687132"&gt;&lt;P&gt;#define BUFF_SIZE 32&lt;/P&gt;&lt;P&gt;#define BUFF_SIZE_MASK (BUFF_SIZE-1)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;typedef struct filbuffer{&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; float buff[BUFF_SIZE];&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; int writeIndex;&lt;/P&gt;&lt;P&gt;}filbuffer;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;void initBuffer(filbuffer* buffer){&lt;/P&gt;&lt;P&gt;&amp;nbsp; int i;&lt;/P&gt;&lt;P&gt;&amp;nbsp; buffer-&amp;gt;writeIndex = 0;&lt;/P&gt;&lt;P&gt;&amp;nbsp; for(i=0;i&amp;lt;BUFF_SIZE;i++){&lt;/P&gt;&lt;P&gt;&amp;nbsp; buffer-&amp;gt;buff[i]=0;&lt;/P&gt;&lt;P&gt;&amp;nbsp; }&lt;/P&gt;&lt;P&gt;}&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;/* Write to the buffer */&lt;/P&gt;&lt;P&gt;void write(filbuffer* buffer, float value){&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; buffer-&amp;gt;buff[(buffer-&amp;gt;writeIndex++) &amp;amp; BUFF_SIZE_MASK] = value;&lt;/P&gt;&lt;P&gt;}&lt;/P&gt;&lt;P&gt;/* Read from the buffer -- probably not needed */&lt;/P&gt;&lt;P&gt;float readn(filbuffer* buffer, int Xn){&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; return buffer-&amp;gt;buff[(buffer-&amp;gt;writeIndex + (~Xn)) &amp;amp; BUFF_SIZE_MASK];&lt;/P&gt;&lt;P&gt;}&lt;/P&gt;&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 06 Aug 2015 22:55:52 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/Efficient-circular-buffer-for-use-with-CMSIS-DSP-lib-K64/m-p/420907#M24090</guid>
      <dc:creator>jparrish88</dc:creator>
      <dc:date>2015-08-06T22:55:52Z</dc:date>
    </item>
    <item>
      <title>Re: Efficient circular buffer for use with CMSIS-DSP lib K64</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/Efficient-circular-buffer-for-use-with-CMSIS-DSP-lib-K64/m-p/420908#M24091</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi, Friends,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I see&amp;nbsp; that you would like to use the following api function to compute the complex FFT which is defined in arm_cfft_f32.c.&lt;/P&gt;&lt;P&gt;If it is the case, you use the function:&lt;/P&gt;&lt;P&gt;void arm_cfft_f32( &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; const arm_cfft_instance_f32 * S, &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; float32_t * p1,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; uint8_t ifftFlag,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; uint8_t bitReverseFlag)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;* The FFT functions operate in-place.&amp;nbsp; That is, the array holding the input data&lt;/P&gt;&lt;P&gt;* will also be used to hold the corresponding result.&amp;nbsp; The input data is complex&lt;/P&gt;&lt;P&gt;* and contains &amp;lt;code&amp;gt;2*fftLen&amp;lt;/code&amp;gt; interleaved values as shown below.&lt;/P&gt;&lt;P&gt;* &amp;lt;pre&amp;gt; {real[0], imag[0], real[1], imag[1],..} &amp;lt;/pre&amp;gt;&lt;/P&gt;&lt;P&gt;* The FFT result will be contained in the same array and the frequency domain&lt;/P&gt;&lt;P&gt;* values will have the same interleaving.&lt;/P&gt;&lt;P&gt;as the above direction, you can define a structure:&lt;/P&gt;&lt;P&gt;&lt;SPAN class="keyword"&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN class="keyword"&gt;typedef &lt;SPAN class="keyword"&gt;struct&lt;/SPAN&gt; { &lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN class="keyword"&gt;float32_t real;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN class="keyword"&gt;float32_t image;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN class="keyword"&gt;} complex;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN class="keyword"&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN class="keyword"&gt;complex array[64];&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN class="keyword"&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN class="keyword"&gt;after you initialize the array[] and call the arm_cfft_f32(), it is okay.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN class="keyword"&gt;BR&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN class="keyword"&gt;Xiangjun Rong&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN class="keyword"&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 07 Aug 2015 04:31:36 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/Efficient-circular-buffer-for-use-with-CMSIS-DSP-lib-K64/m-p/420908#M24091</guid>
      <dc:creator>xiangjun_rong</dc:creator>
      <dc:date>2015-08-07T04:31:36Z</dc:date>
    </item>
  </channel>
</rss>

