2025-02-06 06:07 AM
Hello,
I am currently trying to complete a UCPD Sink implementation using the NUCLEO-G431RB with X-NUCLEO-SNKM1 shield. So far I managed to get to a state, where cable is recognised by CAD stack once pluged in, the power negotiation is (correctly?) initiated and source capabilities are received. However the next step - capability evaluation - does not fulfil as expected. (please see attached trace)
Regardless of the PDOx Voltage and Current setup (please see attached .ioc file) the evaluation end with "PE_EvaluateCapability: could not find desired voltage" error message (id 12), thus falling back to SRC PDO 1 (msg id14).
While trying to find the cause, in the generated code in file usbpd_dpm_user.c function USBPD_DPM_SNK_EvaluateMatchWithSRCPDO(...) I found that in:
...
/* Match if :
SNK Voltage = SRC Voltage
&&
SNK Op Current <= SRC Max Current
Requested Voltage : SNK Voltage
Requested Op Current : SNK Op Current
Requested Max Current : SNK Op Current
*/
if ( (snkvoltage50mv == srcvoltage50mv)
&&(snkopcurrent10ma <= srcmaxcurrent10ma))
{
currentrequestedpower = (snkvoltage50mv * snkopcurrent10ma) / 2; /* to get value in mw */
currentrequestedvoltage = snkvoltage50mv;
}
...
matching snippet the snkvoltage50mv variable remains at 100 (e.g. 5V) and the snkopcurrent10ma at 0 regardless the setting of SNK PDOs in file usbpd_pdo_defs.h generated by the CubeMX (via CubeIDE). It seems as if the data does not correctly translate to code?
If I hardcode the (voltage) matching as:
switch(srcpdo.GenericPDO.PowerObject)
{
/* SRC Fixed Supply PDO */
case USBPD_CORE_PDO_TYPE_FIXED:
for (i=0; i<nbsnkpdo; i++)
{
...
if (srcvoltage50mv == 180) {
match = USBPD_TRUE;
maxrequestedpower = 900; // 9V * 100mA =0.9W e.g. (180*10)/2
maxrequestedvoltage = 180; //9V
}
}
break;
...
}
everything works as expected (assuming we want 9V at 0.9W and the SRC can provide).
The question is - is there some usercode that I omitted or some incorrect setup?
According to the AN5418 "5.6.2 Modification in usbpd_dpm_user.c" there are a few points on code modifications including the USBPD_DPM_SNK_EvaluateCapabilities, but that seems to be fully implemented already despite the AN informing otherwise...
Thank you for your replies!
2025-02-06 08:35 AM - edited 2025-02-06 08:36 AM
UPDATE:
the "issue" seems to be connected to the GUI_INTERFACE utility as when not enabled, PE_EvaluateCapability message is not present in the trace.
However - only 1 PDO (PDO0) gets matched even if 2 are set. (That will probably be an issue of my configuration?)
When PDO0 is set to 9V, 100mA the 9V source voltage is correctly selected.
Am I reinventing the wheel?
Thank you for your replies.