Skip to content

Firmware for ATmega16U2 drops bytes on fast serial to USB transfers #424

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

Closed
aweatherguy opened this issue Aug 9, 2021 · 1 comment
Closed

Comments

@aweatherguy
Copy link

See lines 113,114 in firmwares/atmegaxxu2/arduino-usbserial/Arduino-usbserial.c -- I think this is where data is copied from serial into the USB hardware in the ATmega16U2.

The code waits until the buffer contains 96 bytes (or a timeout occurs for flushing). Then it enters a loop to send the bytes. It does not check return codes and I am not sure if the LUFA code checks to see if the hardware is ready either. See also CDC_Device_SendByte and Endpoint_Write_8 functions in LUFA.

The bottom line is that for very high baud rates (e.g. 1M baud), exceeding about 47k chars/s into the Uno's ATmega328 USART transmit buffer will cause characters to be dropped -- they are never seen at the USB host. I think the proof of a bug here is that using an Arduino board with FTDI chip (e.g. Duemilanova or SparkFun RedBoard) does not exhibit this problem.

It may or may not be possible for the ATmega16U2 to transfer data to USB above this rate -- I don't really know. What I do know is that this problem lies either with the hardware or firmware in the 16U2.

@aweatherguy
Copy link
Author

I have tried to reproduce this with a very simple sketch, and cannot do so. I will investigate further, but for now this doesn't seem to be a problem with the 16U2.

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

No branches or pull requests

1 participant