Hi!
I am working with an application were two nRF52832 shall communicate over UART in half-duplex 1-wire mode (similar to what is described here but I use different pins for Tx/Rx: devzone.nordicsemi.com/.../). The FIFO version of app_uart (app_uart_fifo.c) and SDK 13.0.0 is used.
APP_UART_TX_EMTY is used to check that data been sent before Tx pin is switched to input mode. The problem I am facing is that I don't get the event if I just use app_uart_put() to transmit single data bytes from unit 1 to unit 2. But if I add printf("\r\n") the event occur as expected. I have verified with oscilloscope that first data byte is sent. Code snippets are shown below.
void uart_event_handler(app_uart_evt_t * p_event)
{
if (p_event->evt_type == APP_UART_COMMUNICATION_ERROR)
{
APP_ERROR_HANDLER(p_event->data.error_communication);
}
else if (p_event->evt_type == APP_UART_FIFO_ERROR)
{
APP_ERROR_HANDLER(p_event->data.error_code);
}
else if (p_event->evt_type == APP_UART_TX_EMPTY)
{
tx_empty_flag = true;
}
else if (p_event->evt_type == APP_UART_DATA_READY)
{
data_ready_flag = true;
}
}
while (true)
{
while (app_uart_put('A') != NRF_SUCCESS);
printf("\r\n"); // no APP_UART_TX_EMPTY is received in uart_event_handler if line deleted
while (tx_empty_flag != true );
tx_empty_flag = false;
disable_tx();
}
Could anyone explain this?
Thanks in advance, Mattias