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

nRF52 SD132 NUS reset after sending 4 packets

Hi!

I'm launching code from example to NUS (ble_app_uart) on nRF52-DK. Everything is going OK, except when I quickly send 4 packets in row from UART to connected Bluetooth device, then nRF52 gets reset. In the example the MCU is waiting for 23 bytes or '\n' from UART and then sends buffer over BLE via ble_nus_string_send. Here's the code:

void uart_event_handle(app_uart_evt_t * p_event)
{
    static uint8_t data_array[BLE_NUS_MAX_DATA_LEN];
    static uint8_t index = 0;
    static uint8_t data;
    uint32_t       err_code;

    switch (p_event->evt_type)
    {
        case APP_UART_DATA_READY:
            UNUSED_VARIABLE(app_uart_get(&data_array[index]));
            index++;
            if ((data_array[index - 1] == '\n') || (index >= (BLE_NUS_MAX_DATA_LEN)))
            {
                err_code = ble_nus_string_send(&m_nus, data_array, index);
                if (err_code != NRF_ERROR_INVALID_STATE)
                {
                    APP_ERROR_CHECK(err_code);
                }

                index = 0;
            }
            break;

        case APP_UART_COMMUNICATION_ERROR:
            APP_ERROR_HANDLER(p_event->data.error_communication);
            break;

        case APP_UART_FIFO_ERROR:
            APP_ERROR_HANDLER(p_event->data.error_code);
            break;

        default:
            break;
    }
}

Problem occurs when there are 4 packets to send one after another, for example when data from UART is like this:

1\n2\n3\n4\n

None data is received by connected BLE device and I receive Reset_Handler
When there are up to 3 packets everything is going well, for example data like

1\n2\n3\n

is sent and received OK.
I'm using SD132 1.0.0-3.alpha, SDK 0.9.2 and compiling using IAR 7.40.
I have no idea why it happens. Any help will be greatly appreciated.

Related