I am trying to build something and currently doing some evaluation and development with 32L476GDISCOVERY Discovery Kit with STM32L476VG microcontroller.
What I am trying to achieve at the moment is output of integrated MEMS microphone into a buffer via DMA.
Everything seems to be working perfectly except for one, for me quite important, thing - the resolution of the samples is much higher then I expect. But I need the target buffer to be array of half words (16bits).
Setup I am trying:
DFSDM input clock frequency: 24MHz
Output clock divider: 8 (it means 24/8 = 3Mhz for MEMS microphone)
Filter is using regular conversion
Filter order: 2 (Sinc2)
Continuous mode: ENABLED
DMA Mode: ENABLED
Filter oversampling (Fosr): 73 (=> output sample rate = 3MHz/73 = 41095Hz - almost 41.1kHz)
Integrator oversampling (Iosr): 1
According to Reference Manual of STM32L4x6, where table 124 on page 621 (chapter 21.2.8 Digital filter configuration) defines how to compute maximum output resolution, I should be getting something between +/- 73^2 = +/- 5329. But I am getting much higher numbers.
Small example of data I am getting: 19200, 16640, 17152, 14080, 14592, 12544, 10496, 11008, 7424, 6400, 6912, 4864,2304, 2304, -256, 768, -768, -2816, -2304, -3328, -1792
They are obviously bigger than +/-5329.
Does somebody have any idea why it could be happening?
I know I can for example use bit shift to align it to size I require, but since it does not behave as expected, I am afraid I am doing something completely wrong. If I decide to use bit shift I am also not sure what number I should use, since I do not know what can be the peak value of my filter output at the moment.
My filter and channel initialization procedure:
hdfsdm1_filter1.Instance = DFSDM1_Filter1;
hdfsdm1_filter1.Init.RegularParam.Trigger = DFSDM_FILTER_SW_TRIGGER;
hdfsdm1_filter1.Init.RegularParam.FastMode = ENABLE;
hdfsdm1_filter1.Init.RegularParam.DmaMode = ENABLE;
hdfsdm1_filter1.Init.FilterParam.SincOrder = DFSDM_FILTER_SINC2_ORDER;
hdfsdm1_filter1.Init.FilterParam.Oversampling = 73;
hdfsdm1_filter1.Init.FilterParam.IntOversampling = 1;
hdfsdm1_channel2.Instance = DFSDM1_Channel2;
hdfsdm1_channel2.Init.OutputClock.Activation = ENABLE;
hdfsdm1_channel2.Init.OutputClock.Selection = DFSDM_CHANNEL_OUTPUT_CLOCK_SYSTEM;
hdfsdm1_channel2.Init.OutputClock.Divider = 8;
hdfsdm1_channel2.Init.Input.Multiplexer = DFSDM_CHANNEL_EXTERNAL_INPUTS;
hdfsdm1_channel2.Init.Input.DataPacking = DFSDM_CHANNEL_STANDARD_MODE;
hdfsdm1_channel2.Init.Input.Pins = DFSDM_CHANNEL_SAME_CHANNEL_PINS;
hdfsdm1_channel2.Init.SerialInterface.Type = DFSDM_CHANNEL_SPI_RISING;
hdfsdm1_channel2.Init.SerialInterface.SpiClock = DFSDM_CHANNEL_SPI_CLOCK_INTERNAL;
hdfsdm1_channel2.Init.Awd.FilterOrder = DFSDM_CHANNEL_FASTSINC_ORDER;
hdfsdm1_channel2.Init.Awd.Oversampling = 1;
hdfsdm1_channel2.Init.Offset = 0;
hdfsdm1_channel2.Init.RightBitShift = 0x00;
Thank you for your advice