Hi Team,
We are using the Libuarte driver for our data transfer purpose with the Baudrate of 115200 and timeout of 100usec.
nrf_libuarte_async_config..timeout_us = 100.
With the above configuration it is working fine and when we change the Baudrate to 9600 it is not working. And we changed the timeout value to below value, but with this we are receiving the data but not fully means ,if we are sending the 72 bytes we are receiving only 51 bytes.
nrf_libuarte_async_config..timeout_us = 1500
Is there any dependency with timeout and Baudrate values and how to choose this timeout value for different baudrates. Is there any other settings we need to change when we change the baudrate. Is there any calculation for this timeout and other settings.
Could you any one help us on this issue, we need to deliver the code Customer with the baudrate of 9600, but it is not working.
Here with i am sharing my Code:
NRF_LIBUARTE_ASYNC_DEFINE(libuarte, 1, 0, 0, NRF_LIBUARTE_PERIPHERAL_NOT_USED, 512, 3);
void uart_event_handler(void * context, nrf_libuarte_async_evt_t * p_evt)
{
nrf_libuarte_async_t * p_libuarte = (nrf_libuarte_async_t *)context;
ret_code_t ret = NRF_SUCCESS;
buffer_t buf;
switch (p_evt->type)
{
case NRF_LIBUARTE_ASYNC_EVT_ERROR:
error_flag++;
break;
case NRF_LIBUARTE_ASYNC_EVT_RX_DATA:
buf.p_data = p_evt->data.rxtx.p_data;
buf.length = p_evt->data.rxtx.length;
Update_Rx_Buf(buf.p_data, buf.length);
//ret = nrf_queue_push(&m_buf_queue, &buf);
if(NRF_SUCCESS == ret)
{
rx_done_flag++;
nrf_libuarte_async_rx_free(p_libuarte, p_evt->data.rxtx.p_data, p_evt->data.rxtx.length);
}
break;
case NRF_LIBUARTE_ASYNC_EVT_TX_DONE:
tx_done_flag++;
#if 0
if (m_loopback_phase)
{
nrf_libuarte_async_rx_free(p_libuarte, p_evt->data.rxtx.p_data, p_evt->data.rxtx.length);
if (!nrf_queue_is_empty(&m_buf_queue))
{
buffer_t buf;
ret = nrf_queue_pop(&m_buf_queue, &buf);
APP_ERROR_CHECK(ret);
UNUSED_RETURN_VALUE(nrf_libuarte_async_tx(p_libuarte, buf.p_data, buf.length));
}
}
#endif
break;
default:
break;
}
}
void hal_UARTE_Init(void)
{
ret_code_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_9600,
.parity = NRF_UARTE_PARITY_EXCLUDED,
.hwfc = NRF_UARTE_HWFC_DISABLED,
.timeout_us = 1700,
.int_prio = APP_IRQ_PRIORITY_LOW,
.pullup_rx = NRF_GPIO_PIN_PULLUP
};
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);
err_code = nrf_libuarte_async_tx(&libuarte, "Host UARTE", 11);
}
void hal_nrf_libuarte_async_tx(uint8_t * p_data, uint16_t length)
{
ret_code_t ret;
ret = nrf_libuarte_async_tx(&libuarte, p_data, length);
if((NRF_SUCCESS != ret) && (NRF_ERROR_BUSY != ret))
{
APP_ERROR_CHECK(ret);
}
}