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

Corrupted TX data when using libuarte_async library

Hi everyone,

Because of experiencing stability issues using the app_uart implementation for UART communication, I recently switched to the libuarte_async lib which works like a charm when dealing with reception of data. I started from the libuarte example from SDK 17.0.2 with dev board pca10040. 

receiving data is always consistent, but whenever I want to send data, it actually sends random bytes instead (but the correct number of bytes).

 Here is my main function:

int main(void)
{
    bsp_board_init(BSP_INIT_LEDS);
    
    ret_code_t ret = nrf_drv_clock_init();
    APP_ERROR_CHECK(ret);
  
    nrf_drv_clock_lfclk_request(NULL);

    ret_code_t err_code = NRF_LOG_INIT(app_timer_cnt_get);
    APP_ERROR_CHECK(err_code);

    NRF_LOG_DEFAULT_BACKENDS_INIT();

    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 = 100,
            .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);

    uint8_t data[] = {0x41,0x54,0x2B,0x51,0x43,0x43,0x49,0x44,0x0D};
    ret = nrf_libuarte_async_tx(&libuarte, data, sizeof(data));
    APP_ERROR_CHECK(ret);

    while (true)
    {
        NRF_LOG_FLUSH();
    }
}

And uart instance is created this way:

NRF_LIBUARTE_ASYNC_DEFINE(libuarte, 0, 0, 0, NRF_LIBUARTE_PERIPHERAL_NOT_USED, 255, 3);

Any idea what could be the issue?

Best regards

Parents Reply Children
Related