FFT filter code for Sam4s2a

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.

Parents
  • Hello Andy,

    Please find below 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 tying to execute.

    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");
          }
            
    }
    the code.

Reply Children
More questions in this forum