EasyDMA data recieve issue on nrf52 DK

Hi,

Firstly good day to anyone reading this query, hoping to find a solution for the issue here.

I am trying to create a BLE device using nrf 52382 which transmits Audio file data over BLE which it receives from another controller.

So I am using EasyDMA-SPI in nordic to receive 255 bytes and send the same data over ble to android APP, so that the transfer is fast, uninterrupted and seamless.

But I am facing an issue while receiving data over DMA, my rx buffer of SPI DMA is unable to receive all 255 bytes in continuation. After certain index number the data stops coming and then it again starts receiving left over data from index 0, and this behaviour can happen at any index value and it seems random. Some times starts over at index value 4 and sometimes it even goes upto value 42.


I am using spis example from nrf52 DK v16.

Here is the code. SPIS1_EASYDMA_MAXCNT_SIZE is set at 8

#define SPIS_INSTANCE 1 /**< SPIS instance index. */
static const nrf_drv_spis_t spis = NRF_DRV_SPIS_INSTANCE(SPIS_INSTANCE);/**< SPIS instance. */

#define TEST_STRING "Nordic"
//static uint8_t       m_tx_buf[] = TEST_STRING;           /**< TX buffer. */
//static uint8_t       m_rx_buf[sizeof(TEST_STRING) + 1];    /**< RX buffer. */
static uint8_t       m_rx_buf[255];
static uint8_t       m_tx_buf[255];
static const uint8_t m_length = sizeof(m_tx_buf);        /**< Transfer length. */

static volatile bool spis_xfer_done; /**< Flag used to indicate that SPIS instance completed the transfer. */

/**
 * @brief SPIS user event handler.
 *
 * @param event
 */

void spis_event_handler(nrf_drv_spis_event_t event)
{
    if (event.evt_type == NRF_DRV_SPIS_XFER_DONE)
    {
        spis_xfer_done = true;
        NRF_LOG_INFO(" Transfer completed. Received: %s",(uint32_t)m_rx_buf);
    }
}

int main(void)
{
    // Enable the constant latency sub power mode to minimize the time it takes
    // for the SPIS peripheral to become active after the CSN line is asserted
    // (when the CPU is in sleep mode).
    NRF_POWER->TASKS_CONSTLAT = 1;

    bsp_board_init(BSP_INIT_LEDS);

    APP_ERROR_CHECK(NRF_LOG_INIT(NULL));
    NRF_LOG_DEFAULT_BACKENDS_INIT();

    NRF_LOG_INFO("SPIS example");

    nrf_drv_spis_config_t spis_config = NRF_DRV_SPIS_DEFAULT_CONFIG;
    spis_config.csn_pin               = APP_SPIS_CS_PIN;
    spis_config.miso_pin              = APP_SPIS_MISO_PIN;
    spis_config.mosi_pin              = APP_SPIS_MOSI_PIN;
    spis_config.sck_pin               = APP_SPIS_SCK_PIN;

    APP_ERROR_CHECK(nrf_drv_spis_init(&spis, &spis_config, spis_event_handler));

    while (1)
    {
        //memset(m_rx_buf, 0, m_length);
   

        APP_ERROR_CHECK(nrf_drv_spis_buffers_set(&spis, m_tx_buf, m_length, m_rx_buf, m_length));
         if (spis_xfer_done)
        {
        spis_xfer_done = false;
        }
        while (!spis_xfer_done)
        {
            __WFE();
        }

        NRF_LOG_FLUSH();

        bsp_board_led_invert(BSP_BOARD_LED_0);
    }
}



and below is the issue in the attached photos
here is first transfer received of 255 bytes


and below is the random change in index value.


looking forward to a solution from the community.

regards,
Akshay Mehrotra

Related