Open Huckies opened 2 years ago
Hi @Huckies ,
Part of the driver rely on the default ISR we provided, so I strongly recommend to try to fix this issue without rewriting the ISR (don't call uart_isr_register
).
There are two factors affecting the interrupt frequency:
rx_timeout_thresh
. When the sender doesn't pull down the line for N bytes of time after the last byte, the interrupt will be triggered.rxfifo_full_thresh
. If the sender keeps sending without timeout, the driver will be interrupted when rxfifo_full_thresh
bytes are received. Please try reconfigure these parameter. If it still don't meet your expectations, please come up with your configurations and maybe a signal waveform by logic analyzer so that we can see if the driver works properly.
Hi @Huckies , Part of the driver rely on the default ISR we provided, so I strongly recommend to try to fix this issue without rewriting the ISR (don't call
uart_isr_register
).There are two factors affecting the interrupt frequency:
- rx timeout
rx_timeout_thresh
. When the sender doesn't pull down the line for N bytes of time after the last byte, the interrupt will be triggered.- RX fifo full threshold
rxfifo_full_thresh
. If the sender keeps sending without timeout, the driver will be interrupted whenrxfifo_full_thresh
bytes are received.Please try reconfigure these parameter. If it still don't meet your expectations, please come up with your configurations and maybe a signal waveform by logic analyzer so that we can see if the driver works properly.
Thank you for the instruction, I've turn to SPI interface since it's quite latency sensitive.
Would you please tell me the target of uart_get_buffered_data_len()
uart_read_bytes()
and uart_flush()
? Is it the hardware FIFO register or the ring buffer in memory? Thanks.
Except from read_bytes, I think the other two are kind of internal/lower level APIs.. So I don't suggest to use them.
uart_get_buffered_data_len() and uart_read_bytes() are to read from SW ring buffer, while uart_flush will make sure both SW ring buffer and the HW fifo will be flushed.
Except from read_bytes, I think the other two are kind of internal/lower level APIs.. So I don't suggest to use them.
That definitely doesn't seem to be correct. For one, both are mentioned in the official man: uart_get_buffered_data_len uart_flush
Moreover, uart_get_buffered_data_len
is a well-known go-to method of low-latency Rx.
uart_flush will make sure both SW ring buffer and the HW fifo will be flushed
"flushed" is an ambiguous term and in a lot of contexts means "wait until all Tx data is sent", which is the polar opposite of what uart_flush
does (destroying all data in Rx buffers).
Environment
Problem Description
I intend to receive UART data transmitted in very short internal, so I'm trying a interrupt way, here is the implementation:
Actual Behavior
If I don't execute
uart_flush(INTER_CONNECT_UART_NUM_1);
the interrupt watchdog can get triggered in very short period.Question
The uart documentation make a very fuzzy description on
uart_get_buffered_data_len()
uart_read_bytes()
as well asuart_flush()
. Which buffer do they operate on earth? If all of them works on the FIFO buffer(refer to the documentation), why would I retrieve a constant zero when usinguart_get_buffered_data_len()
in the ISR handler? https://docs.espressif.com/projects/esp-idf/en/v4.4/esp32s3/api-reference/peripherals/uart.htmlFurther, is there any way that can detect the short interval and move data out of the FIFO quickly and then flush it so I can parse them without blocking the next uart sentence?