Underruns with LE aduio application for nRF5340 with I2S and GPIOTE

Hello,

I'm trying to setup a GPIO signal to be toggled by the GPIOTE on I2S frame start event.

So, I added the following code to do such setup

static void setup_signal(void)
{
    nrfx_err_t status;
    (void)status;

    uint8_t out_channel;
    uint8_t gppi_channel;

#if defined(__ZEPHYR__)
    IRQ_DIRECT_CONNECT(NRFX_IRQ_NUMBER_GET(NRF_GPIOTE), IRQ_PRIO_LOWEST, nrfx_gpiote_irq_handler,
                       0);
#endif

    nrfx_gpiote_init(NRFX_GPIOTE_DEFAULT_CONFIG_IRQ_PRIORITY);

    status = nrfx_gpiote_channel_alloc(&out_channel);
    NRFX_ASSERT(status == NRFX_SUCCESS);

    /*
     * Initialize output pin. The SET task will turn the LED on,
     * CLR will turn it off and OUT will toggle it.
     */
    static const nrfx_gpiote_output_config_t output_config = {
        .drive = NRF_GPIO_PIN_S0S1,
        .input_connect = NRF_GPIO_PIN_INPUT_DISCONNECT,
        .pull = NRF_GPIO_PIN_NOPULL,
    };

    const nrfx_gpiote_task_config_t task_config = {
        .task_ch = out_channel,
        .polarity = NRF_GPIOTE_POLARITY_TOGGLE,
        .init_val = NRF_GPIOTE_INITIAL_VALUE_HIGH,
    };

    status = nrfx_gpiote_output_configure(I2S_FRAME_START_OUTPUT_PIN, &output_config,
                          &task_config);
    NRFX_ASSERT(status == NRFX_SUCCESS);

    nrfx_gpiote_out_task_enable(I2S_FRAME_START_OUTPUT_PIN);

    status = nrfx_gppi_channel_alloc(&gppi_channel);
    NRFX_ASSERT(status == NRFX_SUCCESS);

    /*
     * Configure endpoints of the channel so that the I2S frame start event is connected with
     * the output pin OUT task. This means that each time the event occurs, the output
     * pin will be toggled.
     */
    nrfx_gppi_channel_endpoints_setup(
        gppi_channel, nrf_i2s_event_address_get(NRF_I2S0, NRF_I2S_EVENT_FRAMESTART),
        nrfx_gpiote_out_task_addr_get(I2S_FRAME_START_OUTPUT_PIN));

    nrfx_gppi_channels_enable(BIT(gppi_channel));
}

The signal is toggled which is good, but it seems that it causing some sort of delays that causes underruns issue.

As per my understanding, the GPIOTE module runs without any CPU load so I'm confused.

Thanks,

Ahmed

Parents Reply
  • I'm using the LE audio application sample included with the nRF Connect SDK.

    I've inserted the code above in src/modules/audio_sync_timer.c to hook the output pin to I2S start event using the GPIOTE to be able to monitor the pin using a logic analyzer.

    Actually, I wasn't expecting any changes to the application performance as the GPIOTE module shouldn't infulence the CPU but that wasn't the case and I found some logs with underruns.

    Sorry, but I don't have extra information to share about the underruns itself.

Children
Related