3.1.1.4 Advanced Use

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

Dropping a .txt extension text file into the debugger’s mass storage drive can be used to send characters out of the CDC TX pin. The text file must start with the characters: CMD:SEND_UART=. The maximum message length is 50 characters, and all remaining data in the frame is ignored. The default baud rate used in this mode is 9600 bps, but if the CDC is already active or has been configured, the recently used baud rate still applies.

USB-Level Framing Considerations

Sending data from the Host to the CDC can be done byte-wise or in blocks. Blocks will be chunked into 64-byte USB frames. Each frame will be queued up for sending to the CDC TX pin.

The debugger buffers frames, not bytes, so sending a small amount of data per frame can be inefficient, particularly at low-baud rates. A maximum of 4 x 64-byte frames can be active at any time, the debugger will throttle the incoming frames accordingly. Sending full 64-byte data frames data is the most efficient.

When receiving data from the target, the debugger will queue data bound for the Host. When a 64-byte frame is filled, the data is sent to the USB queue for transmission. Incomplete frames are pushed to the USB queue at approximately 100 ms intervals, triggered by USB start-of-frame tokens. Up to 8 x 64-byte frames can be active at any time.

If the application software running on the Host fails to receive data fast enough, an overrun will occur. An overrun will cause the last-filled buffer frame to be recycled. A full frame of data will be lost because of an overrun. To prevent an overrun, the user must ensure that the CDC data pipe is being read continuously, or the incoming data rate must be reduced.