资源简介

这个程序是一个stm32F407的3个ADC进行交替转换,ADC采样率达到最大8.4Msps,连续采样,采样之后采用cortex-M4内部的dsp和fpu单元进行快速的复杂傅里叶变换,通过串口打印输入信号的波形和cfft运算后的结果

资源截图

代码片段和文件信息

#include “stm32f4xx.h“
#include 

void GPIO_Configuration(void)
{
GPIO_InitTypeDef      GPIO_InitStructure;

RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOC ENABLE);

GPIO_InitStructure.GPIO_Pin = GPIO_Pin_2;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AN;
GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL ;
GPIO_Init(GPIOC &GPIO_InitStructure);
}

#define ADC_CDR_ADDRESS    ((uint32_t)0x40012308) //ADC_DCR寄存器基地址
u32 ADCTripleConvertedValue[515]; //很奢侈的分配4K作为ADC采样1024的数据存放位置

void DMA_Configuration(void)
{
   DMA_InitTypeDef       DMA_InitStructure;

RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_DMA2 ENABLE);

DMA_InitStructure.DMA_Channel = DMA_Channel_0;       //通道设置
DMA_InitStructure.DMA_PeripheralbaseAddr = (uint32_t)ADC_CDR_ADDRESS; //外设基地址
DMA_InitStructure.DMA_Memory0baseAddr = (uint32_t)&ADCTripleConvertedValue; //内存基地址
DMA_InitStructure.DMA_DIR = DMA_DIR_PeripheralToMemory; //外设到内存的传输
DMA_InitStructure.DMA_BufferSize = 515; //传输次数 1
DMA_InitStructure.DMA_PeripheralInc = DMA_PeripheralInc_Disable; //外设地址增加失能
DMA_InitStructure.DMA_MemoryInc = DMA_MemoryInc_Enable; //内存地址增加失能
DMA_InitStructure.DMA_PeripheralDataSize = DMA_PeripheralDataSize_Word; //DMA外设半字节传输
DMA_InitStructure.DMA_MemoryDataSize = DMA_MemoryDataSize_Word; //DMA内存半字节传输
DMA_InitStructure.DMA_Mode = DMA_Mode_Normal; //DMA工作于循环模式
DMA_InitStructure.DMA_Priority = DMA_Priority_High; //高优先级运行
DMA_InitStructure.DMA_FIFOMode = DMA_FIFOMode_Disable;    //失能FIFO模式      
DMA_InitStructure.DMA_FIFOThreshold = DMA_FIFOThreshold_HalfFull; //fifo阈值半字节
DMA_InitStructure.DMA_MemoryBurst = DMA_MemoryBurst_Single; //内存单次突发传输
DMA_InitStructure.DMA_PeripheralBurst = DMA_PeripheralBurst_Single; //外设单次突发传输
DMA_Init(DMA2_Stream0 &DMA_InitStructure);

DMA_ITConfig(DMA2_Stream0DMA_IT_TCENABLE);
   DMA_Cmd(DMA2_Stream0 ENABLE);
}

void NVIC_Configuration(FunctionalState NewState)
{
   NVIC_InitTypeDef NVIC_InitStructure;

NVIC_InitStructure.NVIC_IRQChannel = DMA2_Stream0_IRQn;
NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 0;
NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0;
NVIC_InitStructure.NVIC_IRQChannelCmd = NewState;
NVIC_Init(&NVIC_InitStructure);
}

void ADC_Configuration(void)
{
ADC_InitTypeDef       ADC_InitStructure;
ADC_CommonInitTypeDef ADC_CommonInitStructure;

RCC_APB2PeriphClockCmd(RCC_APB2Periph_ADC1|RCC_APB2Periph_ADC2|RCC_APB2Periph_ADC3 ENABLE);

ADC_CommonInitStructure.ADC_Mode = ADC_TripleMode_Interl;
ADC_CommonInitStructure.ADC_TwoSamplingDelay = ADC_TwoSamplingDelay_5Cycles;
ADC_CommonInitStructure.ADC_DMAAccessMode = ADC_DMAAccessMode_2;   //DMA传输模式1
ADC_CommonInitStructure.ADC_Prescaler = ADC_Prescaler_Div2;  //ADC时钟为APB2/2
ADC_CommonInit(&ADC_CommonInitStructure);

ADC_InitStructure.ADC_Resolution = ADC_Resolution_12b;
   ADC_InitStructure.ADC_ScanConvMode 

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----
     目录           0  2012-07-10 09:34  three_adcs_cfft\
     文件      343738  2012-07-10 09:34  three_adcs_cfft\BlankPrj.uvgui.laoyl
     文件      342429  2012-07-09 14:10  three_adcs_cfft\BlankPrj.uvgui_laoyl.bak
     文件       33420  2012-07-10 09:34  three_adcs_cfft\BlankPrj.uvopt
     文件       22611  2012-07-05 00:22  three_adcs_cfft\BlankPrj.uvproj
     文件       33418  2012-07-09 14:10  three_adcs_cfft\BlankPrj_uvopt.bak
     目录           0  2012-07-10 09:34  three_adcs_cfft\Debug\
     文件         280  2012-07-10 09:34  three_adcs_cfft\Debug\BlankPrj.plg
     文件         479  2011-10-20 15:08  three_adcs_cfft\Debug\BlankPrj.sct
     文件        4086  2012-07-09 13:18  three_adcs_cfft\Debug\BlankPrj.tra
     文件          19  2012-07-09 14:10  three_adcs_cfft\Debug\ExtDll.iex
     目录           0  2012-07-05 22:24  three_adcs_cfft\lib\
     文件     9654196  2011-07-26 17:34  three_adcs_cfft\lib\arm_cortexM4lf_math.lib
     目录           0  2012-07-05 22:24  three_adcs_cfft\Source\
     文件      240326  2011-10-04 02:48  three_adcs_cfft\Source\arm_math.h
     文件        6311  2012-07-08 02:13  three_adcs_cfft\Source\common.c
     文件         262  2012-07-08 12:07  three_adcs_cfft\Source\common.h
     文件        1282  2012-07-08 12:42  three_adcs_cfft\Source\main.c
     文件       26908  2011-09-19 17:06  three_adcs_cfft\Source\selftest.c
     文件        1800  2011-09-19 17:06  three_adcs_cfft\Source\selftest.h
     文件       29506  2011-09-09 12:25  three_adcs_cfft\Source\startup_stm32f4xx.s
     文件        3938  2012-07-07 12:17  three_adcs_cfft\Source\stm32f4xx_conf.h
     文件        5012  2012-07-08 12:12  three_adcs_cfft\Source\stm32f4xx_it.c
     文件        2067  2011-09-19 17:07  three_adcs_cfft\Source\stm32f4xx_it.h
     文件         918  2012-06-29 13:44  three_adcs_cfft\Source\sysdelay.c
     文件         349  2012-06-29 13:46  three_adcs_cfft\Source\sysdelay.h
     文件       21471  2012-07-07 14:50  three_adcs_cfft\Source\system_stm32f4xx.c
     文件        2224  2011-09-19 17:06  three_adcs_cfft\Source\usbd_conf.h
     文件        8400  2011-09-19 17:06  three_adcs_cfft\Source\usbd_desc.c
     文件        3425  2011-09-19 17:06  three_adcs_cfft\Source\usbd_desc.h
     文件        4040  2011-09-19 17:06  three_adcs_cfft\Source\usbd_usr.c
............此处省略63个文件信息

评论

共有 条评论