2021-11-27 12:39 PM
Hi, in my current audio processing set up I have a CODEC set as master connected to my STM32F446RE (slave). The current configuration utilizes I2S DMA interrupt callbacks to handle the input and processing of these samples received. The CODEC receives an external clock signal of 12.288 MHz in order to achieve a sample rate of 48 KHz. How can I calculate the amount of time we receive every sample from the CODEC to the STM32F446?
Solved! Go to Solution.
2021-11-27 04:11 PM
DMA receives N samples. Measure time elapsed between two DMA interrupts using a timer, and divide by N. The error is given by the interrupt latency.
A more precise measurement could be taken if the LRCK (WS) signal is externally connected also to some timer input, and that timer is then used to measure period of that signal.
JW
2021-11-27 04:11 PM
DMA receives N samples. Measure time elapsed between two DMA interrupts using a timer, and divide by N. The error is given by the interrupt latency.
A more precise measurement could be taken if the LRCK (WS) signal is externally connected also to some timer input, and that timer is then used to measure period of that signal.
JW
2021-11-28 02:40 AM
I dont see idea why measure one sample, I2S is precise synchronous data transfer, then time is equal to bitclock x numbits.
2021-11-28 03:30 AM
Here, the mcu is I2S slave, so there are legitimate reasons to measure sampling time relative to the mcu clock.
JW
2021-11-28 01:11 PM
Thank you both! That was very useful
2024-06-20 07:01 AM
Do I still have to setup
hi2s1.Init.AudioFreq = I2S_AUDIOFREQ_192K;
when STM is slave? (no MCLK is provided, only BCLK)