-
Notifications
You must be signed in to change notification settings - Fork 10
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.

- 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).
- 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.
In the Arduino IDE (for setup see below):
- 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
- 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
Connect the intermediate connector between two USB C devices. The USB PD messages will be displayed in the Arduino IDE.
- Download and install the Arduino IDE 2.x from the Arduino Software web page.
- In the Arduino IDE, go to the Settings dialog, paste this URL into the Additional boards manager URL field: https://github.com/stm32duino/BoardManagerFiles/raw/main/package_stmicroelectronics_index.json
- In the main menu, click Tools > Board > Boards Manager. An additional column on the left side of the menu open.
- Search for STM32. An item called STM32 MCU based boards will appear.
- Click INSTALL
- Go to https://www.st.com/en/development-tools/stm32cubeprog.html, download the STM32CubeProgrammer software and install it (might require an installation).