2025-03-16 11:28 PM
I am using an STM32G4 microcontroller with UCPD and the USBPD middleware. I was following this tutorial (same as AN5418 https://www.st.com/resource/en/application_note/dm00663511-how-to-build-a-simple-usbpd-sink-application-with-stm32cubemx-stmicroelectronics.pdf:(
https://youtu.be/-vsJhNIaHxE?si=3wosMAMXrO40mVZr
I, however, have a custom PCB without a TCPP chip, I'm not sure if this makes a difference. I set up everything according to the tutorial and I added the code it requires. Additionally, I added the following code to EvaluateSinkCapabilites:
void USBPD_DPM_SNK_EvaluateCapabilities(uint8_t PortNum, uint32_t *PtrRequestData, USBPD_CORE_PDO_Type_TypeDef *PtrPowerObjectType)
{
/* USER CODE BEGIN USBPD_DPM_SNK_EvaluateCapabilities */
USBPD_SNKRDO_TypeDef rdo;
rdo.d32 = 0;
/* Prepare the requested pdo */
rdo.FixedVariableRDO.ObjectPosition = 1;
rdo.FixedVariableRDO.OperatingCurrentIn10mAunits = 50;
rdo.FixedVariableRDO.MaxOperatingCurrent10mAunits = 50;
rdo.FixedVariableRDO.CapabilityMismatch = 0;
*PtrPowerObjectType = USBPD_CORE_PDO_TYPE_FIXED;
*PtrRequestData = rdo.d32;
//USBPD_HandleTypeDef *pdhandle = &DPM_Params[PortNum];
uint32_t size;
uint32_t snkpdolist[USBPD_MAX_NB_PDO]; // Array to store sink PDOs
USBPD_PDO_TypeDef pdo;
// Get the list of sink PDOs
USBPD_PWR_IF_GetPortPDOs(PortNum, USBPD_CORE_DATATYPE_SNK_PDO, (uint8_t *)snkpdolist, &size);
HAL_Delay(100);
ssd1306_Display(1);
ssd1306_Fill(Black);
ssd1306_SetCursor(0, 0);
ssd1306_WriteString("Available PDOs:", Font_11x18, White);
// Iterate through each sink PDO and print its details
for (uint32_t i = 0; i < size; i++)
{
pdo.d32 = snkpdolist[i]; // Get each PDO
char pdo_info[256]; // Adjust the size if needed
snprintf(pdo_info, sizeof(pdo_info), "%u mV, %u mA", pdo.SNKFixedPDO.VoltageIn50mVunits*50, pdo.SNKFixedPDO.OperationalCurrentIn10mAunits * 10);
ssd1306_SetCursor(0, 7 + i*7);
ssd1306_WriteString(pdo_info, Font_11x18, White);
}
ssd1306_UpdateScreen();
/* USER CODE END USBPD_DPM_SNK_EvaluateCapabilities */
}
I also have some code to manipulate the display in main() which is why I know the microcontroller is working. On a USB-A to USB-C cable nothing is changed on the screen, which means this function isn't getting called and its just getting 5V because its USB-A. On a USB C power supply it doesn't even turn on (no voltage is given), so I don't think this function is getting called or the negotiation is working at all, even though I've connected the UCPD CC lines to the port.
STM32CubeMx:
I would greatly appreciate if someone helped me debug this!
2025-03-17 2:03 AM - edited 2025-03-17 2:43 AM
Hi @Nv7
I, however, have a custom PCB without a TCPP chip, I'm not sure if this makes a difference.
> Sure, it makes big difference. The issue could be linked to your hardware implementation. Double-check the schematic and PCB layout to confirm that UCPD CC lines are correctly connected to the USB-C connector on your custom PCB. Would you attach a trace .cpd ?
To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.
2025-03-17 7:37 AM
Yes, the CC lines on the USB port are connected to the chip's UCPD CC lines, although I don't have any resistors on those lines just a direct connection - is that how it's supposed to work? I'm, not sure how to make a trace.cpd file.