This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts
This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

UART TX is not as responsive when the UART RX is busy receiving data. (LIBUARTE + BLE_APP_UART)

Hi Nordic DevTeam,
I am having this minor issue where the transmitting UART of the NRF (from phone to external MCU) is not responding as robust as I expected.
The app on my phone is sending a command to turn on the buzzer connected with the external MCU (let's call this a device).
When the device is not actively running, it works as expected which whenever you send a command, the buzzer will ring immediately.
That's not the case when the unit is actively running. For context, when the unit is running ,the UART RX line will be busy as data is being received from external MCU to NRF and to the phone in regular interval.
The nRF is sending the signal fine from phone to nRF to the transmitting UART line (from the oscilloscope), so it doesn't seem like a signal issue nor software (as nRF is printing the payload data from the phone and the libuarte function is returning NRF_SUCCESS)
I played around with the timeout_us under uart_init, which makes a difference, if I set the timeout like to a large number eg. 50000us, then the buzzer will respond immediately with the device turned running. This solved my problem, but the downside is the UART is now receiving data from external MCU at a slower rate which is also not ideal. 
 
Basically I want the UART to be receiving data fast and also be respond to command request immediately, when the unit is on. It is proven to work with other Transparent UART Chip (BM71 from Microchip). Feel like I'm just missing some key concepts from it.
Is there a default value for timeout_us proven to work reliably in any setting?
With timeout 625us, nRF UART receiving and BLE sending to phone 20 bytes max
With larger timeout, nRF UART receiving and BLE sending to phone 244 bytes max
NRF_LIBUARTE_ASYNC_DEFINE(libuarte, 0, 2, 2, NRF_LIBUARTE_PERIPHERAL_NOT_USED, 244, 5);
/**@brief  Function for initializing the UART module.
 */
/**@snippet [UART Initialization] */
static void uart_init(void)
{
    uint32_t                     err_code;
 
    nrf_libuarte_async_config_t nrf_libuarte_async_config = {
            .tx_pin     = TX_PIN_NUMBER,
            .rx_pin     = RX_PIN_NUMBER,
            .baudrate   = NRF_UARTE_BAUDRATE_115200,
            .parity     = NRF_UARTE_PARITY_EXCLUDED,
            .hwfc       = NRF_UARTE_HWFC_DISABLED,
            .timeout_us = 625, 
            .int_prio   = APP_IRQ_PRIORITY_LOW
            
    };
 
    err_code = nrf_libuarte_async_init(&libuarte, &nrf_libuarte_async_config, uart_event_handler, (void *)&libuarte);
 
    APP_ERROR_CHECK(err_code);
 
    nrf_libuarte_async_enable(&libuarte);
 
    static uint8_t text[] = "ble_app_libUARTE example started.\r\n";
    static uint8_t text_size = sizeof(text);
 
    err_code = nrf_libuarte_async_tx(&libuarte, text, text_size);
    APP_ERROR_CHECK(err_code);
}
/**@snippet [UART Initialization] */
Parents
  • Hi,

    Also for the next question is I sometimes will receive this "NRF_LIBUARTE_DRV_EVT_OVERRUN_ERROR ", when I try to connect to the device, which it sends couple of bytes into the transmitting UART from phone.

    I want to be able to write/send command to TX UART and read it even when RX UART is busy sending data in regular interval, How should I handle this?

Reply
  • Hi,

    Also for the next question is I sometimes will receive this "NRF_LIBUARTE_DRV_EVT_OVERRUN_ERROR ", when I try to connect to the device, which it sends couple of bytes into the transmitting UART from phone.

    I want to be able to write/send command to TX UART and read it even when RX UART is busy sending data in regular interval, How should I handle this?

Children
No Data
Related