Set nRF5340 Audio DK as I2S slave over external bus

Hello! I am attempting to use my nRF5340 Audio DK as a gateway to broadcast audio from an external I2S source.

I have added the `CONFIG_AUDIO_SOURCE_I2S=y` line to my project .conf file as described in the README for the nrf5340_audio project.

I also have followed the instructions in this DevZone post to configure the board to use the external I2S connections on the P10 header.

The issue that I am encountering now is that the nRF board is still acting as the I2S master. The other device I want to connect I am not in control of and is configured as an I2S master. I need the nRF board to act as I2S slave and transmit the audio the other device is sending it over the Bluetooth link (in my case as a BIS broadcast). How can I configure the nRF as I2S slave?

Parents
  • Hi, 

    When you set ADK as I2S slave, you may run into the issue as my colleague's explanation in this post. It is strongly recommended to have nRF5340-gateway audio as I2S master, and your custom board can be I2S slave.

    It would be possible to configure the ADK as I2S slave, but we don't have official support for this feature now. Enabling CONFIG_AUDIO_SOURCE_I2S only switches the audio source interface from USB to I2S since that will break the drift/presentation compensation mechanism in the project. If you really want the nRF5340 gateway to run as the I2S slave (which we won't recommend). You have to modify the audio_datapath module to bypass all the compensation mechanisms, and also modify the audio_i2s module for turning the I2S from master into slave.

    Regards,
    Amanda H.

  • Hi Amanda! We've investigated a couple approaches and would like to try running the nRF as a follower. We know that this is not recommended and can result in audio degradation but we think its worth evaluating since the audio degradation may be acceptable for our application. I've attempted to implement the changes that you've indicated above but it does not appear to be working, I'm sure I'm just missing something.

    in src/modules/audio_i2s.c:41:

    static nrfx_i2s_config_t cfg = {
        /* Pins are configured by pinctrl. */
        .skip_gpio_cfg = true,
        .skip_psel_cfg = true,
        .irq_priority = DT_IRQ(I2S_NL, priority),
        .mode = NRF_I2S_MODE_SLAVE,
        .format = NRF_I2S_FORMAT_ALIGNED,
        .alignment = NRF_I2S_ALIGN_LEFT,
        .ratio = NRF_I2S_RATIO_256X,
        .mck_setup = NRF_I2S_MCK_DISABLED,
        .sample_width = NRF_I2S_SWIDTH_16BIT_IN32BIT,
        .channels = NRF_I2S_CHANNELS_STEREO,
        .clksrc = NRF_I2S_CLKSRC_PCLK32M,
        .enable_bypass = true,
    };

    The device we're attempting to link with uses 16bit samples left aligned in 32bit wide frames

    Next, to disable the compensation mechanisms, I've commented out the call to

    audio_datapath_drift_compensation(frame_start_ts);

    within src/audio/audio_datapath.c:699 which is the

    audio_datapath_i2s_blk_complete

    function.

    This feels like the area I might be missing something. Any assistance would be greatly appreciated! Thanks!

  • I was able to get the application building with the v2.4.0 version of the SDK. I verified that I could send audio from the onboard codec with the nRF still as the I2S master and have it come out on the other board. I also tried disabling the drift compensation features as described with the nRF still as master and the comms still worked. However, once I switched the board over to the external I2S and made it a slave, there was no longer any audio. Any thoughts? The I2S configuration I am using is copied below. I needed to change a couple values based on the I2S format the other device uses (16 bit samples in 32 bit half-frames left aligned, 48kHz sample rate, 256x MCLK, 3V3 signals).

    src/modules/audio_i2s.c:41:

    static nrfx_i2s_config_t cfg = {
        /* Pins are configured by pinctrl. */
        .skip_gpio_cfg = true,
        .skip_psel_cfg = true,
        .irq_priority = DT_IRQ(I2S_NL, priority),
        .mode = NRF_I2S_MODE_SLAVE,  // MODIFIED
        .format = NRF_I2S_FORMAT_ALIGNED,  // MODIFIED
        .alignment = NRF_I2S_ALIGN_LEFT,
        .ratio = NRF_I2S_RATIO_256X,  // MODIFIED
        .mck_setup = NRF_I2S_MCK_DISABLED, //0x66666000, MODIFIED
        .sample_width = NRF_I2S_SWIDTH_16BIT_IN32BIT, // MODIFIED
        .channels = NRF_I2S_CHANNELS_STEREO,
        .clksrc = NRF_I2S_CLKSRC_ACLK,
        .enable_bypass = true,   // MODIFIED
    };
  • Hi, 

    nRF5340 on audio DK is using 1.8v, that could be the root cause.

    -Amanda H.

  • The external I2S source provided an MCLK signal. Does the nRF need this input when acting as I2S slave? I've tried adding some resistor dividers on a breadboard to bring the signals down to 1V8 levels but it's still not working. It also seems like the DIN line pulls the signal down to 1Vpp when I connect it

  • Yes, that is required. If the nRF is a slave, all three clocks are required. I would suggest to get the I2S input working on a nRF5340 DK (not ADK) first, to start out with lower complexity. 

    -Amanda H.

  • Cool good to know. Do I have the proper configurations set in that nrfx_i2s_config_t struct as listed above? The timings for the device we're attempting to connect to are below. 32-bit half-frames with 16 bits of left-aligned sample data. I'll try to get a hold of the non-ADK version of the board

    FS

    48 kHz

     

    Word Clock / Word Select / Frame Sync

    SCLK

    3.072 MHz

    64* FS

    Bit Clock / Serial Clock

    MCLK

    12.288 MHz

    256* FS

    Master Clock

Reply
  • Cool good to know. Do I have the proper configurations set in that nrfx_i2s_config_t struct as listed above? The timings for the device we're attempting to connect to are below. 32-bit half-frames with 16 bits of left-aligned sample data. I'll try to get a hold of the non-ADK version of the board

    FS

    48 kHz

     

    Word Clock / Word Select / Frame Sync

    SCLK

    3.072 MHz

    64* FS

    Bit Clock / Serial Clock

    MCLK

    12.288 MHz

    256* FS

    Master Clock

Children
Related