Skip to content

USB PD Protocol Analyzer for 5 USD

Manuel Bl edited this page Apr 25, 2023 · 2 revisions

For about 5 USD in parts, you can create a USB protocol analyzer.

USB PD Protocol Analyzer for 5 USD

Bill of Materials (BOM)

  • Bluepill development board (with a STM32F103C8 MCU)
  • Breadboard
  • USB C intermediate connector
  • LM393P dual comparator
  • 3.3kΩ resistors (2pcs)
  • 1kΩ resistor
  • Wires

Additionally, a device is needed to program the Bluepill. This tutorial assumes you have an ST-Link programmer (or compatible).

Wiring

  • On the breadboard, create this schematic (left part only)
  • Connect it to the Bluepill board according to the STM32 F1 Family Pin Assignment (Monitor pins only)
  • Connect the USB C intermediate connector to the breadboard (GND, CC1 and CC2). Note that CC1 and CC2 might be called A5 and B5.

Software

In the Arduino IDE (for setup see below):

Preparation

  • Navigate to Sketch > Include Library > Manage Libraries.... The Library Manager will open and you will find a list of libraries that are already installed or ready for installation.
  • Search for Power Delivery using the search bar.
  • Click on the INSTALL button to install it.
  • Navigate to File > Examples > USB Power Delivery > ProtocolAnalyzer. A new sketch will open.
  • From the drop-down menu in the window's top left corner, click Select other board and port.... A dialog opens.
  • Search for F1 and select Generic STM32F1 series and click OK.
  • In the Tools menu, select:
    • Board part number > BluePill F103C8
    • Upload method > STM32CubeProgrammer (SWD)
    • USB support (if available) > CDC (generic 'Serial' supersede U(S)ART)
    • U(S)ART support > Enabled (generic 'Serial')
  • Save the sketch

Uploading

  • Connect the ST-Link programmer to the Bluepill.
  • Compile the sketch and upload it to the Bluepill.
  • Disconnect the ST-Link programmer.
  • Connect the USB data cable to the Bluepill board.
  • In Tools > Port, select the port that is likely your device. If unsure, disconnect and reconnect the USB data cable to see which port disappears from the menu and then reappears.
  • In Tools menu, click Serial Monitor

Protocol Analysis

Connect the intermediate connector between two USB C devices. The USB PD messages will be displayed in the Arduino IDE.

Setup of Arduino IDE

Clone this wiki locally