Skip to main content
Visitor II
September 16, 2020
Question

USB PD Reseting issue

  • September 16, 2020
  • 11 replies
  • 5227 views

Hi Stmteam,

I am using Stm32G081RB to Develop Source application.

please have a look at the source files and trace.

provider_port1

Note : trace file is from sink device attached to the Source Device currently we are looking to Develop complete solution.

Questions:

  1. we couldn't see the PS_RDY msg from source device after the Power Setting across the VBUS. is there any timings to be met for Power establishment after Port negotiation with connected port partner?

Note : ADC reading after the power establishment is proper. I make sure the voltage read by the USBPD stack is correct by putting break point at BSP_PWR_VBUSGetVoltage in usbpd_pwr_user.c file.

Kindly don't hesitate to revert back (at any time) for more information about the product.

Thanks and Regards

Himavanth

    This topic has been closed for replies.

    11 replies

    ST Employee
    September 16, 2020

    Dear @HGorl.1​ 

    Could you please confirm that the function 'USBPD_DPM_SetupNewPower' returns 'USBPD_OK' status? (USBPD_PE_RequestSetupNewPower written in the attached MSC)

    The sent of PS_RDY is triggered after calling this function.

    Regards,

    Yohann

    Note: I will really appreciate a USB-PD trace done on your device. Could you please think about adding a USART TX connection on your board to evacuate the USB-PD trace?

    HGorl.1Author
    Visitor II
    September 17, 2020

    Hi Yohann M,

    USBPD_DPM_SetupNewPower returning USBPD_OK. Is there any other things to make sure to work PD properly?

    Thanks and Regards

    Himavanth

    ST Employee
    September 18, 2020

    Hi

    Do you know the delay to setup the power to 15V? Function 'USBPD_SC88xx_SET_V_C'?

    After successful call of SetupNewPower, provider should send the PS_RDY.

    I think that the pb is that this timing to setup the power is higher than the max timing expected by the sink to receive the PS_RDY (set to tPSTransition at 500ms in our stack).

    <--- 0000155812 P0 SOP s:002 PD3 H:0x03a3 ACCEPT

    ---> 0000155812 P0 SOP s:002   H:0x0201 GOODCRC

    -no - 0000155813 P0 NOTIFY_POWER_STATE_CHANGE

    -no - 0000155813 P0 NOTIFY_REQUEST_ACCEPTED

    -pe - 0000155813 P0 PE_SNK_TRANSITION_SNK

    (tPSTransition expiration on disco side)

    -pe - 0000156313 P0 PE_STATE_HARD_RESET

    It could be confirm easily with a PD trace on provider side!

    Regards,

    Yohann

    HGorl.1Author
    Visitor II
    September 24, 2020

    Hi Yohann,

    After I digging through Header files and source files in PSBPD stack I couldn't find  tPSTransition parameter.

    1. what is tPSTransition parameter refers to, "is it source side max Timeout(with in which PS_RDY should send)" or "sink side max Timeout(with in which PS_RDY should receive)?"
    2. If it is source side max Timeout, where can I found the variable in the stack?

    Regards

    • Himavanth
    ST Employee
    September 24, 2020

    Hi Himavanth,

    This information can be found in the USB-PD specification (§6.6.5.1 PSTransitionTimer). This is the time "sink side max Timeout(with in which PS_RDY should receive)". As this timeout are defined in the stack, they are defined directly in the library. They has been tuned to pass USB-PD certification and should be changed.

    Did you measure your time to raise the voltage to 15V?

    Yohann

    HGorl.1Author
    Visitor II
    September 24, 2020

    Hi Yohan,

    The typical rise time  is less than 10ms(from datasheet).

    As I am operating ADC clock frequency at very low frequency previously, I set the ADC frequency to synchronous clock/ 2. i.e . equal to 32MHz(which is less than max ADC frequency 35Mhz ).

    After this change to the code control is trapping to HAL_DMA_IRQHandler() and it can't come out of the Handler forever. Please let me know the reasons for that. how can I resolve the issue?

    Thanks

    -Himavanth

    HGorl.1Author
    Visitor II
    September 25, 2020

    Hi Yohan,

    As I am using STM32g071_Discovery Kit as a sink device to get the trace, As I am not done any programming for slave device to watch the trace. Is there any way to change the Sink side MAX Timeout for STM32GO71_Discovery Kit?

    Note :

    I tried multiple Device connected to the board as a sink, but none of the boards are working fine(As I don't Know the sink side max Timeout, I can't determine the what is going wrong).

    Thanks & Regards

    ST Employee
    September 25, 2020

    Hi

    For test, you can flash your disco with attached binary. !!! This version is not compliant as I put a timeout to 2s !!!

    In the other hand, I took again your application and adapt it to work with EVAL_G0 and it works fine in my side. Please find the complete package (using latest core lib)

    Regards,

    Yohann

    ST Employee
    September 25, 2020

    + package

    HGorl.1Author
    Visitor II
    September 29, 2020

    Hi Yohann M,

    After a lot of hours spending on debugging through the application, I found USBPD_PWR_IF_SetProfile function returning USBPD_OK, and responds time also so quick.

    Note :

    after the execution of USBPD_PWR_IF_SetProfile function control is transferred to piece of code attached below:

    osEvent osMessageGet (osMessageQId queue_id, uint32_t millisec)
    {
     portBASE_TYPE taskWoken;
     TickType_t ticks;
     osEvent event;
     
     event.def.message_id = queue_id;
     event.value.v = 0;
     
     if (queue_id == NULL) {
     event.status = osErrorParameter;
     return event;
     }
     
     taskWoken = pdFALSE;
     
     ticks = 0;
     if (millisec == osWaitForever) {
     ticks = portMAX_DELAY;
     }
     else if (millisec != 0) {
     ticks = millisec / portTICK_PERIOD_MS;
     if (ticks == 0) {
     ticks = 1;
     }
     }
     
     if (inHandlerMode()) {
     if (xQueueReceiveFromISR(queue_id, &event.value.v, &taskWoken) == pdTRUE) {
     /* We have mail */
     event.status = osEventMessage;
     }
     else {
     event.status = osOK;
     }
     portEND_SWITCHING_ISR(taskWoken);
     }
     else {
     if (xQueueReceive(queue_id, &event.value.v, ticks) == pdTRUE) {
     /* We have mail */
     event.status = osEventMessage;
     }
     else {
     event.status = (ticks == 0) ? osOK : osEventTimeout;
     }
     }
     
     return event;
    }

    finally, it's returns with osEventTimeout by the statement in the piece of code attached above.

    event.status = (ticks == 0) ? osOK : osEventTimeout;

    1. where can I found piece of code that is responsible to send PS_RDY message in USBPD stack?

    Thanks & Regards

    -Himavanth

    ST Employee
    September 29, 2020

    Hi

    PS_RDY is managed internally in the stack. It is described in the above MSC I attached in this thread, sent after calling the function 'USBPD_DPM_SetupNewPower/USBPD_PE_RequestSetupNewPower'.

     case PE_SRC_TRANSITION_SUPPLY:
     {
     if (IS_TIMER_EXPIRED(_pdhandle, PE_GenericTimer))
     {
     PE_SetPowerNegotiation(_pdhandle, USBPD_POWER_TRANSITION);
     /* Request DPM to transition power supply */
     /* Setup the new power level */
     if (_pdhandle->PE_Callbacks->USBPD_PE_RequestSetupNewPower != NULL)
     {
     __DEBUG_CALLBACK(_pdhandle, "USBPD_PE_RequestSetupNewPower");
     if (USBPD_OK != _pdhandle->PE_Callbacks->USBPD_PE_RequestSetupNewPower(_pdhandle->PE_CurrentPortNumber))
     {
     SWITCH_TO_STATE_NOTIMEOUT(_pdhandle, PE_STATE_HARD_RESET);
     }
     else
     {
     SWITCH_TO_STATE(_pdhandle, PE_SRC_TRANSITION_SUPPLY_EXIT);
     }
     }
     }
     break;
     }
     
     case PE_SRC_TRANSITION_SUPPLY_EXIT :
     {
     if (USBPD_OK == PE_Send_CtrlMessage(_pdhandle, USBPD_SOPTYPE_SOP, USBPD_CONTROLMSG_PS_RDY, PE_STATE_READY, USBPD_CA_NONE))
     {
     PE_SetPowerNegotiation(_pdhandle, USBPD_POWER_EXPLICITCONTRACT);
     NOTIFY_EVENT_TO_DPM(_pdhandle, USBPD_NOTIFY_POWER_EXPLICIT_CONTRACT);
    #if defined(USBPD_REV30_SUPPORT) && defined(USBPDCORE_PPS)
     _pdhandle->PE_ZIVal.PE_Timers.PE_PPSPeriodicTimer = 0u;
     /* Start tPPSTimeout timer if APDO has been selected and not running */
     if (USBPD_CORE_PDO_TYPE_APDO == _pdhandle->PE_ZIVal.PE_Flags.Flag.PE_CurrentPowerObject)
     {
     START_TIMER_PE(_pdhandle, PE_PPSPeriodicTimer, PE_TPPSTIMEOUT);
     }
    #endif /* USBPD_REV30_SUPPORT && USBPDCORE_PPS*/
     }
     break;
     }

    I am sorry but I cannot help you more without a USB-PD trace from our stack. You just need to connect a UART TX pin to a ST-Link for instance (RX PIN on CN3 of Nucleo board).

    Regards,

    Yohann

    HGorl.1Author
    Visitor II
    September 29, 2020

    Hi Yohan,

    As I am using MB1136 board for SWD programming,

    1. Is it possible to use MB1136 board to get USBPD Trace from source Side?(i.e. using same as ST link debugger)
    2. if Yes to question 1, tell me the connections necessary to use USBPD trace facility?
    3. if No to question 1, if possible send us a link for st-link debugger from where I can purchase?

    Thanks & Regards

    • Himavanth
    ST Employee
    September 29, 2020

    Hi

    Yes, you can use this board.

    On your cubemx application, you can enable TRACER_EMB as described in the "5.2.2 Activation of embedded tracer for debug".

    Then, you have to select a UART TX pin and this pin can be connected to your MB1136 board (RX pin on CN3 connector).

    Then with CubeMonitor, you should be able to get the traces (as you did for Disco board).

    Yohann