cancel
Showing results for 
Search instead for 
Did you mean: 

USB PD Reseting issue

HGorl.1
Associate II

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

16 REPLIES 16
HGorl.1
Associate II

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

Yohann M.
ST Employee

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.1
Associate II

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

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

HGorl.1
Associate II

Hi Yohan M,

here is our trace from source side. still we are not able to view PS_RDY message.

Kindly help us out in debugging the application.

Thank you

  • Himavanth

Hi @HGorl.1​ 

Nice to see that now you are able to get the trace.

It seems that PE does not have time to send the PS_RDY. There is CC detach during the power transition after 12ms !?

1796 PE 25877 1 PE_SRC_SEND_CAPABILITIES

1797 OUT 25879 1 SRC_CAPABILITIES  DATA:2C9101222CD102002CB104003C2176C0 / 5V - 3A / 9V - 3A / 15V - 3A / [3.3V - 5.9V] - 3A SOP PD3   H:0x41A1   

1798 IN 25880 1 GOODCRC SOP   H:0x0001   

1799 NOTIF 25880 1 SRCCAP_SENT

1800 PE 25880 1 PE_SRC_WAIT_REQUEST

1801 IN 25882 1 REQUEST DATA: 96580231 / ObjectPosition:3 / GiveBack:0 / CapabilityMismatch:0 / USBCommunicationCapable:0 / NoUSBSuspend:1 / UnchunkedExtendedMessagesSupported:0 SOP PD3   H:0x1082   

1802 OUT 25882 1 GOODCRC SOP   H:0x0121   

1803 PE 25883 1 PE_SRC_NEGOTIATE_CAPABILITY

1804 OUT 25883 1 ACCEPT SOP PD3   H:0x03A3   

1805 IN 25884 1 GOODCRC SOP   H:0x0201   

1806 NOTIF 25884 1 REQUEST_ACCEPTED

1807 PE 25884 1 PE_SRC_TRANSITION_SUPPLY

1808 EVENT 25896 1 EVENT_DETACHED

Do you have a protection on your CC lines which can disconnect them?

Did you try at least to get a contract at 5V only? To do it, you could expose only the 1st PD0 in your source capabilities!

Regards,

Yohann

One more point... you use an old version of our stack... Can you try to adapt your applications with latest stack I delivered with the ZIP file (USBPD _provider_port1_ST.7z) I sent to you on 25th of September?