I'm developing nFR52832 to communicate with the PC via UART. commands are sent to the nRF and for each command nRF responds with some data back to the PC via UART.
The UART event handler looks like below,
void uart_error_handle(app_uart_evt_t * p_event) { if (p_event->evt_type == APP_UART_DATA_READY) { while (app_uart_get(&cr) != NRF_SUCCESS) {} if (cr == '\r') { local_buff_length = buff_idx; cmd = local_buff[0]; UART_IN_FLAG = true; buff_idx = 0; //reset buff_idx for next UART packet } else { local_buff[buff_idx] = cr; buff_idx++; } } else if (p_event->evt_type == APP_UART_FIFO_ERROR) { //do nothing } else if (p_event->evt_type == APP_UART_COMMUNICATION_ERROR) { //do nothing } else if (p_event->evt_type == APP_UART_TX_EMPTY) { //do nothing } }
but sometimes the APP_UART_DATA_READY events are missing. since i'm transmitting some data back to PC via UART, can APP_UART_TX_EMPTY event and the next APP_UART_DATA_READY event interfere with each other ? when i debug, the handler goes to the APP_UART_TX_EMPTY event instead of the APP_UART_DATA_READY event when a command is sent from PC to nRF.