只想采集20-2000Hz以内的音频信号改怎么配置DFSDM,配置44.1K代码如下:void DFSDM_Init(void){/* Initialize channel 2 */__HAL_DFSDM_CHANNEL_RESET_HANDLE_STATE(&DfsdmChannelHandle);DfsdmChannelHandle.Instance = DFSDM1_Channel2;DfsdmChannelHandle.Init.OutputClock.Activation = ENABLE;DfsdmChannelHandle.Init.OutputClock.Selection = DFSDM_CHANNEL_OUTPUT_CLOCK_AUDIO;DfsdmChannelHandle.Init.OutputClock.Divider = 4; /* 11.294MHz/4 = 2.82MHz */DfsdmChannelHandle.Init.Input.Multiplexer = DFSDM_CHANNEL_EXTERNAL_INPUTS;DfsdmChannelHandle.Init.Input.DataPacking = DFSDM_CHANNEL_STANDARD_MODE; /* N.U. */DfsdmChannelHandle.Init.Input.Pins = DFSDM_CHANNEL_SAME_CHANNEL_PINS;DfsdmChannelHandle.Init.SerialInterface.Type = DFSDM_CHANNEL_SPI_RISING;DfsdmChannelHandle.Init.SerialInterface.SpiClock = DFSDM_CHANNEL_SPI_CLOCK_INTERNAL;DfsdmChannelHandle.Init.Awd.FilterOrder = DFSDM_CHANNEL_FASTSINC_ORDER; /* N.U. */DfsdmChannelHandle.Init.Awd.Oversampling = 10; /* N.U. */DfsdmChannelHandle.Init.Offset = 0;DfsdmChannelHandle.Init.RightBitShift =0;if(HAL_OK != HAL_DFSDM_ChannelInit(&DfsdmChannelHandle)){Error_Handler();}/* Initialize filter 0 */__HAL_DFSDM_FILTER_RESET_HANDLE_STATE(&DfsdmFilterHandle);DfsdmFilterHandle.Instance = DFSDM1_Filter0;DfsdmFilterHandle.Init.RegularParam.Trigger = DFSDM_FILTER_SW_TRIGGER;DfsdmFilterHandle.Init.RegularParam.FastMode = ENABLE;DfsdmFilterHandle.Init.RegularParam.DmaMode = ENABLE;DfsdmFilterHandle.Init.InjectedParam.Trigger = DFSDM_FILTER_SW_TRIGGER; /* N.U. */DfsdmFilterHandle.Init.InjectedParam.ScanMode = ENABLE; /* N.U. */DfsdmFilterHandle.Init.InjectedParam.DmaMode = DISABLE; /* N.U. */DfsdmFilterHandle.Init.InjectedParam.ExtTrigger = DFSDM_FILTER_EXT_TRIG_TIM1_TRGO; /* N.U. */DfsdmFilterHandle.Init.InjectedParam.ExtTriggerEdge = DFSDM_FILTER_EXT_TRIG_RISING_EDGE; /* N.U. */DfsdmFilterHandle.Init.FilterParam.SincOrder =DFSDM_FILTER_SINC3_ORDER;DfsdmFilterHandle.Init.FilterParam.Oversampling = 64; /* 11.294MHz/(4*64) = 44.1KHz */DfsdmFilterHandle.Init.FilterParam.IntOversampling = 1;if(HAL_OK != HAL_DFSDM_FilterInit(&DfsdmFilterHandle)){Error_Handler();}/* Configure regular channel and continuous mode for filter 0 */if(HAL_OK != HAL_DFSDM_FilterConfigRegChannel(&DfsdmFilterHandle, DFSDM_CHANNEL_2, DFSDM_CONTINUOUS_CONV_ON)){Error_Handler();}} |
不能把 DFSDM 的输出时钟降那么低,否则数字麦克风可能不工作。你想限制带宽的话,DFSDM 采进来降采样之后(比如CKOUT 3.072MHz, 64倍降采样到48kHz PCM),再自己用软件做FIR低通,再做降采样。