What is USB CDC?
USB CDC (Communications Device Class)is a USB device class defined by the USB-IF that allows a USB device to present itself as a communication device, such as a serial port, modem, network adapter, or telephony device. The most commonly used CDC subclass in embedded systems isCDC-ACM (Abstract Control Model), which emulates a traditional UART COM port. [usb.org], [en.wikipedia.org]
CDC Class Hierarchy
USB Device Class (0x02) │ ├── CDC-ACM (Virtual COM Port) ├── CDC-ECM (Ethernet Control Model) ├── CDC-NCM (Network Control Model) ├── CDC-ATM ├── CDC-PSTN └── CDC-WMCThe most common embedded implementation is:
USB CDC-ACM ↓ Windows → COM3, COM4 ... Linux → /dev/ttyACM0 macOS → /dev/cu.usbmodemxxxx ``[usb.org], [en.wikipedia.org]
CDC Architecture
CDC separates communication into two interfaces:
1. Communication Interface (CIC)
Used for control and management.
Class = 0x02 (CDC)Carries:
- Line coding configuration
- DTR/RTS status
- Notification messages
- Modem status
Typical endpoint:
Interrupt IN2. Data Interface (DIC)
Used for actual payload transfer.
Class = 0x0A (CDC Data)Typical endpoints:
Bulk OUT Bulk INEndpoint Layout
A typical CDC-ACM device uses:
EP0 Control EP1 IN Interrupt (Notification) EP2 OUT Bulk (Host → Device) EP2 IN Bulk (Device → Host) ``Host │ ▼ +---------------+ | CDC Driver | +---------------+ │ ┌────────┴─────────┐ ▼ ▼ Interrupt EP Bulk EP (Control) (Data)Enumeration Example
During enumeration, the host sees:
Device Descriptor Configuration Descriptor Interface 0 CDC Communication Interface Interface 1 CDC Data Interface ``The host loads the CDC driver and creates a virtual serial port.
Examples:
Windows : COM5 Linux : /dev/ttyACM0 macOS : /dev/cu.usbmodem101[en.wikipedia.org], [usb.org]
CDC-ACM Control Requests
After enumeration, the host sends class-specific requests.
SET_LINE_CODING
typedef struct { uint32_t baudrate; uint8_t stopbits; uint8_t parity; uint8_t databits; } LINE_CODING;Example:
115200 8 data bits No parity 1 stop bitGET_LINE_CODING
Host requests current UART settings.SET_CONTROL_LINE_STATE
Controls:
DTR RTSMany MCU applications use DTR as:
Terminal Connectedsignal.
SEND_BREAK
Generate UART break condition.CDC-ACM Data Flow
Application │ UART-style API │ CDC Driver │ USB Bulk IN/OUT │ USB Host ``Example:
printf("Hello\r\n");MCU:
CDC_Transmit_FS()USB:
Bulk IN EndpointPC Terminal:
COM Port Windowshows:
HelloWhy CDC Is Popular
No Custom Driver Needed
Most operating systems already provide CDC drivers.
Windows usbser.sys Linux cdc_acm macOS built-inUART Replacement
Instead of:
USB-UART Bridge ↓ FT232 CP2102 CH340the MCU directly implements:
USB CDC-ACM ``saving hardware cost.
Debug Console
Used for:
Firmware logs CLI commands Bootloader communication AT commandsCDC vs HID
| Feature | CDC | HID |
|---|---|---|
| Appears as | COM Port | Keyboard/Mouse |
| Bulk transfer | Yes | No |
| Driver support | CDC Driver | HID Driver |
| Throughput | High | Lower |
| Virtual UART | Yes | No |
CDC vs Vendor Specific
| Feature | CDC | Vendor Class |
|---|---|---|
| Standardized | Yes | No |
| Host Driver | Built-in | Usually custom |
| COM Port | Yes | Depends |
| Portability | High | Lower |
Typical Descriptor Classes
Device Class 0x02 CDC Communication 0x02 CDC Data 0x0AFunctional descriptors:
Header Descriptor Call Management Descriptor ACM Descriptor Union DescriptorThese descriptors tell the host that the device implements the CDC-ACM model and that Interface 0 controls Interface 1. [cscott.net], [usb.org]
For embedded firmware engineers,CDC-ACM is essentially "USB behaving like a UART", although the transport underneath is actually USB control, interrupt, and bulk transfers rather than UART signaling.