Skip to content

_uart_isr use wr_addr != rd_addr as test for internal queue not empty #1849

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Sep 17, 2018
Merged

_uart_isr use wr_addr != rd_addr as test for internal queue not empty #1849

merged 1 commit into from
Sep 17, 2018

Conversation

qt1
Copy link
Contributor

@qt1 qt1 commented Sep 7, 2018

This is a possible fix for uart fifo problem.

@lbernstone
Copy link
Contributor

Fixes #1824

@me-no-dev me-no-dev merged commit a6a9a51 into espressif:master Sep 17, 2018
@me-no-dev
Copy link
Member

Done! and thanks :)

@qt1 qt1 deleted the uart_isr_fifo branch September 17, 2018 20:34
@cv007
Copy link

cv007 commented Oct 16, 2018

while(uart->dev->status.rxfifo_cnt || (uart->dev->mem_rx_status.wr_addr != uart->dev->mem_rx_status.rd_addr)) {

the above change worked for me
(ran several days with no problem- previously the rxfifo_cnt would 'lose' about a dozen bytes a day- the bytes were never missing, its just the rxfifo_cnt was returning 0 when there were bytes available, which the rd/wr addr compare now solves)

but maybe this can simply be reduced to-
while(uart->dev->mem_rx_status.wr_addr != uart->dev->mem_rx_status.rd_addr) {
as I don't see any need to check the 'unreliable' rxfifo_cnt
if rxfifo_cnt == 0, then wr_addr/rd_addr has to be compared to catch the possibly 'bad' rxfifo_cnt
if rxfifo_cnt != 0, then wr_addr != rd_addr will also be true
so just check wr_addr/rd_addr
(I also tried this for a few days with no problem)

related-

while(uart->dev->status.rxfifo_cnt != 0 || (uart->dev->mem_rx_status.wr_addr != uart->dev->mem_rx_status.rd_addr)) {

in uartFlush-

this also could be reduced to-
while(uart->dev->mem_rx_status.wr_addr != uart->dev->mem_rx_status.rd_addr) {

although in both cases the rxfifo_cnt check is harmless if left as-is

It seems the reading of rxfifo_cnt only occurs in this file, so any problem rxfifo_cnt seems to have should now be taken care of :)

@ouraborous
Copy link

Implementing this fix helped in my code, seems like a serious silicon issue that is not documented in the errata.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants