Zephyr USB Audio to I2S Rate Adaption - connecting downlink USB ISOCH audio source to nRF52840 I2S TX

Hello,

Could someone advice how the Zephyr I2S (i2s_nrfx.c) modules or Nordic Module (nrfx_i2s.c) should be used to I2S TX a USB ISOCH stream (1msec), when the 2 rates (USB source and I2S TX destination) drift with respect to each other?  

Previously, I have handled this with drop/insert techniques on ring buffers.  However the Zephyr/Nordic implemented I2S driver has FIXED buffer sizes which makes this type of technique difficult with low latency.

I guess I am looking for information on how to use the Zephyr / Nordic I2S driver (as written) with USB ISOCH when the source/destination clocks are drifting WRT each other.  The problem is exacerbated if the nRF52840 is used as the I2S master - then the USB source rate is 48Khz and the I2S TX rate is 47.619kHz.

Notes.

- The nrf52840 was chosen for the product because it is cheaper than the nrf5340.

- The nRF52840 has no adjustable Audio clock (nrf5340 has the adjustable HF Audio clock)

- With the nRF52840 I2S in Master mode it has limited capability to meet different Audio rates e.g 48KHz can only be achieved with a MCLK = SCK = 1523809 Hz, LRCLK=47619 Hz (0.8% error). This makes the problem much harder.

- With the nRF52840 in Slave mode and using a HW CODED that can generate 48kHz, we will still have the clock drift problem.

- We are not fixed at a 48kHz audio rate, I can use any of the following rates - but which ever I chose the clock drift issue will still be present.

    16,  // 0x01: 8kHz  1 Channel 16 bits
    32,  // 0x02: 8kHz  2 Channel 16 bits
    24,  // 0x03: 12kHz 1 Channel 16 bits
    24,  // 0x04: 12kHz 2 Channel 16 bits
    32,  // 0x05: 16kHz 1 Channel 16 bits
    64,  // 0x06: 16kHz 2 Channel 16 bits
    40,  // 0x07: 20kHz 1 Channel 16 bits
    80,  // 0x08: 20kHz 2 Channel 16 bits
    48,  // 0x09: 24kHz 1 Channel 16 bits
    96,  // 0x0A: 24kHz 2 Channel 16 bits
    64,  // 0x0B: 32kHz 1 Channel 16 bits
    128, // 0x0C: 32kHz 2 Channel 16 bits
    80,  // 0x0D: 40kHz 1 Channel 16 bits
    160, // 0x0E: 40kHz 2 Channel 16 bits
    96,  // 0x0F: 48kHz 1 Channel 16 bits
    192, // 0x10: 48kHz 2 Channel 16 bits

Any help appreciated.

Regards

Wayne

Related