cancel
Showing results for 
Search instead for 
Did you mean: 

STM32G071RB USBPD Source auto send Source Cap

H V N D
Associate II

STM32G071RB USBPD Source auto send Source Cap when start debug: after reset, I'm not connect cable to C-Type port, I click start debug ( ST-Link ), I send about 50 packet of source

Please see in trace and config in attach file

14 REPLIES 14
H V N D
Associate II

@Community member​ , please support me

Yohann M.
ST Employee

Dear @H V N D​ 

I had a look at your application.

I can see that you did not implement a way to enable VBUS. Activation of VBUS is done when a CC connection is detected through the 'USBPD_DPM_UserCableDetection' callback:

/**
  * @brief  UserCableDetection reporting events on a specified port from CAD layer.
  * @param  PortNum The handle of the port
  * @param  State CAD state
  * @retval None
  */
void USBPD_DPM_UserCableDetection(uint8_t PortNum, USBPD_CAD_EVENT State)
{
/* USER CODE BEGIN USBPD_DPM_UserCableDetection */
  switch(State)
  {
  case USBPD_CAD_EVENT_ATTACHED:
  case USBPD_CAD_EVENT_ATTEMC:
    {
      if (USBPD_OK != USBPD_PWR_IF_VBUSEnable(PortNum))
      {
        /* Should not occur */
        osDelay(6000);
        NVIC_SystemReset();
      }
      break;
    }
  case USBPD_CAD_EVENT_DETACHED :
  case USBPD_CAD_EVENT_EMC :
  default :
    {
      if (USBPD_OK != USBPD_PWR_IF_VBUSDisable(PortNum))
      {
        /* Should not occur */
        while(1);
      }
      break;
    }
  }
/* USER CODE END USBPD_DPM_UserCableDetection */
}

To help you in the integration of USB-PD application, I advise you to enable Utilities/TRACER_EMB feature in CubeMX. Please refer to following Wiki page for further details:

https://wiki.st.com/stm32mcu/wiki/USB_Power_Delivery_overview#Specific_tools

Regards,

Yohann

Hi Yohann,

the problem is when I enable SRC or DRP mode, I'm not code anything, just build and run, and I see the CAD and PE task running and send some message when I'm not connect anything

Hi

Could you please provide a .cpd trace of your issue?

I flashed your application in my side and I have no USB-PD activities in my side. PE task is not running when there are no connected cables.

Regards,

Yohann

I'm not using Trace, I'm using EZ-PD Analyzer for trace.

but when I'm add debug code:

void USBPD_PE_Task(void const *argument)

{

 uint8_t _port = (uint32_t)argument;

 for(;;)

 {

  osMessageGet(PEQueueId[_port], 

  USBPD_PE_StateMachine_SRC(_port));

  g_NumberPETask_u32 ++;

 }

}

and

#if (osCMSIS < 0x20000U)

void USBPD_CAD_Task(void const *argument)

#else

void USBPD_CAD_Task(void *argument)

#endif /* osCMSIS < 0x20000U */

{

 for(;;)

 {

#if (osCMSIS < 0x20000U)

  osMessageGet(CADQueueId, USBPD_CAD_Process());

  g_NumberCADTask_u32 ++;

#else

  uint32_t event;

  (void)osMessageQueueGet(CADQueueId, &event, NULL, USBPD_CAD_Process());

#endif /* osCMSIS < 0x20000U */

 }

}

the value of g_NumberCADTask_u32 , g_NumberPETask_u32 is increase when start debug without Connector cable

In my side, I put a breakpoint in USBPD_PE_Task function and it was not raised !

Just to be clear, .cpd trace is an internal trace with debug information from our USB-PD library (like state machines states..).

Could you confirm that nothing is connected to PB15 & PA8? Except CC connector. Could you check the level on these 2 pins?

Hi Yahann,

If I config with only Sink, it running ok, make sure cc line is good

but when I change to source or drp, it go to PE & CAD task when I not connect anything ( sure )

please check wwith my config in attach file, sorry I don't have .cpd file

which board do you use? For your information, it does nor work on STM32G071-DISCO board because only Sink configuration is supported on this board.

this board 2 design base on STM32G071RB, using UCPD0( DB1 & DB2 not connect), with VBUS, I'm using some I2C to buck&boost VBUS, don't worry. I try to fix with Sink, it's working normal, but when change to source and drp is not work, when start debug, it's send some message without connection cable