This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

I2S loopback example missing in installation folder

I setup NRF SDK using nrfconnectsetup341ia32 executable. 

I2S example file should be located at <InstallFolder>\examples\peripheral\i2s according to https://infocenter.nordicsemi.com/index.jsp?topic=%2Fcom.nordic.infocenter.sdk5.v11.0.0%2Fi2s_example_loopback.html.

But no such folder is available.

Can you please help?

Parents
  • nRF Connect SDK does not have an I2S loopback example. To use the I2S with NCS and the nRF5340 you will have to use the nRFX drivers in "ncs root"\modules\hal\nordic\nrfx\drivers\src\nrfx_i2s.c 

  • Thank you for your reply.

    I found I2S loopback example in <InstallFolder>\tests\drivers\i2s.

    However this example does not use nrfx_i2s_init or any related functions.

    On compiling and running this "Assertion failed at ../src/test_i2s_loopback.c:42: test_i2s_tx_transfer_configure_0: (dev_i2s is NULL) device I2S_0 not found" error occurred.

    Can you please let me know if what should be I2S device name to be used?

    Can you please let me know where can I find I2S receive/transmit example which uses "nrfx_i2s_init" and related functions?

  • Add CONFIG_NRFX_I2S=y to prj.conf file in order to include the driver's source file in the build system. 

    Add #include <nrfx_i2s.h> to your main.c file. 

  • Thank you for this information. I am able to build and run the application.
    When I ran the application i got "E: >>> ZEPHYR FATAL ERROR 1: Unhandled interrupt on CPU 0" error. "nrfx_i2s_init" is successful. I used 26, 27, 28, 29, 30 for sck_pin, lrck_pin, mck_pin, sdout_pin and sdin_pin respectively.

    When "nrfx_i2s_start" is called, app crashed with above mentioned error.

    When debugged further, crash occurred inside "nrf_i2s_task_trigger" function.

    Can you please let me know how to fix this error?

    Can you please let me know what pins should I be using for IN, OUT and clocks of I2S?  

  • Here is the code used

    #include <zephyr.h>
    #include <ztest.h>
    #include <device.h>
    #include <drivers/i2s.h>
    #include <nrf.h>
    #include <nrfx.h>
    #include <nrfx_i2s.h>
    #include "i2s_api_test.h"

    static void data_handler(nrfx_i2s_buffers_t const * p_released,
    uint32_t status)
    {
    if(p_released != NULL) {
    if(p_released->p_rx_buffer != NULL) {
    printf("RX buffer received\n");
    } else if(p_released->p_tx_buffer) {
    printf("TX buffer received\n");
    } else {
    printf("RX/TX buffer not received\n");
    }
    } else {
    printf("Received buffers are NULL\n");
    }
    }

    #define PAUSE_TIME 500
    #define I2S_BUFFER_SIZE 1000
    static uint32_t m_buffer_rx[I2S_BUFFER_SIZE];
    static uint32_t m_buffer_tx[I2S_BUFFER_SIZE];

    void test_main(void)
    {

    nrfx_i2s_config_t i2s_cfg = NRFX_I2S_DEFAULT_CONFIG(0, 1, 17, 20, 22);
    nrfx_i2s_buffers_t nrx_buf;
    nrx_buf.p_rx_buffer = m_buffer_rx;
    nrx_buf.p_tx_buffer = m_buffer_tx;
    err_code = nrfx_i2s_init(&i2s_cfg, data_handler);
    printf("nrfx_i2s_init return code is %u\n", err_code);

    for(index = 0; index < 10; index++)
    {
    err_code = nrfx_i2s_start(&nrx_buf, I2S_BUFFER_SIZE, 0);
    printf("nrfx_i2s_start return code is %u\n", err_code);
    k_sleep(K_MSEC(100));
    nrfx_i2s_stop();
    printf("After nrfx_i2s_stop \n");
    }

    }

  • Can you please check the above code and let me know if I am doing anything wrong?

Reply Children
Related