Advanced Use

CDC Override Mode

In normal operation, the on-board debugger is a true UART bridge between the host and the device. However, in certain use cases, the on-board debugger can override the basic operating mode and use the CDC TX and RX pins for other purposes.

Dropping a text file into the on-board debugger’s mass storage drive can be used to send characters out of the debugger’s CDC TX pin. The filename and extension are trivial, but the text file must start with the characters:
CMD:SEND_UART=
Debugger firmware version 1.20 or earlier has the following limitations:
  • The maximum message length is 50 characters – all remaining data in the frame are ignored
  • The default baud rate used in this mode is 9600 bps, but if the CDC is already active or has been configured, the previously used baud rate still applies
Debugger firmware version 1.21 and later has the following limitations/features:
  • The maximum message length may vary depending on the MSC/SCSI layer timeouts on the host computer and/or operating system. A single SCSI frame of 512 bytes (498 characters of payload) is ensured, and files of up to 4 KB will work on most systems. The transfer will complete on the first NULL character encountered in the file.
  • The baud rate used is always 9600 bps for the default command:
    CMD:SEND_UART=
    The CDC Override Mode should not be used simultaneously with data transfer over the CDC/terminal. If a CDC terminal session is active at the time a file is received via CDC Override Mode, it will be suspended for the duration of the operation and resumed once complete.
  • Additional commands are supported with explicit baud rates:
    CMD:SEND_9600=
    CMD:SEND_115200=
    CMD:SEND_460800=

USB-Level Framing Considerations

Sending data from the host to the CDC can be done byte-wise or in blocks, which will be chunked into 64-byte USB frames. Each such frame will be queued up for sending to the debugger’s CDC TX pin. Transferring a small amount of data per frame can be inefficient, particularly at low baud rates, as the on-board debugger buffers frames and not bytes. A maximum of four 64-byte frames can be active at any time. The on-board debugger will throttle the incoming frames accordingly. Sending full 64-byte frames containing data is the most efficient method.

When receiving data on the debugger’s CDC RX pin, the on-board debugger will queue up the incoming bytes into 64-byte frames, which are sent to the USB queue for transmission to the host when they are full. Incomplete frames are also pushed to the USB queue at approximately 100 ms intervals, triggered by USB start-of-frame tokens. Up to eight 64-byte frames can be active at any time.

If the host (or the software running on it) fails to receive data fast enough, an overrun will occur. When this happens, the last-filled buffer frame will be recycled instead of being sent to the USB queue, and a full data frame will be lost. To prevent this occurrence, the user must ensure that the CDC data pipe is being read continuously, or the incoming data rate must be reduced.