Skip to main content
Visitor II
November 27, 2021
Solved

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?

  • November 27, 2021
  • 3 replies
  • 1475 views

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?

    This topic has been closed for replies.
    Best answer by waclawek.jan

    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

    3 replies

    Super User
    November 28, 2021

    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

    Graduate II
    November 28, 2021

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

    Super User
    November 28, 2021

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

    JW

    Visitor II
    June 20, 2024

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

    AP.10Author
    Visitor II
    November 28, 2021

    Thank you both! That was very useful