How do you talk USB Power Delivery (PD)? Grab a PHY? Use a MCU with one built-in? Well, if you’re hardcore enough, you can do it with just a few resistors and GPIOs. [eeucalyptus] shows you their implementation of USB-PD on a CH32V003, which has no PD peripheral. This includes building a PD trigger, completely open source, and walking you through the entire low-level PD basics, too!
It helps that CH32V003 is a 32-bit MCU with a good few resources and peripherals, for instance, an internal comparator. Other than that, you don’t need much in terms of hardware resources, but you do need a steady hand — parts of the firmware had to be written in assembly to keep up with PD timing. Want to tinker with the fruit of this research, perhaps, further build upon the code? There’s an example board on GitHub, too!
Want to try your own luck with this method? There’s a schematic, and logic analyzer captures, and a board to refer to. Again, more than enough information on every single low-level detail! Otherwise, grab an MCU pre-programmed to talk PD, maybe a trigger board chip, or maybe even a PD PHY and implement PD communications with it directly – it’s pretty easy!
We thank [Julianna] for sharing this with us!
Haha, oh my that is still very WIP. But anyone interested: stay tuned I’m going to continue this in the next few weeks ;)
I was glad to see you accounted for the variance in the RC oscillator but I’m also concerned about the variance in the resistors with regard to temperature. Most notably, the circuit could be heated unevenly causing the voltage divider to skew outside of acceptable margins. I haven’t looked at the full schematic but please be sure to double check the math on acceptable resistor tolerances and put them in the schematic.
Interesting, so far I found that the signal level is one of the more robust electrical parameters. Table 5.15 in the v3.2 spec shows a Tx-level of 1.04 V to 1.2 V, so that’s quite a margin. But I get the uneven heat thing, on the test board I have an LDO on VBUS, that one might get quite warm :D
I’m still excited to see where this lands in the end.
This is great, but I do sometimes miss the days where you’d just add a barrel jack connector, scribble the right voltage next to it and call it a day :-D