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

Uart + BLE throws NRF_DRV_UART_EVT_ERROR

Hi I am using SDK 12.3.0 with softdevice s130 v2. When I try to combine ble_app_hrs_peripheral code with app_uart.c, uart module gives error NRF_DRV_UART_EVT_ERROR in uart_irq_handler. I have enabled uart by using APP_UART_ENABLED and UART_ENABLED under c/c++ #define. I have manually commented out CODE_FOR_UART in nrf_drv_uart.c (attached herewith). Will this be the cause of the uart error? Other than this (commenting out CODE_FOR_UART) I haven't changed anything in the library - both in ble and app_uart (and nrf_drv_uart). Thanks for your help. nrf_drv_uart.c

Update: This error occurs only after connecting the ble_app_hrs peripheral to ble_app_hrs central. If I comment out just the line: ble_advertising_start(BLE_ADV_MODE_FAST); in ble_app_hrs_peripheral, then the uart error does not occur.

I have used:

Hash define MIN_CONN_INTERVAL MSEC_TO_UNITS(400, UNIT_1_25_MS)
Hash define MAX_CONN_INTERVAL MSEC_TO_UNITS(650, UNIT_1_25_MS)

Hash define SLAVE_LATENCY 0
Hash define CONN_SUP_TIMEOUT MSEC_TO_UNITS(4000, UNIT_10_MS)

Hash define FIRST_CONN_PARAMS_UPDATE_DELAY APP_TIMER_TICKS(5000, APP_TIMER_PRESCALER)
Hash define NEXT_CONN_PARAMS_UPDATE_DELAY APP_TIMER_TICKS(30000, APP_TIMER_PRESCALER) Hash define MAX_CONN_PARAMS_UPDATE_COUNT 3

Update: I noticed that this error happens even when peripheral (ble_app_hrs) is just advertising (i.e.not connecting to central) with app_uart

Update: This is because of overrun error:ERRORSRC:OVERRRUN. I tried clearing all the errors as following in uart irq handler (as per devzone.nordicsemi.com/.../), but still problem is not solved. I have hardware flow control enabled as well.

    nrf_uart_event_clear(p_uart, NRF_UART_EVENT_ERROR);
 NRF_UART0->EVENTS_ERROR  = 0;
NRF_UART0->EVENTS_RXDRDY = 0;
NRF_UART0->EVENTS_TXDRDY = 0;

					// Activate UART.
NRF_UART0->TASKS_STARTTX = 1;
NRF_UART0->TASKS_STARTRX = 1;
NRF_UART0->ERRORSRC = 0xF;

My code is here: FinalToNordic.zip

Update: Even if the errors are cleared manually in the uart isr as described above, once connection is established with the central, the uart stops receiving or transmitting(I halted here and saw that there are no errors and Tx and Rx interrupt are still enabled in the peripheral registers - in debug mode). I am worried if this would become worse if peripheral and central start to exchange huge chunks of data. Please help.

Update: I tried moving the 'app_uart_get(&rx_data[read_ctr++]);' from uart_error_handle to uart_receiveBuffer - still does not help.

Update: If all the ble part have been removed, then, the uart would work fine without any problems.

Update: I basically need to clear any overrun errors and continue. But when overrun error occurs, even if I clear it NRF_UART0->ERRORSRC=0xF, (inside uart_irq_handler in nrf_drv_uart.h) the overrun error is cleared but from then on, transmit (and receive?) interrupt does not work anymore.

Related