Hi, I had a question regarding the USB-PD board (STUSB4500) – I’ve been struggling for a while to get the voltage parameter to read properly. When running the supplied example code it outputs values which do not reflect the true values set (which are verified to be working by the expected PDO LED selected, and the output voltage being set properly).
A simple example, when running the SetParameters example sketch with the values:
/* PDO1
- Voltage fixed at 5V
- Current value for PDO1 0-5A, if 0 used, FLEX_I value is used
- Under Voltage Lock Out (setUnderVoltageLimit) fixed at 3.3V
- Over Voltage Lock Out (setUpperVoltageLimit) 5-20%
*/
usb.setCurrent(1,3.0);
usb.setUpperVoltageLimit(1,20);
/* PDO2
- Voltage 5-20V
- Current value for PDO2 0-5A, if 0 used, FLEX_I value is used
- Under Voltage Lock Out (setUnderVoltageLimit) 5-20%
- Over Voltage Lock Out (setUpperVoltageLimit) 5-20%
*/
usb.setVoltage(2,12.0);
usb.setCurrent(2,1.0);
usb.setLowerVoltageLimit(2,20);
usb.setUpperVoltageLimit(2,20);
/* PDO3
- Voltage 5-20V
- Current value for PDO3 0-5A, if 0 used, FLEX_I value is used
- Under Voltage Lock Out (setUnderVoltageLimit) 5-20%
- Over Voltage Lock Out (setUpperVoltageLimit) 5-20%
*/
usb.setVoltage(3,15.0);
usb.setCurrent(3,1.0);
usb.setLowerVoltageLimit(3,20);
usb.setUpperVoltageLimit(3,20);
The output is:
Connected to STUSB4500!
New Parameters:
PDO Number: 3
Voltage1 (V): 49.80
Current1 (A): 3.00
Lower Voltage Tolerance1 (%): 0
Upper Voltage Tolerance1 (%): 20
Voltage2 (V): 50.40
Current2 (A): 1.00
Lower Voltage Tolerance2 (%): 20
Upper Voltage Tolerance2 (%): 20
Voltage3 (V): 50.20
Current3 (A): 1.00
Lower Voltage Tolerance3 (%): 20
Upper Voltage Tolerance3 (%): 20
Flex Current: 1.00
External Power: 0
USB Communication Capable: 0
Configuration OK GPIO: 2
GPIO Control: 1
Enable Power Only Above 5V: 0
Request Source Current: 0
To further investigate this I dumped the register values and found that only the first two bytes are returning as expected (based on the STUSB4500 programming guide). The first 20 bits should correspond to the current (bits 9-0) and voltage (bits 19-10), but only the lower 6 bits of the voltage are read back as expected, furthermore, bits 20 and 21 are reserved and shall be set to 0, however these are both set to 1’s – in fact the upper two bytes are all 1’s:
Current PDO 1
11111111 11111111 10010001 00101100
Current PDO 2
11111111 11111111 11000000 01100100
Current PDO 3
11111111 11111111 10110000 01100100
So this explains why the current is being read back properly but not the voltage. I’m wondering if anyone has any thoughts on why this might be?
For reference I’m using a Sparkfun Pro Micro (USB-C) connected via Qwiic to program the USB-PD board (the only modifications to the example made were changing ‘Serial’ to ‘SerialUSB’ and the write values – though even with the default values it still was off). Additionally I’m on Arduino v1.8.13, SparkFun AVR Boards v1.1.13, SparkFun STUSB4500 v1.1.0.
Thanks!