2021-03-03 03:16 AM
I have been using STM32G MCUs with USB PD Sink or Source application. Right now, I want to implement Debug Accessory Mode in either STM32G0 or G4 MCUs with SInk USB PD Application. Hence, i would like to use USB-C cable SBU and Data lines for MCU flashing.
When i created an example project and inspected the firmware, i found out that the SNK_ACCESORY is not defined and it is not within and cinfig file, even though i checked the box of CAD Debug within CubeIDE. When i inspected further, i found out in usbpd_def.h that the CAD_AccesorySupport is commented as not yet implemented. I would like to see if i can implement the Debug Accesory Mode by manually defining the SNK_ACCESSORY.
What are the steps i need to follow to implement this mode within STM PD3 Stack? Is there any further example project i can follow from one of these MCUs for Debug Accessory Mode application?
Solved! Go to Solution.
2021-03-03 07:08 AM
Dear Faik,
The detection of the Debug accessory has not been implemented inside our device example. But you are on the right way by looking around SNK_ACCESORY feature because it is a very similar detection mechanism.
The difference is mainly on the resistor value:
So you can use as model the ACCESSORY detection to manage the DEBUG detection which is Rd detection on both CC lines.
SNK_ACCESSORY state machine has not been delivered in any example however this feature has been internally validated with the USB-PD tester (Ellysis, MQP, Lecroy, GRL).
to return a DEBUG_ATTACH event to DPM application, you will have to forward the debug detection like this :
*pEvent = USBPD_CAD_EVENT_DEBUG;
And to catch the attachment inside the application
void USBPD_DPM_CADCallback(uint8_t PortNum, USBPD_CAD_EVENT State, CCxPin_TypeDef Cc)
{
#ifdef _TRACE
USBPD_TRACE_Add(USBPD_TRACE_CADEVENT, PortNum, (uint8_t)State, NULL, 0);
#endif /* _TRACE */
switch (State)
{
case USBPD_CAD_EVENT_DEBUG: // added event
// add you treatment here
break;
I invite you to share the code on github, we will do a review and integrate it into our deliveries
feel free to contact us if something is not enough clear.
Regards
Dominique
2021-03-03 07:08 AM
Dear Faik,
The detection of the Debug accessory has not been implemented inside our device example. But you are on the right way by looking around SNK_ACCESORY feature because it is a very similar detection mechanism.
The difference is mainly on the resistor value:
So you can use as model the ACCESSORY detection to manage the DEBUG detection which is Rd detection on both CC lines.
SNK_ACCESSORY state machine has not been delivered in any example however this feature has been internally validated with the USB-PD tester (Ellysis, MQP, Lecroy, GRL).
to return a DEBUG_ATTACH event to DPM application, you will have to forward the debug detection like this :
*pEvent = USBPD_CAD_EVENT_DEBUG;
And to catch the attachment inside the application
void USBPD_DPM_CADCallback(uint8_t PortNum, USBPD_CAD_EVENT State, CCxPin_TypeDef Cc)
{
#ifdef _TRACE
USBPD_TRACE_Add(USBPD_TRACE_CADEVENT, PortNum, (uint8_t)State, NULL, 0);
#endif /* _TRACE */
switch (State)
{
case USBPD_CAD_EVENT_DEBUG: // added event
// add you treatment here
break;
I invite you to share the code on github, we will do a review and integrate it into our deliveries
feel free to contact us if something is not enough clear.
Regards
Dominique