<?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: digital filter preinstalled in codewarrior 10.7 ? in Kinetis Microcontrollers</title>
    <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/digital-filter-preinstalled-in-codewarrior-10-7/m-p/692651#M42683</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi, Philipp,&lt;/P&gt;&lt;P&gt;I am glad to hear you have fixed the library issue.&lt;/P&gt;&lt;P&gt;Regarding the q15 FIR digital filter, I suppose you have to acquire the coefficents array with matlab or the other tools based on the application requirements, if the coefficents array is float type, and the absolute maximum element is greater than 1, you can divide each element of the coefficents with the absolute maximum element, in this way all the coeffiecnts in the array ranges from -1 to +1.&lt;/P&gt;&lt;P&gt;You can use the macro to transform the coeeicents to Q15.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;#define FRAC16(x) 32768*x&lt;BR /&gt;#define TAPNUMBER 20&lt;BR /&gt;#define BLOCKSIZE 1&lt;BR /&gt;#define TOTAL_POINTS 100&lt;BR /&gt;#define Q15_OFFSET 0x4000&lt;/P&gt;&lt;P&gt;int16_t lpFilterCoefficent[TAPNUMBER]=&lt;BR /&gt;{&lt;BR /&gt;FRAC16(4.45556640625000e-003),&lt;BR /&gt;FRAC16(1.44042968750000e-002),&lt;BR /&gt;FRAC16(2.54516601562500e-002),&lt;BR /&gt;FRAC16(3.69873046875000e-002),&lt;BR /&gt;FRAC16(4.84619140625000e-002),&lt;BR /&gt;FRAC16(5.92041015625000e-002),&lt;BR /&gt;FRAC16(6.86950683593750e-002),&lt;BR /&gt;FRAC16(7.63244628906250e-002),&lt;BR /&gt;FRAC16(8.16650390625000e-002),&lt;BR /&gt;FRAC16(8.44116210937500e-002),&lt;BR /&gt;FRAC16(8.44116210937500e-002),&lt;BR /&gt;FRAC16(8.16650390625000e-002),&lt;BR /&gt;FRAC16(7.63244628906250e-002),&lt;BR /&gt;FRAC16(6.86950683593750e-002),&lt;BR /&gt;FRAC16(5.92041015625000e-002),&lt;BR /&gt;FRAC16(4.84619140625000e-002),&lt;BR /&gt;FRAC16(3.69873046875000e-002),&lt;BR /&gt;FRAC16(2.54516601562500e-002),&lt;BR /&gt;FRAC16(1.44042968750000e-002),&lt;BR /&gt;FRAC16(4.45556640625000e-003)&lt;BR /&gt;};&lt;/P&gt;&lt;P&gt;const arm_fir_instance_q15 sFirStru;&lt;BR /&gt;int16_t FirState[TAPNUMBER+BLOCKSIZE];&lt;/P&gt;&lt;P&gt;int16_t temp,temp1;&lt;/P&gt;&lt;P&gt;void main()&lt;/P&gt;&lt;P&gt;{&lt;/P&gt;&lt;P&gt;.....................&lt;/P&gt;&lt;P&gt;arm_fir_init_q15(&amp;amp;sFirStru,TAPNUMBER,&amp;amp;lpFilterCoefficent[0],&amp;amp;FirState[0],BLOCKSIZE);&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;arm_fir_fast_q15(&amp;amp;sFirStru,&amp;amp;temp,&amp;amp;temp1,1);&lt;/P&gt;&lt;P&gt;}&lt;/P&gt;&lt;P&gt;In the code, the temp is the latest sample(Note if the sample is in 16 bits, you should logic right shift one bit, because the MSB is regarded as sign. In other words, the MSB should be zero), temp1 is the filtered result. Generally, the arm_fir_fast_q15() should be put in the ADC ISR.&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, 13 Jul 2017 03:42:15 GMT</pubDate>
    <dc:creator>xiangjun_rong</dc:creator>
    <dc:date>2017-07-13T03:42:15Z</dc:date>
    <item>
      <title>digital filter preinstalled in codewarrior 10.7 ?</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/digital-filter-preinstalled-in-codewarrior-10-7/m-p/692648#M42680</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello, &lt;/P&gt;&lt;P&gt;i working with a TWR-K60F120M Evaluationboard.&lt;/P&gt;&lt;P&gt;I build a &lt;SPAN class="" lang="en"&gt;&lt;SPAN class=""&gt;continuous&lt;/SPAN&gt;&lt;/SPAN&gt; single ended adc &lt;SPAN class="" lang="en"&gt;&lt;SPAN class=""&gt;Measurement&lt;/SPAN&gt;&lt;/SPAN&gt; and all works fine. With the dma function i don't have to burden the µC with the measurement. My problem is that i can't find any components for digital filtering and i have problems to use the CMSIS Lib of ARM. I looking for a way to use a &lt;SPAN class="" lang="en"&gt;&lt;SPAN class=""&gt;Moving average on my measured value without programm the code myself. &lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 11 Jul 2017 12:39:44 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/digital-filter-preinstalled-in-codewarrior-10-7/m-p/692648#M42680</guid>
      <dc:creator>philippadolph</dc:creator>
      <dc:date>2017-07-11T12:39:44Z</dc:date>
    </item>
    <item>
      <title>Re: digital filter preinstalled in codewarrior 10.7 ?</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/digital-filter-preinstalled-in-codewarrior-10-7/m-p/692649#M42681</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi, Philipp,&lt;/P&gt;&lt;P&gt;I suggest you can use FIR digital filter, if you want to perform &lt;SPAN class="" lang="en"&gt;&lt;SPAN class=""&gt;Moving average&lt;/SPAN&gt;&lt;/SPAN&gt;, it is okay to use digital filter by setting the digital coefficents as the same value.&lt;/P&gt;&lt;P&gt;I think you have to do digital filtering, currently, what is your problem? You can post you code, I can help you to fix the issue.&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>Wed, 12 Jul 2017 09:28:30 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/digital-filter-preinstalled-in-codewarrior-10-7/m-p/692649#M42681</guid>
      <dc:creator>xiangjun_rong</dc:creator>
      <dc:date>2017-07-12T09:28:30Z</dc:date>
    </item>
    <item>
      <title>Re: digital filter preinstalled in codewarrior 10.7 ?</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/digital-filter-preinstalled-in-codewarrior-10-7/m-p/692650#M42682</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;SPAN class=""&gt;&lt;A _jive_internal="true" class="" data-content-finding="Community" data-userid="19420" data-username="xiangjun.rong" href="https://community.nxp.com/people/xiangjun.rong"&gt;xiangjun.rong here my project&lt;/A&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN class=""&gt;i can use the library , i found my problem with the implantation.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN class=""&gt;but i don't know how to use the q15 fir function probably&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 12 Jul 2017 17:21:56 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/digital-filter-preinstalled-in-codewarrior-10-7/m-p/692650#M42682</guid>
      <dc:creator>philippadolph</dc:creator>
      <dc:date>2017-07-12T17:21:56Z</dc:date>
    </item>
    <item>
      <title>Re: digital filter preinstalled in codewarrior 10.7 ?</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/digital-filter-preinstalled-in-codewarrior-10-7/m-p/692651#M42683</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi, Philipp,&lt;/P&gt;&lt;P&gt;I am glad to hear you have fixed the library issue.&lt;/P&gt;&lt;P&gt;Regarding the q15 FIR digital filter, I suppose you have to acquire the coefficents array with matlab or the other tools based on the application requirements, if the coefficents array is float type, and the absolute maximum element is greater than 1, you can divide each element of the coefficents with the absolute maximum element, in this way all the coeffiecnts in the array ranges from -1 to +1.&lt;/P&gt;&lt;P&gt;You can use the macro to transform the coeeicents to Q15.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;#define FRAC16(x) 32768*x&lt;BR /&gt;#define TAPNUMBER 20&lt;BR /&gt;#define BLOCKSIZE 1&lt;BR /&gt;#define TOTAL_POINTS 100&lt;BR /&gt;#define Q15_OFFSET 0x4000&lt;/P&gt;&lt;P&gt;int16_t lpFilterCoefficent[TAPNUMBER]=&lt;BR /&gt;{&lt;BR /&gt;FRAC16(4.45556640625000e-003),&lt;BR /&gt;FRAC16(1.44042968750000e-002),&lt;BR /&gt;FRAC16(2.54516601562500e-002),&lt;BR /&gt;FRAC16(3.69873046875000e-002),&lt;BR /&gt;FRAC16(4.84619140625000e-002),&lt;BR /&gt;FRAC16(5.92041015625000e-002),&lt;BR /&gt;FRAC16(6.86950683593750e-002),&lt;BR /&gt;FRAC16(7.63244628906250e-002),&lt;BR /&gt;FRAC16(8.16650390625000e-002),&lt;BR /&gt;FRAC16(8.44116210937500e-002),&lt;BR /&gt;FRAC16(8.44116210937500e-002),&lt;BR /&gt;FRAC16(8.16650390625000e-002),&lt;BR /&gt;FRAC16(7.63244628906250e-002),&lt;BR /&gt;FRAC16(6.86950683593750e-002),&lt;BR /&gt;FRAC16(5.92041015625000e-002),&lt;BR /&gt;FRAC16(4.84619140625000e-002),&lt;BR /&gt;FRAC16(3.69873046875000e-002),&lt;BR /&gt;FRAC16(2.54516601562500e-002),&lt;BR /&gt;FRAC16(1.44042968750000e-002),&lt;BR /&gt;FRAC16(4.45556640625000e-003)&lt;BR /&gt;};&lt;/P&gt;&lt;P&gt;const arm_fir_instance_q15 sFirStru;&lt;BR /&gt;int16_t FirState[TAPNUMBER+BLOCKSIZE];&lt;/P&gt;&lt;P&gt;int16_t temp,temp1;&lt;/P&gt;&lt;P&gt;void main()&lt;/P&gt;&lt;P&gt;{&lt;/P&gt;&lt;P&gt;.....................&lt;/P&gt;&lt;P&gt;arm_fir_init_q15(&amp;amp;sFirStru,TAPNUMBER,&amp;amp;lpFilterCoefficent[0],&amp;amp;FirState[0],BLOCKSIZE);&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;arm_fir_fast_q15(&amp;amp;sFirStru,&amp;amp;temp,&amp;amp;temp1,1);&lt;/P&gt;&lt;P&gt;}&lt;/P&gt;&lt;P&gt;In the code, the temp is the latest sample(Note if the sample is in 16 bits, you should logic right shift one bit, because the MSB is regarded as sign. In other words, the MSB should be zero), temp1 is the filtered result. Generally, the arm_fir_fast_q15() should be put in the ADC ISR.&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, 13 Jul 2017 03:42:15 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/digital-filter-preinstalled-in-codewarrior-10-7/m-p/692651#M42683</guid>
      <dc:creator>xiangjun_rong</dc:creator>
      <dc:date>2017-07-13T03:42:15Z</dc:date>
    </item>
    <item>
      <title>Re: digital filter preinstalled in codewarrior 10.7 ?</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/digital-filter-preinstalled-in-codewarrior-10-7/m-p/692652#M42684</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;My ADC measurement saves 32768 values via dma in a array and all works fine and the change of my coeffs work also from float to int16_t.&lt;/P&gt;&lt;P&gt;Here my code for fir&lt;/P&gt;&lt;P&gt;//DEFINES&lt;BR /&gt;#define TEST_LENGTH_SAMPLES 16384&lt;BR /&gt;#define BLOCK_SIZE 32&lt;BR /&gt;#define NUM_TAPS 29&lt;BR /&gt;//COEFFICIENTS fir1(28,1/5) mathlab&lt;BR /&gt;float32_t Coeffs[NUM_TAPS]={&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;0.0011 , 0.0021 , 0.0032 , 0.0031 , -0.0000 , -0.0071 , -0.0165 , -0.0233 , -0.0200 , 0.0000 , 0.0386 , 0.0906 , 0.1441 ,&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;0.1845 , 0.1995 , 0.1845 , 0.1441 , 0.0906 , 0.0386 , 0.0000 , -0.0200 , -0.0233 , -0.0165 , -0.0071 , -0.0000 , 0.0031 , &lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;0.0032 , 0.0021 , 0.0011&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;BR /&gt;};&lt;BR /&gt;//&lt;BR /&gt;uint16_t numblocks=TEST_LENGTH_SAMPLES/BLOCK_SIZE;&lt;BR /&gt;//NUMBER OF SAMPLES&lt;BR /&gt;uint32_t blocksize=BLOCK_SIZE;&lt;BR /&gt;//COEFFICIENTS int16_t&lt;BR /&gt;int16_t Coeffsq15[NUM_TAPS];&lt;BR /&gt;//FIR Output&lt;BR /&gt;int16_t output_fir[TEST_LENGTH_SAMPLES];&lt;BR /&gt;//STATE buffer&lt;BR /&gt;int16_t firstate[BLOCK_SIZE+NUM_TAPS];&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;....&lt;/P&gt;&lt;P&gt;int main(void)&lt;BR /&gt;/*lint -restore Enable MISRA rule (6.3) checking. */&lt;BR /&gt;{&lt;/P&gt;&lt;P&gt;....&lt;/P&gt;&lt;P&gt;arm_fir_instance_q15 S;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;uint16_t i;&lt;/P&gt;&lt;P&gt;....&lt;/P&gt;&lt;P&gt;//FIR&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;arm_float_to_q15(Coeffs,Coeffsq15,29);&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;arm_fir_init_q15(&amp;amp;S,29,&amp;amp;Coeffsq15[0],&amp;amp;firstate[0],blocksize);&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;for (;;) &lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;{&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;if(DMA_complete==TRUE)&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;{&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;for(i=0;i&amp;lt;numblocks;i++)&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;{&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;arm_fir_q15(&amp;amp;S,Messwertarray+(i*blocksize),output_fir+(i+blocksize),blocksize);&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;}&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;}&lt;/P&gt;&lt;P&gt;If i debug my system jumps in a hardfault. What am i doing wrong?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 13 Jul 2017 10:24:50 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/digital-filter-preinstalled-in-codewarrior-10-7/m-p/692652#M42684</guid>
      <dc:creator>philippadolph</dc:creator>
      <dc:date>2017-07-13T10:24:50Z</dc:date>
    </item>
    <item>
      <title>Re: digital filter preinstalled in codewarrior 10.7 ?</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/digital-filter-preinstalled-in-codewarrior-10-7/m-p/692653#M42685</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi, Philipp,&lt;/P&gt;&lt;P&gt;&lt;EM&gt; I suspect that the code is incorrect.&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt; &amp;nbsp;arm_fir_q15(&amp;amp;S,Messwertarray+(i*blocksize),output_fir+(i+blocksize),blocksize);&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;Pls check if the address of Messwertarray and output_fir is correct.&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;I suspect you should use this line.&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt; &amp;nbsp;arm_fir_q15(&amp;amp;S,Messwertarray+(i*blocksize*sizeof(int16_t)),output_fir+(i*blocksize*sizeof(int16_t)),blocksize);&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;Pls have a check.&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;BR&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;Xiangjun Rong&lt;/EM&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 14 Jul 2017 06:15:18 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/digital-filter-preinstalled-in-codewarrior-10-7/m-p/692653#M42685</guid>
      <dc:creator>xiangjun_rong</dc:creator>
      <dc:date>2017-07-14T06:15:18Z</dc:date>
    </item>
  </channel>
</rss>

