Testing FFT filter for SAM4S2A

Go To Last Post
6 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

The below code is FFT filter code for SAM4SD32C

 

"<

uint32_t ifftFlag = 0;
uint32_t doBitReverse = 1;
uint32_t fftSize = 1024;

#define TEST_LENGTH_SAMPLES 2048

 

for(xt=0;xt<2048;xt++)
            {
                mt[xt] =  adc_get_channel_value(ADC, ADC_CHANNEL_0);

               testInput_f32_10khz[xt] =(0.6-((float)mt[xt]/4100.00))*16.00;
                delay_us(10);
                
        
            arm_cfft_f32(&arm_cfft_sR_f32_len1024, testInput_f32_10khz, ifftFlag, doBitReverse);
            arm_cmplx_mag_f32(testInput_f32_10khz, testOutput, fftSize);
            arm_max_f32(testOutput, fftSize, &maxValue, &testIndex);
            maxi = maxValue;
            printf("Maxi %d test Index %d\n",maxi,testIndex);
        
        }

>"

 

I trying to work out the same code in SAM4S2A controller

 

But the output values maxi and testIndex are changing.Due to this output is not as getting and testIndex value is getting 0.

 

can any one help me out to resolve the issue.

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

can any on please try to give reply for the above query.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I don't have a SAM4S so I doubt I can help but is that really the correct code? It looks like the fft is done 2048 times with different input so it would make sense the result is not the same. What is mt, testInput_f32_10khz, testOutput?

/Lars

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

uint32_t ifftFlag = 0,testIndex = 0;
uint32_t doBitReverse = 1;
uint32_t fftSize = 1024;
#define TEST_LENGTH_SAMPLES 2048
float32_t testOutput[TEST_LENGTH_SAMPLES/2],testInput_f32_10khz[TEST_LENGTH_SAMPLES];
float32_t maxValue;
int maxi=0;

while(1)
{
    for(xt=0;xt<2048;xt++)
    {
        mt[xt] =  adc_get_channel_value(ADC, ADC_CHANNEL_0);
        testInput_f32_10khz[xt] =(0.6-((float)mt[xt]/4100.00))*16.00;
        delay_us(10);
    }    
        arm_cfft_f32(&arm_cfft_sR_f32_len1024, testInput_f32_10khz, ifftFlag, doBitReverse);
        arm_cmplx_mag_f32(testInput_f32_10khz, testOutput, fftSize);
        arm_max_f32(testOutput, fftSize, &maxValue, &testIndex);
        maxi = maxValue;
        printf("Maxi %d test Index %d\n",maxi,testIndex);

      if(testIndex>=990)
      {
         printf("Voice\n");
      }
      if(testIndex<990)
      {
         printf("No Voice\n");
      }
        
}

 

Please find above code in detail

the output value testindex is giving zero even the voice is generated form external source.

The same code is working with Sam4SD32C now i m just changing the controller to Sam4S2A and trying to execute.

 

 

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

That makes more sense (except for the bad indent) but still, where is the mt array from?

/Lars

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

int mt[2048];

 

mt is getting values from the mems connected to the ADC channel.

 

when ever voice is detected externally these mems it will generate the values.