2025-03-21 8:14 AM - edited 2025-03-21 8:36 AM
Hi,
I'm using the code generated by CubeMX ver 16.14.0 following the following link to develop a USBPD sink.
I added an APDO to the PDO list but it is not working. I traced the issue to be coming from the USBPD_DPM_RequestMessageRequest function when it calculates the allowable power. It uses the DPM_SNKRequestedPower.MaxOperatingCurrentInmAunits found in the DPM_USER_Settings structure. The issue is that this value is not initialized. If I use the cubeMonitor-UCPD app, I can see that APDO is defined in the SINK capabilities tab, so the data is there somewhere. Additionally, if I press "SEND TO TARGET", the DPM_SNKRequestedPower.MaxOperatingCurrentInmAunits found in the DPM_USER_Settings is now correct.
Is this an issue related to missing initialization in the code generated by the cubeMX which is leaving the DPM_USER_Settings to be not correctly initialized?
PS. Attached the IOC
Thanks
Edit: I confirmed that initialization is the issue as if I manually call the UpdateSNKPowerPort0 function during firmware initialization, everything works from the start. Is this the correct planned way? Should there be other code generated by the cubeMX?