完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
只想采集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();}} |
|
相关推荐
2个回答
|
|
接的数字麦克风么?
不能把 DFSDM 的输出时钟降那么低,否则数字麦克风可能不工作。你想限制带宽的话,DFSDM 采进来降采样之后(比如CKOUT 3.072MHz, 64倍降采样到48kHz PCM),再自己用软件做FIR低通,再做降采样。 |
|
|
|
为了配置DFSDM以采集20-2000Hz的音频信号,我们需要考虑以下几个关键参数:
1. DFSDM的采样率(Sampling Rate) 2. 滤波器的截止频率(Filter Cutoff Frequency) 3. 滤波器的过采样率(Filter Oversampling Ratio) 首先,我们需要确定DFSDM的采样率。根据奈奎斯特定理,为了准确采集20-2000Hz的音频信号,采样率至少应该是信号最高频率的两倍,即4000Hz。但是,为了获得更好的信噪比和抗混叠性能,我们可以选择更高的采样率。在这个例子中,我们使用44.1kHz的采样率。 接下来,我们需要配置滤波器的截止频率。截止频率应该高于信号的最高频率,以确保信号的所有成分都能通过滤波器。在这个例子中,我们选择2200Hz作为滤波器的截止频率。 最后,我们需要设置滤波器的过采样率。过采样率是采样率与滤波器截止频率的比值。在这个例子中,过采样率应该为: Oversampling Ratio = Sampling Rate / Cutoff Frequency Oversampling Ratio = 44100Hz / 2200Hz ≈ 20 现在,我们可以根据这些参数配置DFSDM。以下是修改后的代码: ```c 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_SYSTEM; DfsdmChannelHandle.Init.Input.Multiplexer = DFSDM_CHANNEL_EXTERNAL_INPUTS; DfsdmChannelHandle.Init.Input.DataPacking = DFSDM_CHANNEL_STANDARD_MODE; 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_SINC1_ORDER; DfsdmChannelHandle.Init.Awd.Oversampling = 10; // Adjust this value if needed DfsdmChannelHandle.Init.Offset = 0; DfsdmChannelHandle.Init.RightBitShift = 0; HAL_DFSDM_ChannelInit(&DfsdmChannelHandle); /* Configure the filter */ 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; DfsdmFilterHandle.Init.InjectedParam.ScanMode = DISABLE; DfsdmFilterHandle.Init.InjectedParam.DmaMode = DISABLE; DfsdmFilterHandle.Init.InjectedParam.ExtTrigger = DFSDM_FILTER_EXT_TRIG_TIM8_TRGO; DfsdmFilterHandle.Init.InjectedParam.ExtTriggerEdge = DFSDM_FILTER_EXT_TRIG_RISING_EDGE; DfsdmFilterHandle.Init.FilterParam.SincOrder = DFSDM_FILTER_SINC3_ORDER; DfsdmFilterHandle.Init.FilterParam.Oversampling = 1; // Adjust this value to achieve the desired oversampling ratio DfsdmFilterHandle.Init.FilterParam.IntOversampling = 20; // Set the oversampling ratio HAL_DFSDM_FilterInit(&DfsdmFilterHandle); /* Configure the DFSDM clock */ HAL_RCCEx_PeriphCLKConfig(&PeriphClkInit); } ``` 请注意,您可能需要根据实际硬件和项目需求调整代码中的一些参数。 |
|
|
|
只有小组成员才能发言,加入小组>>
调试STM32H750的FMC总线读写PSRAM遇到的问题求解?
1750 浏览 1 评论
X-NUCLEO-IHM08M1板文档中输出电流为15Arms,15Arms是怎么得出来的呢?
1608 浏览 1 评论
1049 浏览 2 评论
STM32F030F4 HSI时钟温度测试过不去是怎么回事?
721 浏览 2 评论
ST25R3916能否对ISO15693的标签芯片进行分区域写密码?
1665 浏览 2 评论
1924浏览 9评论
STM32仿真器是选择ST-LINK还是选择J-LINK?各有什么优势啊?
709浏览 4评论
STM32F0_TIM2输出pwm2后OLED变暗或者系统重启是怎么回事?
559浏览 3评论
583浏览 3评论
stm32cubemx生成mdk-arm v4项目文件无法打开是什么原因导致的?
544浏览 3评论
小黑屋| 手机版| Archiver| 电子发烧友 ( 湘ICP备2023018690号 )
GMT+8, 2024-12-18 10:10 , Processed in 0.694709 second(s), Total 50, Slave 43 queries .
Powered by 电子发烧友网
© 2015 bbs.elecfans.com
关注我们的微信
下载发烧友APP
电子发烧友观察
版权所有 © 湖南华秋数字科技有限公司
电子发烧友 (电路图) 湘公网安备 43011202000918 号 电信与信息服务业务经营许可证:合字B2-20210191 工商网监 湘ICP备2023018690号