Skip to content

Remove pretty catastrophic loop in the USART serial transmit handler #25

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
Aug 2, 2019

Conversation

egilkv
Copy link
Contributor

@egilkv egilkv commented Aug 2, 2019

The new Arduino megaavr serial driver has a serious issue in the transmit interrupt
handler causing tjhe CPU to stay in interrupt handler more or less the entire time
until the character is fully transmitted. Thus blocking out other interrupts,
such as receive on other ports, and also wasting CPU resources.

causing CPU to stay in interrupt handler more or less the entire time
untill the character was transmitted. Thus blocking out other interrupts,
such as receive on other ports, and also wasting CPU resources.
@MCUdude
Copy link
Owner

MCUdude commented Aug 2, 2019

Thanks! I haven't had time to review the other PRs just yet, but this bug sure is ugly! So everything now acts normally when this line is removed?

@egilkv
Copy link
Contributor Author

egilkv commented Aug 2, 2019

All fine now.

I discovered it when investigating a problem with lost characters on Serial receive, and found it got worse the more you were transmitting on other channels. Found it by doing a code review of UART.cpp and friends. The bug is easily verified by incrementing a (volatile) counter in the while loop, where one will discover the CPU spends a lot of time in that loop.

@MCUdude MCUdude merged commit fce7f2c into MCUdude:master Aug 2, 2019
@MCUdude
Copy link
Owner

MCUdude commented Aug 15, 2019

@egilkv should this PR be updated with what came out of the discussion in megaavr PR#42?

@egilkv
Copy link
Contributor Author

egilkv commented Aug 15, 2019

For now it is fine. I am also working on a proper fix/cleanup, which I think is ready but I want to do more testing before I signal final go-ahead. Will keep you posted.

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.

2 participants