AnsweredAssumed Answered

PROBLEM WITH FFT ON STM32F4

Question asked by eini.reza on Dec 11, 2015
Latest reply on Dec 12, 2015 by Clive One
I'm going to apply FFT on 512 sized array captured from ADC
BUT as soon as i add libraries like "arm_math.h"or "ARMCM4.h" i get bunch of errors
here is my code
please someone kindly help me im running out of time
I attached files

////////////////////////////////////////////////////////////////////

#include "stm32f4xx.h"
#include "system_stm32f4xx.h"
#include "tm_stm32f4_hd44780.h"
#include "stm32f4xx_tim.h"
#include "stm32f4xx_rcc.h"
#include "stdlib.h"
#include "stm32f4xx_gpio.h"
#include "defines.h"
#include "arm_math.h"
#include "arm_const_structs.h"
#include "math_helper.h"
#include "system_ARMCM4.h"
#include "stm32f4xx_adc.h"
#include "stm32f4xx_dma.h"
#include "tm_stm32f4_adc.h"
#include "tm_stm32f4_delay.h"
#include "tm_stm32f4_gpio.h"
#include "stdio.h"
#define rezabuffer0 [1024]
 
uint16_t rezareadadc(ADC_TypeDef* ADCx, uint8_t channel) {
    int i1;
    ADC_RegularChannelConfig(ADCx, channel, 0, ADC_SampleTime_15Cycles);
    ADC_RegularChannelConfig(ADCx, channel, 1, ADC_SampleTime_15Cycles);
    ADC_SoftwareStartConv(ADCx);
     
    /* Wait till done */
    while (ADC_GetFlagStatus(ADCx, ADC_FLAG_EOC) == RESET);
     
    /* Return result */
    return ADC_GetConversionValue(ADCx);
}
int rezafft(){
 
}
void rezapinsled()
{
      GPIO_InitTypeDef GPIO_InitStructure;
      GPIO_InitTypeDef gpioStructure;
    RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOD, ENABLE);
    gpioStructure.GPIO_Pin = GPIO_Pin_12 | GPIO_Pin_13;
    gpioStructure.GPIO_Mode = GPIO_Mode_OUT;
    gpioStructure.GPIO_Speed = GPIO_Speed_50MHz;
    GPIO_Init(GPIOD, &gpioStructure);
    // GPIO_WriteBit(GPIOD, GPIO_Pin_12 | GPIO_Pin_13, Bit_RESET);
}
void rezapinsadc(){
    GPIO_InitTypeDef GPIO_InitStructure;
      GPIO_InitTypeDef gpioStructure;
     RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOA, ENABLE);
    
     GPIO_InitStructure.GPIO_Pin = GPIO_Pin_0 | GPIO_Pin_1/* |GPIO_Pin_2 | GPIO_Pin_3
    | GPIO_Pin_5 | GPIO_Pin_6*/;
  GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AN;
  GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL;
  GPIO_Init(GPIOA, &GPIO_InitStructure);
}
  
void rezatimer()
{
      TIM_TimeBaseInitTypeDef timerInitStructure;
    RCC_APB1PeriphClockCmd(RCC_APB1Periph_TIM7, ENABLE);
  
     
    timerInitStructure.TIM_Prescaler = 4200;
    timerInitStructure.TIM_CounterMode = TIM_CounterMode_Up;
    timerInitStructure.TIM_Period = 5;
    timerInitStructure.TIM_ClockDivision = TIM_CKD_DIV1;
    timerInitStructure.TIM_RepetitionCounter = 0;
    TIM_TimeBaseInit(TIM7, &timerInitStructure);
    TIM_Cmd(TIM7, ENABLE);
         
TIM_ITConfig(TIM7, TIM_IT_Update, ENABLE);
}
 int rezaintrrupt(){
 NVIC_InitTypeDef nvicStructure;
    nvicStructure.NVIC_IRQChannel = TIM7_IRQn;
    nvicStructure.NVIC_IRQChannelPreemptionPriority = 0;
    nvicStructure.NVIC_IRQChannelSubPriority = 0;
    nvicStructure.NVIC_IRQChannelCmd = ENABLE;
    NVIC_Init(&nvicStructure);
}
void rezaadcconfg(void)
{
     
    ADC_InitTypeDef       ADC_InitStructure;
  ADC_CommonInitTypeDef ADC_CommonInitStructure;
    RCC_APB2PeriphClockCmd(RCC_APB2Periph_ADC1, ENABLE);
 ADC_CommonInitStructure.ADC_Mode = ADC_Mode_Independent;
  ADC_CommonInitStructure.ADC_Prescaler = ADC_Prescaler_Div2;
  ADC_CommonInitStructure.ADC_DMAAccessMode = ADC_DMAAccessMode_Disabled;
  ADC_CommonInitStructure.ADC_TwoSamplingDelay = ADC_TwoSamplingDelay_5Cycles;
  ADC_CommonInit(&ADC_CommonInitStructure);
   
  /* ADC1 Init ****************************************************************/
  ADC_InitStructure.ADC_Resolution = ADC_Resolution_6b;
  ADC_InitStructure.ADC_ScanConvMode = ENABLE;
  ADC_InitStructure.ADC_ContinuousConvMode = ENABLE;
  ADC_InitStructure.ADC_ExternalTrigConvEdge = ADC_ExternalTrigConvEdge_None;
  ADC_InitStructure.ADC_ExternalTrigConv = ADC_ExternalTrigConv_T1_CC1;
  ADC_InitStructure.ADC_DataAlign = ADC_DataAlign_Right;
  ADC_InitStructure.ADC_NbrOfConversion = 1;
 
}
 
 
 
int main()
{
    int j=0,i=0;
    int VA[1024];
    int IA[1024];
     rezapinsled();
       rezapinsadc();
     rezatimer();
     rezaintrrupt();
     rezaadcconfg();
     
         while (1){
            if (TIM_GetITStatus(TIM2, TIM_IT_Update) != RESET)
    {
            TIM_ClearITPendingBit(TIM2, TIM_IT_Update);
         
                if (i<1025){
                    VA[i]=rezareadadc(ADC1,0);
                    IA[i]=rezareadadc(ADC1,1);
                    i++;
                }
             
        
}
             
}
}


Attachments

Outcomes