2018-03-11 08:38 AM
Hi,
I have get pdm data and want to use dfsdm to convert to PCM.
The test code is like below:
HAL_DFSDM_FilterRegularStart(&hdfsdm1_filter0);
uint16_t *pdm_data=... for (int i=0;i<pdm_size;i++) { hdfsdm1_channel1.Instance->CHDATINR = pdm_data[i]; ret = HAL_DFSDM_FilterPollForRegConversion(&hdfsdm1_filter0, 5); if(ret == HAL_OK){ printf('%d:', i); pcm_data = HAL_DFSDM_FilterGetRegularValue(&hdfsdm1_filter0, &channel); printf('filter value: %d, channel:%d\n', pcm_data, channel); HAL_DFSDM_FilterRegularStart(&hdfsdm1_filter0); } }I think when i =4 ,the
HAL_DFSDM_FilterGetRegularValue can get ok.
Because I set Oversampling=64, SincOrder =DFSDM_FILTER_SINC3_ORDER, so 4*16=64 bit can filter a 16 bit pcm value.
But the real is when i=196, the filter have the result.
when use DFSDM_FILTER_SINC2_ORDER, the i=131.
when use
DFSDM_FILTER_SINC1_ORDER, the i=66.
How dose it work? how many pdm bit to one pcm value when use the config?
The filter config:
hdfsdm1_filter0.Instance = DFSDM1_Filter0;
hdfsdm1_filter0.Init.RegularParam.Trigger = DFSDM_FILTER_SW_TRIGGER; hdfsdm1_filter0.Init.RegularParam.FastMode = ENABLE; hdfsdm1_filter0.Init.RegularParam.DmaMode = DISABLE; hdfsdm1_filter0.Init.FilterParam.SincOrder = DFSDM_FILTER_SINC3_ORDER; hdfsdm1_filter0.Init.FilterParam.Oversampling = 64; hdfsdm1_filter0.Init.FilterParam.IntOversampling = 1;The channel config:
hdfsdm1_channel1.Instance = DFSDM1_Channel1;
hdfsdm1_channel1.Init.OutputClock.Activation = DISABLE; hdfsdm1_channel1.Init.OutputClock.Selection = DFSDM_CHANNEL_OUTPUT_CLOCK_SYSTEM; hdfsdm1_channel1.Init.OutputClock.Divider = 50; hdfsdm1_channel1.Init.Input.Multiplexer = DFSDM_CHANNEL_INTERNAL_REGISTER; hdfsdm1_channel1.Init.Input.DataPacking = DFSDM_CHANNEL_STANDARD_MODE; hdfsdm1_channel1.Init.Input.Pins = DFSDM_CHANNEL_SAME_CHANNEL_PINS; hdfsdm1_channel1.Init.SerialInterface.Type = DFSDM_CHANNEL_SPI_RISING; hdfsdm1_channel1.Init.SerialInterface.SpiClock = DFSDM_CHANNEL_SPI_CLOCK_EXTERNAL; hdfsdm1_channel1.Init.Awd.FilterOrder = DFSDM_CHANNEL_FASTSINC_ORDER; hdfsdm1_channel1.Init.Awd.Oversampling = 1; hdfsdm1_channel1.Init.Offset = 0x00; hdfsdm1_channel1.Init.RightBitShift = 0;2018-03-11 04:20 PM
I don't understand your question, but maybe you should know that the parallel input is not PDM but regular PCM. Only the serial input - through pin - is PDM.
JW
2018-03-12 05:15 AM
The reference manual said:
This digital data stream is sent into a DFSDM input
channel through a serial interface. DFSDM supports several standards to connect various Σ∆ modulator outputs: SPI interface and Manchester coded 1-wire interface (both with adjustable parameters). DFSDM module supports the connection of up to 8 multiplexed input digital serial channels which are shared with up to 4 DFSDM modules. DFSDM module also supports alternative parallel data inputs from up to 8 internal 16-bit data channels (from microcontrollers memory).So I think
parallel data inputs is same as SPI interface or Manchester coded 1-wire interface.
PDM to PCM can use SPI, So I think parallel can also used to convert PDM to PCM.