<?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: 【Urgent Question】  Codewarrior Bug or Code error ?  ---About The FFT function dfr16RFFT in Classic/Legacy CodeWarrior</title>
    <link>https://community.nxp.com/t5/Classic-Legacy-CodeWarrior/Urgent-Question-Codewarrior-Bug-or-Code-error-About-The-FFT/m-p/130611#M474</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;Hi, Vincent:&lt;BR /&gt;&lt;BR /&gt;What do you mean by "it does not work well"? Do you mean it is not as accurate as Matlab? Or do you mean that it takes a lot of coffee breaks and complains a lot? (I do when I have to do an FFT).&lt;BR /&gt;&lt;BR /&gt;Matlab is going to give you a very accurate answer, but a 16-bit fraction is not. The resolution of a 16-bit fraction is approximately 0.00003, ranging from -1.0 to almost 1.0 (actually, 0.99997). When you consider what happens to the coefficients and with all of the multiplications, you can't expect much accuracy. But what you are getting is speed.&lt;BR /&gt;&lt;BR /&gt;If your problem is not with the accuracy, then never mind . . .&lt;BR /&gt;&lt;BR /&gt;Hope that helps.&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 31 Mar 2006 05:22:08 GMT</pubDate>
    <dc:creator>rocco</dc:creator>
    <dc:date>2006-03-31T05:22:08Z</dc:date>
    <item>
      <title>【Urgent Question】  Codewarrior Bug or Code error ?  ---About The FFT function dfr16RFFT</title>
      <link>https://community.nxp.com/t5/Classic-Legacy-CodeWarrior/Urgent-Question-Codewarrior-Bug-or-Code-error-About-The-FFT/m-p/130610#M473</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;DIV&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;When &amp;nbsp;i &amp;nbsp;use &amp;nbsp;the &amp;nbsp;function-dfr16RFFT &amp;nbsp;in &amp;nbsp;PE &amp;nbsp;to &amp;nbsp;execute &amp;nbsp;a &amp;nbsp;FFT. &amp;nbsp;It &amp;nbsp;doesn't &amp;nbsp;work &amp;nbsp;well,Although &amp;nbsp;i &amp;nbsp;strictly &amp;nbsp;follow &amp;nbsp;the &amp;nbsp;instructions &amp;nbsp;of &amp;nbsp;PE's &amp;nbsp;manual&amp;nbsp;&amp;nbsp;,It does not work well . My code goes following . i'm wondering what's wrong with it ?&amp;nbsp; does Anyone can give me an example of the function dfr16RFFT which give the same result of the answer from Matlab&amp;nbsp; "fft([0.1 0.2 0.3 0.4],8)"&lt;/DIV&gt;&lt;DIV&gt;ans =&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&amp;nbsp;1.0000&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;BR /&gt;&amp;nbsp;-0.0414 + 0.7243i&lt;BR /&gt;&amp;nbsp;-0.2000 - 0.2000i&lt;BR /&gt;&amp;nbsp;&amp;nbsp;0.2414 + 0.1243i&lt;BR /&gt;&amp;nbsp;-0.2000&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;0.2414 - 0.1243i&lt;BR /&gt;&amp;nbsp;-0.2000 + 0.2000i&lt;BR /&gt;&amp;nbsp;-0.0414 - 0.7243i&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;Thanks A lot!!!!!!!&lt;/DIV&gt;&lt;DIV&gt;==============&lt;/DIV&gt;&lt;DIV&gt;void main(void)&lt;BR /&gt;{&lt;BR /&gt;&amp;nbsp;/*** Processor Expert internal initialization. DON'T REMOVE THIS CODE!!! ***/&lt;BR /&gt;&amp;nbsp;&lt;BR /&gt;&amp;nbsp;/*** End of Processor Expert internal initialization.&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ***/&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;/* Write your code here */&lt;BR /&gt;&amp;nbsp;&amp;nbsp;dfr16_tRFFTStruct *pRFFT;&lt;BR /&gt;&amp;nbsp;Result&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; res;&lt;BR /&gt;&amp;nbsp;Frac16&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; pX[]={FRAC16(0.1),FRAC16(0.2),FRAC16(0.3),FRAC16(0.4)};&lt;BR /&gt;&amp;nbsp;UInt16&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; options = FFT_SCALE_RESULTS_BY_N;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;dfr16_sInplaceCRFFT *pZ=malloc(sizeof(dfr16_sInplaceCRFFT));&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;BR /&gt;&amp;nbsp;PE_low_level_init();&lt;BR /&gt;&amp;nbsp;pRFFT = dfr16RFFTCreate (8, options); /* N = 8 point RFFT */&lt;BR /&gt;&amp;nbsp;res = dfr16RFFT (pRFFT, pX, pZ);&lt;BR /&gt;&amp;nbsp;&lt;BR /&gt;&amp;nbsp;&lt;BR /&gt;&amp;nbsp;dfr16RFFTDestroy (pRFFT);&lt;BR /&gt;&amp;nbsp;&lt;BR /&gt;&amp;nbsp;for(;&lt;A href="http://freescale.i.lithium.com/i/smilies/16x16_smiley-wink.gif"&gt;&lt;IMG alt=":smileywink:" class="emoticon emoticon-smileywink" src="http://freescale.i.lithium.com/i/smilies/16x16_smiley-wink.gif" title="Smiley Wink" /&gt;&lt;/A&gt; {}&lt;BR /&gt;}&lt;BR /&gt;=====================&lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 30 Mar 2006 19:15:09 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Classic-Legacy-CodeWarrior/Urgent-Question-Codewarrior-Bug-or-Code-error-About-The-FFT/m-p/130610#M473</guid>
      <dc:creator>vincent2046</dc:creator>
      <dc:date>2006-03-30T19:15:09Z</dc:date>
    </item>
    <item>
      <title>Re: 【Urgent Question】  Codewarrior Bug or Code error ?  ---About The FFT function dfr16RFFT</title>
      <link>https://community.nxp.com/t5/Classic-Legacy-CodeWarrior/Urgent-Question-Codewarrior-Bug-or-Code-error-About-The-FFT/m-p/130611#M474</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;Hi, Vincent:&lt;BR /&gt;&lt;BR /&gt;What do you mean by "it does not work well"? Do you mean it is not as accurate as Matlab? Or do you mean that it takes a lot of coffee breaks and complains a lot? (I do when I have to do an FFT).&lt;BR /&gt;&lt;BR /&gt;Matlab is going to give you a very accurate answer, but a 16-bit fraction is not. The resolution of a 16-bit fraction is approximately 0.00003, ranging from -1.0 to almost 1.0 (actually, 0.99997). When you consider what happens to the coefficients and with all of the multiplications, you can't expect much accuracy. But what you are getting is speed.&lt;BR /&gt;&lt;BR /&gt;If your problem is not with the accuracy, then never mind . . .&lt;BR /&gt;&lt;BR /&gt;Hope that helps.&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 31 Mar 2006 05:22:08 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Classic-Legacy-CodeWarrior/Urgent-Question-Codewarrior-Bug-or-Code-error-About-The-FFT/m-p/130611#M474</guid>
      <dc:creator>rocco</dc:creator>
      <dc:date>2006-03-31T05:22:08Z</dc:date>
    </item>
    <item>
      <title>Re: 【Urgent Question】  Codewarrior Bug or Code error ?  ---About The FFT function dfr16RFFT</title>
      <link>https://community.nxp.com/t5/Classic-Legacy-CodeWarrior/Urgent-Question-Codewarrior-Bug-or-Code-error-About-The-FFT/m-p/130612#M475</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;DIV&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;rocoo,&amp;nbsp; thanks for&amp;nbsp; ur reply. But&amp;nbsp; It's&amp;nbsp; not a problem of speed or accurate.&lt;/DIV&gt;&lt;DIV&gt;i could not get any result from this function [ dfr16RFFT].&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;The function [dfr16RFFT]&amp;nbsp; always returns -1 which indicate an error.&lt;/DIV&gt;&lt;DIV&gt;or it jump to an interrupt vector when i step by step run this program.&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;even more ,i'm confused by the result struct.&lt;/DIV&gt;&lt;DIV&gt;&lt;P&gt;&lt;FONT face="Courier"&gt;&lt;FONT size="2"&gt;typedef struct {&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&lt;FONT face="Courier"&gt;&lt;FONT size="2"&gt;Frac16&amp;nbsp;&amp;nbsp; z0; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;/* z[0]&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; (real 16-bit fractional) */&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&lt;FONT face="Courier"&gt;&lt;FONT size="2"&gt;Frac16&amp;nbsp;&amp;nbsp; zNDiv2; &amp;nbsp;&amp;nbsp;&amp;nbsp;/* z[n/2]&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; (real 16-bit fractional) */&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&lt;FONT face="Courier"&gt;&lt;FONT size="2"&gt;CFrac16&amp;nbsp;&amp;nbsp;cz[1]; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;/* z[1] .. z[n/2 - 1] (complex 16-bit fractional)*/&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier"&gt;&lt;FONT size="2"&gt;} dfr16_sInplaceCRFFT;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;how could it place &lt;FONT face="Courier" size="2"&gt;z[1] .. z[n/2 - 1] to 2 short CFrac16 variable?&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier" size="2"&gt;i want to print the result with the command "printf".&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier" size="2"&gt;for (i=0;i&amp;lt;n/2;i++)&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier" size="2"&gt;&amp;nbsp;&amp;nbsp;printf("z[%d]= %f",i,????);&lt;/FONT&gt;&lt;/P&gt;&lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 31 Mar 2006 09:48:45 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Classic-Legacy-CodeWarrior/Urgent-Question-Codewarrior-Bug-or-Code-error-About-The-FFT/m-p/130612#M475</guid>
      <dc:creator>vincent2046</dc:creator>
      <dc:date>2006-03-31T09:48:45Z</dc:date>
    </item>
    <item>
      <title>Re: 【Urgent Question】  Codewarrior Bug or Code error ?  ---About The FFT function dfr16RFFT</title>
      <link>https://community.nxp.com/t5/Classic-Legacy-CodeWarrior/Urgent-Question-Codewarrior-Bug-or-Code-error-About-The-FFT/m-p/130613#M476</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;DIV&gt;&lt;/DIV&gt;&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;it seems to be a problem of memory allocation.&lt;/P&gt;&lt;P&gt;On the line:&lt;BR /&gt;dfr16_sInplaceCRFFT *pZ=malloc(sizeof(dfr16_sInplaceCRFFT));&lt;/P&gt;&lt;P&gt;It is not possible to use the sizeof operator, since the structure dfr16_sInplaceCRFFT represents only a beginning of the array of the values (if contains only a first and last element - both real valus(z0 and zNDIv2) and only a beginning of the complex results array CZ that is array of CFrac16 types.&lt;BR /&gt;The actual size of the cz[] array differs according to the length of the input.&lt;/P&gt;&lt;P&gt;It should be done the following way:&amp;nbsp;&lt;/P&gt;&lt;P&gt;dfr16_sInplaceCRFFT *pZ=malloc(2*sizeof(Frac16) + (N/2-1) * sizeof(CFrac16));&lt;/P&gt;&lt;P&gt;The second thing is that the malloc function won't work placed before the&lt;BR /&gt;PE_low_level_init(); call, because it uses the DSP_MEM bean.&lt;BR /&gt;Do you have DSP_MEM bean correctly configured?&lt;BR /&gt;The DSP_MEM bean has to be correctly configured for the proper function of&lt;BR /&gt;the dynamic memory allocation. There has to be at least one memory area with&lt;BR /&gt;the quialifier INTERNAL_DYNAMIC or EXTERNAL_DYNAMIC.&lt;BR /&gt;Please see the applicaiton notes page in the help pages for the DSP_MEM bean.&lt;BR /&gt;This may be the reason why the statement&lt;/P&gt;&lt;P&gt;pRFFT = dfr16RFFTCreate (8, options); /* N = 8 point RFFT */&lt;/P&gt;&lt;P&gt;doesn't properly allocate the memory and consequently the dfr16RFFT function&lt;BR /&gt;results with -1. Please see the pRFFT value if it is not null.&lt;/P&gt;&lt;P&gt;Regarding the displaying of the values, you can use the following way:&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;/* first */&lt;BR /&gt;printf("z[0]= %f", ((short) (pZ-&amp;gt;z0)) / (float)32768);&lt;BR /&gt;/* complex values */&lt;BR /&gt;for (i=0;i&amp;lt;N/2;i++) {&lt;/P&gt;&lt;P&gt;&amp;nbsp;printf("z[%d] real = %f",i,((short) (pZ-&amp;gt;z[i].real)) / (float)32768));&lt;BR /&gt;&amp;nbsp;printf("z[%d] imag = %f",i,((short) (pZ-&amp;gt;z[i].imag)) / (float)32768));&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&lt;BR /&gt;}&lt;BR /&gt;/* last */&lt;BR /&gt;printf("z[N/2]= %f", ((short) (pZ-&amp;gt;zNDiv2)) / (float)32768 );&lt;/P&gt;&lt;P&gt;I hope that this will help.&lt;/P&gt;&lt;P&gt;best regards&lt;BR /&gt;Petr Hradsky&lt;BR /&gt;Processor Expert Support Team&lt;BR /&gt;UNIS&lt;BR /&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 03 Apr 2006 18:11:50 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Classic-Legacy-CodeWarrior/Urgent-Question-Codewarrior-Bug-or-Code-error-About-The-FFT/m-p/130613#M476</guid>
      <dc:creator>ProcessorExpert</dc:creator>
      <dc:date>2006-04-03T18:11:50Z</dc:date>
    </item>
  </channel>
</rss>

