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 Children
  • Hi,

    Thank you for providing the logs.

    Could you try your application using NCS v2.5.1 and provide the logs?

    Best regards,
    Dejan

  • Hi Dejan,

    First of all, I appreciate your co-operation while trying to help with this, but I don't see this helping.

    I'm not trying to avoid the underruns, so even if it doesn't exist with the latest SDK, I won't consider it solved as I've a complete application built arround SDK 2.4.0 and I'm not willing to migrate to another SDK version.

    I'm trying to find out what makes the GPIOTE module affects the runtime behavior of the application.

    Assigning a task to toggle an LED using the GPIOTE should not infulence the application behavior as it's a H/W module that runs in the background independent of the CPU.

    So, I'm trying to figure out whether I'm using it in a wrong way, Is there a driver issue or what else.

    I hope you got my point and feel free to express what you think.

  • Hi,

    Based on my discussion with developers, this does not seem to be a driver issue. The only concern expressed is your choice to use default NRFx priority. Maybe you do something there which could cause underruns.

    Best regards,
    Dejan

Related