cancel
Showing results for 
Search instead for 
Did you mean: 

Unable to send any message

YKubo.1
Associate

Dear members,

I'm working on an adapter project using the USB PD library to connect a NUCLEO-DRP1M1 and a SINK1M1 to an STM32G0C1-EV. The connection is a wire.

I have already ported from the manual and the sample program, and implemented USBPD_DPM_TimerCounter() and osSystickHandler() to HAL_TIM_PeriodElapsedCallback().

When the Power Bank is connected to the evaluation board, it is confirmed that power negotiation is performed and voltage is supplied.

I then tried a test program that calls PowerRoleSwap() when the button is pressed, but depending on the target to be connected, the messages are not sent.

When I connected my Power Bank and pressed its button, the PR_SWAP message was sent as expected. (Of course, that request was denied by Power Bank.)

But, when I connected a smartphone and pressed the button, no PR_SWAP was sent.

​What are the conditions for the USB PD stack to emit PR_SWAP?

For Smartphones

0 EVENT 5636596 1 EVENT_ATTACHED

1 DEBUG 5636596 1 VBUS:5085, CC:2

2 SRC 5636755 1 SRC_CAPABILITIES  DATA:96900136 / 5V - 1.5A SOP PD3   H:0x13A1   

3 SNK 5636756 1 GOODCRC SOP   H:0x0201   

4 SNK 5636757 1 REQUEST DATA: 2C590214 / ObjectPosition:1 / GiveBack:0 / CapabilityMismatch:1 / USBCommunicationCapable:0 / NoUSBSuspend:0 / UnchunkedExtendedMessagesSupported:0 SOP PD3   H:0x1082   

5 SRC 5636758 1 GOODCRC SOP   H:0x0161   

6 SRC 5636759 1 ACCEPT SOP PD3   H:0x05A3   

7 SNK 5636759 1 GOODCRC SOP   H:0x0401   

8 SRC 5636760 1 PS_RDY SOP PD3   H:0x07A6   

9 SNK 5636761 1 GOODCRC SOP   H:0x0601   

10 SRC 5636862 1 SVDM_DISCOVER_IDENTITY  DATA:01A000FF / VDM : INIT SOP PD3   H:0x19AF   VENDOR_DEFINED

11 SNK 5636863 1 GOODCRC SOP   H:0x0801   

12 SNK 5636865 1 SVDM_DISCOVER_IDENTITY  DATA:41A000FF4C05001000000000AAAA0200 / VDM : ACK / VID : 0x054C : Sony SOP PD3   H:0x428F   VENDOR_DEFINED

13 SRC 5636865 1 GOODCRC SOP   H:0x03A1   

14 SRC 5636867 1 SVDM_DISCOVER_SVIDS  DATA:02A000FF / VDM : INIT SOP PD3   H:0x1BAF   VENDOR_DEFINED

15 SNK 5636867 1 GOODCRC SOP   H:0x0A01   

16 SNK 5636868 1 SVDM_DISCOVER_SVIDS  DATA:82A000FF / VDM : NAK SOP PD3   H:0x148F   VENDOR_DEFINED

17 SRC 5636869 1 GOODCRC SOP   H:0x05A1   

I pressed the button, but there's no response...

For Power bank (On line 13, a PR_SWAP message is sent.)

0 EVENT 5686458 1 EVENT_ATTACHED

1 DEBUG 5686458 1 VBUS:5128, CC:2

2 SRC 5686561 1 SRC_CAPABILITIES  DATA:F090010B2CD102002CB10400E1400600 / 5V - 2.4A / 9V - 3A / 15V - 3A / 20V - 2.25A SOP PD3   H:0x41A1   

3 SRC 5686563 1 SRC_CAPABILITIES  DATA:F090010B2CD102002CB10400E1400600 / 5V - 2.4A / 9V - 3A / 15V - 3A / 20V - 2.25A SOP PD3   H:0x41A1   

4 SRC 5686565 1 SRC_CAPABILITIES  DATA:F090010B2CD102002CB10400E1400600 / 5V - 2.4A / 9V - 3A / 15V - 3A / 20V - 2.25A SOP PD3   H:0x41A1   

5 SRC 5686746 1 SRC_CAPABILITIES  DATA:F090010B2CD102002CB10400E1400600 / 5V - 2.4A / 9V - 3A / 15V - 3A / 20V - 2.25A SOP PD3   H:0x41A1   

6 SNK 5686747 1 GOODCRC SOP   H:0x0001   

7 SNK 5686749 1 REQUEST DATA: 2CB10421 / ObjectPosition:2 / GiveBack:0 / CapabilityMismatch:0 / USBCommunicationCapable:0 / NoUSBSuspend:1 / UnchunkedExtendedMessagesSupported:0 SOP PD3   H:0x1082   

8 SRC 5686749 1 GOODCRC SOP   H:0x0161   

9 SRC 5686751 1 ACCEPT SOP PD3   H:0x03A3   

10 SNK 5686752 1 GOODCRC SOP   H:0x0201   

11 SRC 5686801 1 PS_RDY SOP PD3   H:0x05A6   

12 SNK 5686802 1 GOODCRC SOP   H:0x0401   

13 SNK 5690486 1 PR_SWAP SOP PD3   H:0x028A   

