uart_wait_tx_done() is supposed to return when the last bit of a byte has been shifted out of the UART.
That indeed works nicely if more than 1 bytes are sent with uart_write_bytes().
But when sending a single byte then uart_wait_tx_done() returns immediately. So switching a RS485 driver is impossible.
Is this a UART h/w issue or can it be fixed in the driver s/w ?
uart_wait_tx_done() fails when sending a single byte
Re: uart_wait_tx_done() fails when sending a single byte
You could try
https://github.com/espressif/esp-idf/bl ... art.c#L951
Code: Select all
if(UART[uart_num]->status.txfifo_cnt == 0 && UART[uart_num]->status.st_utx_out == 0) {
Re: uart_wait_tx_done() fails when sending a single byte
Thanks!
That looks good. In a simple test it indeed worked. But when using it in a real protocol environment (when rcv is also involved) it behaved as before. For some reason it seems that status.st_utx_out was still set. Can it be cleared when calling uart_write_bytes() is called?
Or is it strictly h/w controlled?
Can it be done with this:
UART[uart_num]->status.st_utx_out = 0
That looks good. In a simple test it indeed worked. But when using it in a real protocol environment (when rcv is also involved) it behaved as before. For some reason it seems that status.st_utx_out was still set. Can it be cleared when calling uart_write_bytes() is called?
Or is it strictly h/w controlled?
Can it be done with this:
UART[uart_num]->status.st_utx_out = 0
Re: uart_wait_tx_done() fails when sending a single byte
No it is hw controlled. That code path is to check if tx is already done. The idea was if the fifo is empty but the last byte is still being shifted out it would wait for the tx done interrupt. I am not sure of exactly when the fifo count goes to zero.
Who is online
Users browsing this forum: Baidu [Spider], Google [Bot], tonystuart and 57 guests