I am using esp-idf release version 4.2 on a ESP32-WROOM32-D.
I am currently developing a UART based communication protocol to talk to a vehicle.
Sometimes I want to avoid that the bytes that I send get stored in the UART RxRingBuffer.
Therefore I am calling this functions before calling uart_tx_chars.
Code: Select all
if((nErr = uart_flush(pstHW->nUART)) != ESP_OK)
{
NETLOG_ERROR("uart_flush failed with err-code: %d", nErr);
return ESP_FAIL;
}
if((nErr = uart_disable_intr_mask(pstHW->nUART, UART_IRQ_FLAGS)) != ESP_OK)
{
NETLOG_ERROR("uart_disable_intr_mask failed with err-code: %d", nErr);
return ESP_FAIL;
}
Code: Select all
if((nErr = uart_flush(pstHW->nUART)) != ESP_OK)
{
NETLOG_ERROR("uart_flush failed with err-code: %d", nErr);
return ESP_FAIL;
}
if(uart_enable_intr_mask(pstHW->nUART, UART_IRQ_FLAGS) != ESP_OK)
{
NETLOG_ERROR("uart_enable_intr_mask failed");
return ESP_FAIL;
}
I noticed that after calling uart_enable_intr_mask it takes about 28 ms until the next incoming byte is ready to be received from the ring buffer, even though the sender sends the data 10 ms after uart_enable_intr_mask has been called.
This leads to situations in which I run into protocol timeouts, even though the sender met the timing constraints.
My question is:
Why does it take so long after calling uart_enable_intr_mask that the UART is able to receive again / put the data in the ring buffer.
Do you know of any methods to improve the situation ?
Thank you very much for the help