cancel
Showing results for 
Search instead for 
Did you mean: 

DFSDM conversion resolution problem

Roman Bosák
Associate
Posted on December 08, 2016 at 22:32

Hi,

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

http://www.st.com/content/ccc/resource/technical/document/reference_manual/02/35/09/0c/4f/f7/40/03/DM00083560.pdf/files/DM00083560.pdf/jcr:content/translations/en.DM00083560.pdf

, 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

Roman

#stm32l476 #mems #discovery #problem #filter #dfsdm
2 REPLIES 2
Lawliet KG
Associate III
Posted on December 09, 2016 at 16:44

Hi

bosakrom

,

ST is providing an example about theDFSDM usage. This will surely help you to correctly configure yourperipheral.

You can find the working 'DFSDM_AudioRecord' example

inside the STM32Cube

L

4 library (v 1.6.0)

at this path:

STM32Cube_FW_L4_V1.6.0\Projects\STM32L476G-Discovery\Examples\DFSDM\DFSDM_AudioRecord.

May this help you.

Best regards,

Lawliet

If this answers your request, please press 'correct'

🙂

Posted on December 10, 2016 at 23:10

Hi

garsi.khouloud

,

thank you very much for the quick reply.

I know about the example and tried it already before. After you mentioned it I tried it again with focus on getting same data I have for my case and it seems there is same problem. I tried to debug it and after I paused I checked RecBuff data.

According to DFSDM setup of the example:

Filter order: 3(Sinc3)

Continuous mode: ENABLED

DMA Mode: ENABLED

Filter oversampling (Fosr): 64

Integrator oversampling (Iosr): 1

Right bit shift: 2

I would expect to get resolution +/-65536 = 64^3 >> 2 (based on equations and other definitions from reference manual mentioned above)

But I again get quite different numbers.

Example data from RecBuffer:-840192,-709888,-585728,-460288,-315904,-174080,-24064,106752,237056,385536,506880,621824

As you can see, majority of the values are much higher thanexpected maximum again.

Do I overlook something? Any more ideas?

Thank you

Roman