Skip to main content
crackl1ng
Associate III
April 26, 2022
Solved

Frequency is slightly shifted with microphone SPH0641 and DFSDM

Hello STM32-Community,

I'm currently using the SPH0641 Microphone alongside DFSDM. My DFSDM settings are:

Sinc filter: Sinc 3 Filter

IOSR: 8

Divider = 79

FOSR = 37

with a clock frequency of 48 MHz and as a clocksource for DFSDM I've a sample rate of about 2052 Hz.

After collecting 4096 datasets I'm doing a 4096-FFT to get the main frequencies of the audio signal. I'm using a sound generator to generate sound in any frequency. On the following image you can see, that the frequency of 500 Hz simulated by me and it isn't correctly displayed by the collected data of the DFSDM. I've also done an FFT with the raw microphone data and also get a main frequency of about 504 Hz after doing an FFT with Matlab.0693W00000Lz3WLQAZ.png 

And this error is increasing by about 0.7 Hz every 100 Hz. Eg with 100 Hz sound I receive a mainfrequency of about 100.69 Hz. At 200, it's 201.39 Hz. At 300 Hz it is 302.58 and so on. The bigger the frequency, the higher the discrepancy between simulated sound and measured one.

Edit: I checked how long the micro controller takes to collect 4096 data samples. Expected is a time of about 1.996 seconds (4096/2052). Measuring it with a Logic Analyzer returns about 2.013 seconds, while a 1 ms-Tick counter returns 1996. Why is there such a big discrepancy?

Anyone knows what I'm doing wrong?

Kind regards

This topic has been closed for replies.
waclawek.jan
waclawek.janBest answer
Super User
April 26, 2022

MSI in 'L4+ has a factory error of +-1.3% at normal VCC/temperature:

0693W00000Lz6n5QAB.pngYou are experiencing a 0.7% error. It's normal.

Use HSE/crystal for better precision.

JW

5 replies

crackl1ng
crackl1ngAuthor
Associate III
April 26, 2022

-

waclawek.jan
Super User
April 26, 2022

Which STM32?

> with a clock frequency of 48 MHz

What's the primary clock source?

RC oscillators are not precise.

JW

crackl1ng
crackl1ngAuthor
Associate III
April 26, 2022

I'm using STM32L4R9 with MSI as a clock source. DFSDM-clock also uses the system clock.

waclawek.jan
waclawek.janBest answer
Super User
April 26, 2022

MSI in 'L4+ has a factory error of +-1.3% at normal VCC/temperature:

0693W00000Lz6n5QAB.pngYou are experiencing a 0.7% error. It's normal.

Use HSE/crystal for better precision.

JW

crackl1ng
crackl1ngAuthor
Associate III
April 26, 2022

Thank you very much!