This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

TivaWare USB CDC SerialState notifications do not work correctly

Other Parts Discussed in Thread: EK-TM4C123GXL, EK-TM4C1294XL

Using the TivaWare USB library for CDC virtual COM port has problems with correctly transporting the SerialState notification of the UART status. According to the USB Universal Serial Bus Communication Class Subclass Specification for PSTN Devices, Revision 1.2, Section 6.5.4 SerialState, and Table 31: UART State Bitmap Values, the SerialState notification is supposed to send UART error indicators (overrun, parity error, and framing error) and signal states (BREAK, RI, DSR, and DCD) to the USB host.

However, using a modified version of the TivaWare "usb_dev_serial" example for the ek-tm4c123gxl (I actually run it on the Connected LaunchPad Evaluation Board EK-TM4C1294XL), the TivaWare USB library has two main problems:

1) The UART error signal indicators are never sent - they are sent from the example's CheckForSerialStateChange() function by calling the USBDCDCSerialStateChange() function, but the overrun, parity error, and framing error bits are always cleared on the data sent on the USB bus (the BREAK bit is correctly sent, but never cleared - see second item).

2) The serial signal states are correctly sent on the USB bus by the USBDCDCSerialStateChange() function when they are asserted, but they are never cleared when their signals are de-asserted. Therefore, the recipient cannot be notified when these signal states are no longer present.

The problem appears to be due to the following lines in the USBDCDCSerialStateChange() function: (file usbdcdc.c)

    psInst->ui16SerialState |= (ui16State & USB_CDC_SERIAL_ERRORS);  // merge in error bits
    psInst->ui16SerialState &= ~USB_CDC_SERIAL_ERRORS;               // save only state bits
    psInst->ui16SerialState |= (ui16State & ~USB_CDC_SERIAL_ERRORS); // merge in state bits

I replaced those lines with the following line to get the expected operation:

    psInst->ui16SerialState = ui16State;

With this change, UART error indicators are sent to the USB host and the serial signal states are correctly transported to the USB host as well.

  • Hello Dan,

    Which release of TivaWare are you using?

    Can you try the following instead of an unconditional update.

    ui16State &= ui16Mask; // Clear any bits that should not be set
    psInst->ui16SerialState &= ~ui16Mask; // Clear the affected bits
    psInst->ui16SerialState |= ui16State; // Apply the new bits
  • Amit,

    I started with release 2.1.0.12573 but release 2.1.3.156 was no different in this area.

    Assuming ui16Mask is 0x7f, the changes you suggested do work but appear to be more complicated than needed. My understanding is that USBDCDCSerialStateChange() is called with the current state of all of the serial line signals and the current UART errors, not just the one(s) that have changed as there is no way to indicate to this function which bits have changed state.

    Dan

  • Hello Dan

    The idea is to update only the bits that are updated without having to lose any other information.