AnsweredAssumed Answered

use dfsdm with parallel  input

Question asked by ll.hgyxb on Mar 11, 2018
Latest reply on Mar 12, 2018 by ll.hgyxb

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;

Outcomes