14 SRC 5690487 1 GOODCRC SOP   H:0x0361   

15 SRC 5690489 1 NOT_SUPPORTED SOP PD3   H:0x07B0   

16 SNK 5690490 1 GOODCRC SOP   H:0x0601   

B.R.

1 ACCEPTED SOLUTION

Accepted Solutions
Nicolas P.
ST Employee

Hello @YKubo.1​ 

You have used a G0 disco as a spy ?

Could you join the .cpd trace file (See the wiki), from the board you want to debug ?

You will see that having the internal trace is useful to follow the stack states in parallel of the stack user manual.

If you activate the GUI_INTERFACE, you would be able to use the tool UCPD Monitor to send messages (instead of using the button).

If you have a G0 eval board, you can also use the joystick and the LCD, to request a power role swap.

If I guess well, for the smartphone trace, G0 is the sink, and the smartphone is the source.

And in the power bank trace, G0 is the source, and the power bank is the sink.

Even if the stack doesn't control the remote DRP capabilities before sending the DRP request, could you send a get sink capability to check the capabilities of the smartphone and the power bank ?

Do you have USBPDM1_VCC_FEATURE_ENABLED compilation switch activated ?

Can you add in file usbpd_phy_hw_if.c , function USBPD_HW_IF_IsResistor_SinkTxOk the part between defined USBPDM1_VCC_FEATURE_ENABLED ?

uint8_t USBPD_HW_IF_IsResistor_SinkTxOk(uint8_t PortNum)
{
#if defined(_LOW_POWER) || defined(USBPDM1_VCC_FEATURE_ENABLED)
/* in case of low power, the type C state machine is OFF
so the state machine shall re-enabled to get the update value */
/* Enable type C state machine */
CLEAR_BIT(Ports[PortNum].husbpd->CR, UCPD_CR_CC1TCDIS | UCPD_CR_CC2TCDIS);
 
/* Let time for internal state machine to refresh his state */
for(int32_t index=0; index < CAD_DELAY_READ_CC_STATUS; index++){ __DSB();};
 
/* Disable type C state machine */
SET_BIT(Ports[PortNum].husbpd->CR, UCPD_CR_CC1TCDIS | UCPD_CR_CC2TCDIS);
#endif /* _LOW_POWER || USBPDM1_VCC_FEATURE_ENABLED */
 
switch (Ports[PortNum].CCx)
{
case CC1 :
if((Ports[PortNum].husbpd->SR & UCPD_SR_TYPEC_VSTATE_CC1) == LL_UCPD_SNK_CC1_VRP30A)
{
return USBPD_TRUE;
}
break;
...

In case of TCPP01, we optimize power, and for that, we disable CC lines sensing. So patch here is to activate it, refresh the status, and go to power saving again.

Nicolas

View solution in original post

1 REPLY 1
Nicolas P.
ST Employee

Hello @YKubo.1​ 

You have used a G0 disco as a spy ?

Could you join the .cpd trace file (See the wiki), from the board you want to debug ?

You will see that having the internal trace is useful to follow the stack states in parallel of the stack user manual.

If you activate the GUI_INTERFACE, you would be able to use the tool UCPD Monitor to send messages (instead of using the button).

If you have a G0 eval board, you can also use the joystick and the LCD, to request a power role swap.

If I guess well, for the smartphone trace, G0 is the sink, and the smartphone is the source.

And in the power bank trace, G0 is the source, and the power bank is the sink.

Even if the stack doesn't control the remote DRP capabilities before sending the DRP request, could you send a get sink capability to check the capabilities of the smartphone and the power bank ?

Do you have USBPDM1_VCC_FEATURE_ENABLED compilation switch activated ?

Can you add in file usbpd_phy_hw_if.c , function USBPD_HW_IF_IsResistor_SinkTxOk the part between defined USBPDM1_VCC_FEATURE_ENABLED ?

uint8_t USBPD_HW_IF_IsResistor_SinkTxOk(uint8_t PortNum)
{
#if defined(_LOW_POWER) || defined(USBPDM1_VCC_FEATURE_ENABLED)
/* in case of low power, the type C state machine is OFF
so the state machine shall re-enabled to get the update value */
/* Enable type C state machine */
CLEAR_BIT(Ports[PortNum].husbpd->CR, UCPD_CR_CC1TCDIS | UCPD_CR_CC2TCDIS);
 
/* Let time for internal state machine to refresh his state */
for(int32_t index=0; index < CAD_DELAY_READ_CC_STATUS; index++){ __DSB();};
 
/* Disable type C state machine */
SET_BIT(Ports[PortNum].husbpd->CR, UCPD_CR_CC1TCDIS | UCPD_CR_CC2TCDIS);
#endif /* _LOW_POWER || USBPDM1_VCC_FEATURE_ENABLED */
 
switch (Ports[PortNum].CCx)
{
case CC1 :
if((Ports[PortNum].husbpd->SR & UCPD_SR_TYPEC_VSTATE_CC1) == LL_UCPD_SNK_CC1_VRP30A)
{
return USBPD_TRUE;
}
break;
...

In case of TCPP01, we optimize power, and for that, we disable CC lines sensing. So patch here is to activate it, refresh the status, and go to power saving again.

Nicolas