cancel
Showing results for 
Search instead for 
Did you mean: 

What is a good approach to measure the time it takes to receive each I2S sample when using DMA from a CODEC into my STMF446 when using interrupt callbacks?

AP.10
Associate II

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?

1 ACCEPTED SOLUTION

Accepted Solutions

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

View solution in original post

5 REPLIES 5

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

MM..1
Chief III

I dont see idea why measure one sample, I2S is precise synchronous data transfer, then time is equal to bitclock x numbits.

Here, the mcu is I2S slave, so there are legitimate reasons to measure sampling time relative to the mcu clock.

JW

AP.10
Associate II

Thank you both! That was very useful

Do I still have to setup
hi2s1.Init.AudioFreq = I2S_AUDIOFREQ_192K;
when STM is slave? (no MCLK is provided, only BCLK)