USB_PD
USB PD
Category: Power Management
Overview
USB Power Delivery (USB PD) is a protocol that allows USB ports to negotiate higher voltages and currents for faster charging and powering of devices. It enables up to 100W (20V @ 5A) delivery over a USB-C cable using the CC (Configuration Channel) lines.
1. Theory & Fundamentals
- Negotiates power profiles over CC1/CC2 pins (not VBUS/D+/D-)
- Standard voltages: 5V, 9V, 15V, 20V (fixed PDOs)
- Standard currents: 0.9A, 1.5A, 2A, 3A, 5A
- Power: Up to 100W (USB PD 2.0), 240W (USB PD 3.1 with EPR)
- BMC encoding: Bi-phase Mark Coding at 300 kbps on CC line
- Roles: Source (provides power), Sink (consumes), DRP (dual-role)
- USB PD 3.0: Adds PPS (Programmable Power Supply) for variable V/I
2. Frame / Packet Structure
USB PD message over CC line:
Preamble(64b) | SOP(20b) | Header(16b) | Data Objects(0-7×32b) | CRC(32b) | EOP(5b)
Message Header:
NumDataObjects(3b) | MsgID(3b) | PowerRole(1b) | SpecRev(2b) | DataRole(1b) | MsgType(4b)
Control Messages: GoodCRC, GotoMin, Accept, Reject, Ping, PS_RDY,
Get_Source_Cap, Get_Sink_Cap, DR_Swap, PR_Swap, VCONN_Swap, Wait, Soft_Reset
Data Messages:
Source_Capabilities (PDO list)
Request (RDO - Request Data Object)
BIST, Sink_Capabilities, Vendor_Defined, Battery_Status
PDO (Power Data Object):
Type(2b) | bits depend on type (Fixed, Variable, Battery, PPS)
Fixed PDO: Voltage(10b)×50mV | Current(10b)×10mA
3. Protocol Mechanics
- Negotiation: Source sends Capabilities → Sink sends Request → Source sends Accept → PS_RDY
- PD state machine: Unattached → Attached → SourceReady/SinkReady
- GoodCRC: Every message requires GoodCRC acknowledgment
- Hard Reset: Resets PD state machine; returns to 5V
- Soft Reset: Resets message IDs without VBUS change
- Cable communication: SOP' messages to active cable plug EMCA
4. Hardware Implementation
- PD controller ICs: FUSB302 (onsemi), STUSB4500, IP2721, Renesas ISL95338
- FUSB302: Most popular open-source PD controller; I2C to MCU
- USB-C connector: CC1/CC2 pins; orientation detection
- Rd/Rp resistors: 5.1kΩ Rd on CC pins of sink device
- CC line: Not connected to USB data; dedicated for PD
- VCONN: 5V power for active cable; provided by source
5. Register-Level / Configuration
// FUSB302 I2C control (popular PD controller)
#include "fusb302.h"
fusb302_init(); // Initialize FUSB302 via I2C
// State machine: runs in interrupt handler
void fusb302_irq_handler(void) {
fusb302_handle_irq();
}
// Called when source capabilities received:
void pd_received_capabilities(PDO *pdos, int n) {
// Find 9V PDO
for(int i=0;i<n;i++) {
if(PDO_VOLTAGE(pdos[i]) == 9000) { // 9V in mV
pd_send_request(i, 2000); // Request 9V @ 2A
return;
}
}
}
6. Driver / Software Development
// Complete PD negotiation flow
void USB_PD_Task(void) {
switch(pd_state) {
case PD_STATE_RECV_CAP:
// Parse source PDOs
best_pdo = find_best_pdo(src_pdos, num_pdos);
pd_send_request_rdo(best_pdo, 3000); // 3A
pd_state = PD_STATE_WAIT_ACCEPT;
break;
case PD_STATE_RECV_PS_RDY:
// VBUS now at negotiated voltage
start_application(); // e.g. charge at 15V
break;
}
}
7. Debugging & Testing
- USB PD Analyzer: Ellisys USB Explorer, Teledyne LeCroy Voyager
- CC line scope: Verify BMC encoding at 300 kbps
- FUSB302 register dump via I2C
- Common issues: Missing Rd resistors; no GoodCRC response; wrong message ID
- USB Type-C cable tester: Verify CC pin continuity and E-marker chip
8. Real-World Applications
- Laptop charging (65W–100W fast charge)
- Smartphone fast charging (USB PD + PPS)
- Embedded single-board computers (Raspberry Pi 5 uses USB PD)
- Display monitors with USB-C power delivery
- Industrial power supplies with dynamic voltage control
9. Advanced Topics & Edge Cases
- USB PD 3.1 EPR: Extended Power Range up to 240W (48V @ 5A)
- PPS (Programmable Power Supply): Variable V/I in 20mV/50mA steps
- Fast Role Swap (FRS): Ultra-fast power role change
- Alternate Modes: HDMI, DisplayPort, Thunderbolt negotiated via PD
- Source-only: Simple chargers only send Capabilities, no negotiation complexity
10. Standards & Variants
| Version | Max Power | Features |
|---|---|---|
| USB PD 1.0 | 60W | Basic V/I profiles |
| USB PD 2.0 | 100W | Most common |
| USB PD 3.0 | 100W | PPS, extended msgs |
| USB PD 3.1 | 240W | EPR (48V) |
💡 Practical Examples
Ex 1: Negotiate 9V: Receive source caps → find 9V PDO → send RDO requesting 9V/2A → wait Accept → PS_RDY.
Ex 2: STUSB4500 standalone: Configure NVM to auto-request 20V @ 5A without MCU firmware.
Ex 3: PPS charging: Request 5V-21V programmable supply; adjust voltage in 20mV steps for optimal charging.
🧪 Practice Questions
Beginner: 1) USB PD max power? 2) Which pins carry PD? 3) What is a PDO? 4) What is PS_RDY? 5) What is PPS?
Intermediate: 1) PD negotiation sequence. 2) Fixed PDO encoding. 3) RDO construction. 4) Hard reset behavior. 5) FUSB302 initialization.
Advanced: 1) Implement full PD sink state machine. 2) Source capabilities design. 3) PPS charger implementation. 4) USB PD 3.1 EPR 240W design. 5) Alternate mode negotiation.
Checklist
- [ ] Understand USB PD negotiation flow
- [ ] Initialize FUSB302 via I2C
- [ ] Parse source PDOs
- [ ] Send Request Data Object (RDO)
- [ ] Handle Accept and PS_RDY
- [ ] Implement GoodCRC ACK
- [ ] Handle Hard Reset
- [ ] Implement PPS variable voltage
- [ ] Debug with CC line oscilloscope
- [ ] Design complete sink device