Skip to content

16u2 USB2Serial firmware does low baud rates wrong #265

Open
@WestfW

Description

@WestfW

http://forum.arduino.cc/index.php?topic=385567.msg2670448#msg2670448

The xxxU2 firmware for implementing USB to Serial does not handle very low bitrates (300bps) correctly.
These low bitrates are not possible on a 16MHz AVR using the U2X doublespeed setting (which is used for Arduino, normally.) The AVR firmware contains code that checks for an overly high divisor and unsets U2X, but it does not recalculate the divisor.

 /* Special case 57600 baud for compatibility with the ATmega328 bootloader. */ 
    UBRR1 = (CDCInterfaceInfo->State.LineEncoding.BaudRateBPS == 57600)
            ? SERIAL_UBBRVAL(CDCInterfaceInfo->State.LineEncoding.BaudRateBPS)
            : SERIAL_2X_UBBRVAL(CDCInterfaceInfo->State.LineEncoding.BaudRateBPS);  

    UCSR1C = ConfigMask;
    UCSR1A = (CDCInterfaceInfo->State.LineEncoding.BaudRateBPS == 57600) ? 0 : (1 << U2X1);
    UCSR1B = ((1 << RXCIE1) | (1 << TXEN1) | (1 << RXEN1));

The SAM firmware does not have any checks at all to unset U2X.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions