2020-07-17 01:26 AM
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
2020-07-19 07:29 PM
@Community member , please support me
2020-07-20 01:06 AM
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
2020-07-20 01:49 AM
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
2020-07-20 01:59 AM
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
2020-07-20 02:24 AM
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
2020-07-20 02:43 AM
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?
2020-07-20 02:59 AM
2020-07-20 04:51 AM
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.
2020-07-20 07:12 AM
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