Use a CDC serial port

USB Library ›› Device ››
… visits
Parent Previous Next

Choose CDC when you want to use a serial terminal or an existing COM-port program. Start with the short connection test below.

After the first connection

Connect and test

CDC makes the PIC appear as a serial or COM port on the PC. Your program sends and receives bytes through TXReport, RXReport and the common USB calls. A physical UART is not needed for this USB-only connection.

CDC PC test application connected on COM6 with binary command buttons, text entry, DTR and RTS controls, and received text.

Choose the assigned COM port and connect. Each SEND 100/200/222 button sends one binary byte; the Custom box can send text instead. COM6 is only the port used in this example. The picture shows example settings; the current app starts with DTR enabled. Keep it enabled when your firmware requires it.

Windows device listing named USB Serial Device (COM6), with Positron8 CDC Serial shown as the model.

Windows may keep the general name USB Serial Device even when the model shows your product name. Use the COM number assigned on your PC; it may differ from COM6.

  1. Choose CDC ACM serial, complete Hardware/Registers and use the generated Integration code.
  2. Start with 64-byte TX/RX packets and the serial defaults.
  3. Program and connect the PIC. Select its assigned COM port in the supplied CDC application or another serial program.
  4. Choose the port settings and open the port. For a first USB-only test, choose 115200, 8 data bits, no parity, one stop bit and no flow control. Enable DTR if your firmware requires it.
  5. Send a known command. Decide whether it is a binary byte or text before writing the PIC parser.
  6. Call USB_Read() frequently and process only the first USB_RxLength bytes when its result is USB_OK.

A visible COM port is only the first step. USB_Configured=1 means the PC has set up the USB connection. A terminal may still be closed. Windows may call the port USB Serial Device (COMx) even when you entered a product name. Windows chooses the COM number.

Build the supplied Windows app

The CDC Data → PC Host App folder contains the source for the basic Windows test app. Build it in Visual Studio 2026, then follow Use the CDC test app to select the port, send a command and read the reply. You can keep using it as a test tool or change its buttons and display for your own project.

See also

Created with the Personal Edition of HelpNDoc: Elevate your documentation to new heights with HelpNDoc's built-in SEO