您好,欢迎访问三七文档
当前位置:首页 > 商业/管理/HR > 信息化管理 > 基于STM32的FFT傅里叶变换
/********************(C)COPYRIGHT2010STMicroelectronics*********************FileName:ADCompute.c*Author:*Version:V1.0*Date:10/08/2007*Description:AD_Computeprogrambody*********************************************************************************THEPRESENTSOFTWAREWHICHISFORGUIDANCEONLYAIMSATPROVIDINGCUSTOMERS*WITHCODINGINFORMATIONREGARDINGTHEIRPRODUCTSINORDERFORTHEMTOSAVETIME.*ASARESULT,STMICROELECTRONICSSHALLNOTBEHELDLIABLEFORANYDIRECT,*INDIRECTORCONSEQUENTIALDAMAGESWITHRESPECTTOANYCLAIMSARISINGFROMTHE*CONTENTOFSUCHSOFTWAREAND/ORTHEUSEMADEBYCUSTOMERSOFTHECODING*INFORMATIONCONTAINEDHEREININCONNECTIONWITHTHEIRPRODUCTS.*******************************************************************************//*Includes------------------------------------------------------------------*///#includestm32f10x.h#includemain.h#includestm32f10x_usart.h#includestm32f10x_lib.h#includestm32f10x_map.h#includeplatform_config.h#includestm32f10x_nvic.h#includestm32f10x_adc.h#includestm32f10x_dma.h#includeextern.h#includestdio.h#includemath.H#defineplus10#defineplus21#defineplus32//#defineBufferSize200#defineADC1((ADC_TypeDef*)ADC1_BASE)#defineDMA1_Channel6((DMA_Channel_TypeDef*)DMA1_Channel6_BASE)//u8ch_flag[3]={0,0,0};//u8plus_state[3]={0,0,0};volatileunsignedshortintCurrent_L;//剩余电流volatileunsignedshortintADC_ValueData[224];//volatileunsignedshortintADC_ValueDataTAB[7]={0,0,0,0,0,0,0};volatileunsignedshortintAngle_Value_Data[7]={0,0,0,0,0,0,0};volatilesignedlongintzhengxuDateTab[36][7];volatilesignedlongintfuxuDateTab[36][7];//unsignedshortintADC_Value[7]={0,0,0,0,0,0,0};///////////////标识///////////////////////////////u8prun,ddj_run,qda,qdc[5],Trip,Trip2,Alarm,RLP_oweI,RLP_oweP,RLP_oweUA,RLP_oweUT;///////////////变量///////////////////////////////vs32recval3[16],e[40];vs32ss0,ss1,ss2,ss3,ss4,ss5,ss6,ss7,ss8,ss9,ss10,ss11,ss12,ss13,ss14,ss15,ss16,ss17,ss18,ss19,ss20,ss21,sss_r,sss_x,ss_dxa,ss_dxb,ss_dxc,ss_bphave,ss_bpha,ss_bphb,ss_bphc,ss_bphmax;vu8pro1,pro2,pro3,pro4,pro5,pro6,pro7,pro8,pro9,pro10,pro11,pro12,pro13,pro14,pro15,sett[FLASH_PAGE_SIZE];vu32e_im,e_105im,e_3im,e_6im,e_25im,e_1375im,pn,un;u32est_t,st_t,tfdl2,rtfdl2;vu8chn,set_num,M_num;floatTtirp,t_rgz;constsignedshortintx_Num[]={0,347,684,1000,1285,1532,1732,1879,1969,2000,1969,1879,1732,1532,1285,1000,684,347,-0,-347,-684,-1000,-1285,-1532,-1732,-1879,-1969,-2000,-1969,-1879,-1732,-1532,-1285,-1000,-684,-347};//vs16resist_temper[4];unsignedshortintSampleData(volatileunsignedshortintADCDataTab[],unsignedshortintnChannel);//constsignedshortinty_Num[]={2000,1969,1879,1732,1532,1285,1000,684,347,0,-347,-684,-1000,-1285,-1532,-1732,-1879,-1969,-2000,-1969,-1879,-1732,-1532,-1285,-1000,-684,-347,-0,347,684,1000,1285,1532,1732,1879,1969};/////////////////////////////////////////////////////////////////////////////////////////////////////////////floatCH_ComputeTab[10][7];floatUI_Parent[7];//unsignedshortintSignal_Data[7]={0,0,0,0,0,0,0};//unsignedintIA1_Value=0;//voidVoltage_Calculate(void);voidSignal_Conversion(void);voidSIG_Distribute(void);floatDifferencevalue(floatnumber);//绝对值double_squarert(doublenumber);//开方structCtrl_FlagCtrlState;structMeterage_ParameterphaseA,phaseB,phaseC;//定义测量参数/********************************************************************************FunctionName:ADC_Configuration*Description:ThisfunctionhandlesADC_Configuration*Input:None*Output:None*Return:None*******************************************************************************/voidADC_Configuration(void){ADC_InitTypeDefADC_InitStructure;/*ADC1Configuration------------------------------------------------------*/ADC_InitStructure.ADC_Mode=ADC_Mode_Independent;//独立工作模式ADC_InitStructure.ADC_ScanConvMode=ENABLE;//扫描方式ADC_InitStructure.ADC_ContinuousConvMode=ENABLE;//连续转换ADC_InitStructure.ADC_ExternalTrigConv=ADC_ExternalTrigConv_None;//外部触发禁止ADC_InitStructure.ADC_DataAlign=ADC_DataAlign_Right;//数据右对齐ADC_InitStructure.ADC_NbrOfChannel=7;//用于转换的通道数ADC_Init(ADC1,&ADC_InitStructure);/*ADC1regularchannel8configuration*///[规则模式通道配置]ADC_RegularChannelConfig(ADC1,ADC_Channel_0,4,ADC_SampleTime_239Cycles5);//IaADC_RegularChannelConfig(ADC1,ADC_Channel_1,5,ADC_SampleTime_239Cycles5);//IbADC_RegularChannelConfig(ADC1,ADC_Channel_2,6,ADC_SampleTime_239Cycles5);//IcADC_RegularChannelConfig(ADC1,ADC_Channel_3,1,ADC_SampleTime_239Cycles5);//UaADC_RegularChannelConfig(ADC1,ADC_Channel_4,2,ADC_SampleTime_239Cycles5);//UbADC_RegularChannelConfig(ADC1,ADC_Channel_5,3,ADC_SampleTime_239Cycles5);//UcADC_RegularChannelConfig(ADC1,ADC_Channel_6,7,ADC_SampleTime_239Cycles5);//Il/*Configurehighandlowanalogwatchdogthresholds*///ADC_AnalogWatchdogThresholdsConfig(ADC1,0x0B00,0x0300);/*Configurechannel8asthesingleanalogwatchdogguardedchannel*///ADC_AnalogWatchdogSingleChannelConfig(ADC1,ADC_Channel_8);/*Enableanalogwatchdogononeregularchannel*///ADC_AnalogWatchdogCmd(ADC1,ADC_AnalogWatchdog_SingleRegEnable);/*EnableAWDinterupt*///ADC_ITConfig(ADC1,ADC_IT_AWD,ENABLE);//AD中断/*EnableADC1*/ADC_Cmd(ADC1,ENABLE);/*E
本文标题:基于STM32的FFT傅里叶变换
链接地址:https://www.777doc.com/doc-5948626 .html