cancel
Showing results for 
Search instead for 
Did you mean: 

Synchronising I2S reception with LSE

gregstm
Senior III

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 = ....

1 ACCEPTED SOLUTION

Accepted Solutions

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.

View solution in original post

5 REPLIES 5
Piranha
Chief II

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
Senior III

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
Senior III

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

and what was the issue?

To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.

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.