Skip to main content
gregstm
Senior II
Aug 9, 2019 2:12 PM UTC
Solved

Synchronising I2S reception with LSE

This is probably more of a wish list item than a question that can be solved - I'm using an STM32L4 chip's SAI to interface to an I2s microphone (SPH0645lm4h Knowles microphone). It works well.

But things would be even better if the I2s reception could be somehow synchronised to an LSE derived clock. eg. 32768Hz/2 = 16384Hz. That way I would be able to get the full accuracy of the LSE crystal for pitch analysis. Maybe there is a way but I haven't figured it out yet....

By the way, there seems to be a few errors in the SAI section of the Reference manual eg. in the register section, I think Fsck_x = Fsai_x_ker_ck / MCKDIV x 2 should be Fmclk = ....

This topic has been closed for replies.
gregstm
gregstmBest answer
Senior II
Sep 29, 2019 11:44 AM UTC

what was the silly mistake? unfortunately I can't remember now. I write direct to registers for all my software, so it is easy to make silly typo/initialisation mistakes (but I enjoy the compactness, simplicity and freedom of this method). I can now detect a pitch with 0.2 Hertz accuracy using my FHT routine - so I'm very happy with that result.

5 replies

Piranha
Principal III
Aug 10, 2019 6:48 AM UTC

Well, the PLL doesn't work with such a low frequencies as LSE have, therefore HSE must be used if accuracy is needed. Is this wish because You want to run on HSI/MSI without that HSE crystal?

gregstm
gregstmAuthor
Senior II
Aug 11, 2019 10:49 AM UTC

I may eventually have to resort to using the HSE, I was trying to avoid that ... but I had a cunning plan of managing with the LSE alone -

  • I would run the microphone at a higher sample rate of ~62.5KHz (HSI16 derived) and DMA that result to a single 32 bit location
  • I would then use an LSE driven timer to DMA that single location above to a buffer at the precise 16384Hz rate
  • That buffer would be Low pass filtered so that I can finally downsample to my required rate of 4096Hz

Unfortunately DMAing from a single location to a buffer (step 2) doesn't seem to work. Maybe the hardware doesn't allow it or I have made a mistake in the programming... I will keep trying... must be a way

gregstm
gregstmAuthor
Senior II
Aug 12, 2019 2:04 AM UTC

...found the silly mistake that prevented my plan working - so now have a workable method of getting wave data synchronised to the LSE.

Amel NASRI
ST Technical Moderator
Sep 3, 2019 3:32 PM UTC

and what was the issue?

To give better visibility on the answered topics, please click on "Best Answer" on the reply which solved your issue or answered your question.
gregstm
gregstmAuthorBest answer
Senior II
Sep 29, 2019 11:44 AM UTC

what was the silly mistake? unfortunately I can't remember now. I write direct to registers for all my software, so it is easy to make silly typo/initialisation mistakes (but I enjoy the compactness, simplicity and freedom of this method). I can now detect a pitch with 0.2 Hertz accuracy using my FHT routine - so I'm very happy with that result.