Skip to content
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

Use DMA polling instead of TC/HT and USART IDLE interrupts for RX buffer updates #44

Merged
merged 3 commits into from
Sep 28, 2021

Conversation

r2axz
Copy link
Owner

@r2axz r2axz commented Aug 23, 2021

It seems that using DMA TC/HC interrupts in conjunction with the USART IDLE interrupt for updating RX buffers head positions is a wrong strategy in the case of a USB to UART bridge.

Consider the following scenario: a low-speed device (say 2400, 9600 baud) connected to UART sends a steady stream of bytes. There are no gaps in transmission, so that the USART IDLE interrupt never triggers. On the other hand, since the RX buffers on bluepill-serial-monster are relatively large, the firmware will not send the content of the RX buffer to the host until DMA TC/HC triggers. While it does not lead to data loss, it creates a noticeable delay which can be critical for applications that rely on RX timing.

On the other hand, the firmware can only send the data to the host in the USB polling loop, so it makes perfect sense to update circular buffers there as well.

As a side effect, this change introduces a slight delay in the RTS signal handling. It looks like it should not be a problem, however this requires some additional testing.

@r2axz
Copy link
Owner Author

r2axz commented Sep 28, 2021

Also, it has been reported that ser2net freezes occasionally with the main firmware while works just fine with this modification.

@r2axz r2axz merged commit 368fee2 into main Sep 28, 2021
@r2axz r2axz deleted the r2axz-no-dma-rx-no-usart-idle-interrupts branch September 28, 2021 06:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
1 participant