cancel
Showing results for 
Search instead for 
Did you mean: 

How to implement USB DPM, prevent hard reset

Nv7
Associate III

I tried following STM32 AN5418 but the EvaluateSinkCapabilities method is not getting called. I added debug prints everywhere in the code and here is what I am receiving:

1. VBusInit (this always happens)

2. DPM notification 104 (Stack init)

3. Cable detection

4. Unimplemented SetDataInfo 8 (USBPD_CORE_EXTENDED_CAPA)

5. SetDataInfo 6 (USBPD_CORE_DATATYPE_RCV_REQ_PDO

- I haven't implemented anything in this, but I had it print out what it received and it looked good (e.g. 5V 3A 9V 3A 20V 5A etc.)

6. Notification: 30 (USBPD_NOTIFY_HARDRESET_RX)

7. Hard reset callback

8. Device turns off, turns on a few seconds later and goes through this same loop

What do I need to implement to get this working? Is this just because all of my methods are unimplemented besides EvaluateSinkCapabilities and one of the cases in GetDataInfo? At what point/do I call USBPD_DPM_RequestMessageRequest?

3 REPLIES 3
FBL
ST Employee

Hi @Nv7 

Would you describe your working environment? Would you attach your project? 

USBPD_DPM_RequestMessageRequestfunction is used to send a power request to the source device based on the selected Source PDO and the prepared RDO. Check this example.

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.


Nv7
Associate III

https://github.com/TektiteBiz/charge2b Here is the code. It appears that RequestMessageRequest is unimplemented, as well as everything else. I am not sure how to implement these.

 

Looking at the example it seems that it is unimplemented there too. (https://github.com/STMicroelectronics/STM32CubeG0/blob/fa3123ccb654f447d3738b86740fb869b2701ace/Projects/STM32G081B-EVAL/Applications/USB-PD/USB-PD_Consumer_1port/Src/usbpd_dpm_user.c#L535)

USBPD_StatusTypeDef USBPD_DPM_RequestMessageRequest(uint8_t PortNum, uint8_t IndexSrcPDO, uint16_t RequestedVoltage)
{
  USBPD_StatusTypeDef _status = USBPD_ERROR;
/* USER CODE BEGIN USBPD_DPM_RequestMessageRequest */
  /* To be adapted to call the PE function */
  /*       _status = USBPD_PE_Send_Request(PortNum, rdo.d32, pdo_object);*/
  DPM_USER_DEBUG_TRACE(PortNum, "HELP: update USBPD_DPM_RequestMessageRequest");
/* USER CODE END USBPD_DPM_RequestMessageRequest */
  DPM_USER_ERROR_TRACE(PortNum, _status, "REQUEST not accepted by the stack");
  return _status;
}

 

Nv7
Associate III

I tried adding a request through USBPD_PE_Send_Request inside of SetDataInfo because that successfully receives the source capabilities, whereas the EvaluateSinkCapabilities function is never called (not sure why). The device still receives notification 30 - HARDRESET_RX and then gets power cycled.

 

Do you have any idea on what could be causing the hard reset message - perhaps a protocol violation I am unaware of? Do you know why EvaluateSinkCapabilities isn't getting called?