Skip to main content
Visitor II
February 20, 2021
Question

USB PD Audio Accessory connection

  • February 20, 2021
  • 8 replies
  • 1678 views

I am working with demo board B-G474E-DPOW1 and the project from the STM32CubeG4 Sink examples.

I am trying to figure out how to connect an Audio Accessory. I have such an adapter. When I connect it to the usb-c, I expect to see an event with the connection of an Audio Accessory. But that doesn't happen.

_SNK and _ACCESSORY_SNK are defined.

How can I debug this event?

    This topic has been closed for replies.

    8 replies

    ST Employee
    February 22, 2021

    Dear @ADoro.2​ 

    An accessory is a device which presents Ra resistors on each CC lines. To be sure that you are connected an audio accessory, you should check the values of resistors conneted on both CC lines. You may attach a cpd log to this thread or read directly the values of UCPD[SR] registers in the debugger, bits TYPEC_VSTATE_CC1 & TYPEC_VSTATE_CC2. You should have 0 for both values.

    #define LL_UCPD_SRC_CC1_VRA 0x0U /*!< CC1 Source vRA state */
    #define LL_UCPD_SRC_CC2_VRA 0x0U /*!< CC2 Source vRA state */

    Yohann

    ADoro.2Author
    Visitor II
    February 22, 2021

    Bits TYPEC_VSTATE_CC1 & TYPEC_VSTATE_CC2 equal 0 for both states, when nothing attached and when audio accessory attached.

    In UCPD monitor nothing happens.

    Is it possible to make any event on audio accessory attach?

    ST Employee
    February 23, 2021

    Hello

    did you enable CAD_AccesorySupport in uspb_dpm_conf.h?

    USBPD_SettingsTypeDef DPM_Settings[USBPD_PORT_COUNT] =
    {
     {
    (...)
     .CAD_AccesorySupport = USBPD_TRUE, /* cas accessory support */
    (...)

    Yohann

    ADoro.2Author
    Visitor II
    February 23, 2021

    When I enable CAD_AccesorySupport these messages are coming continuously:

    713   CAD   34864   1   USBPD_CAD_STATE_DETACHED

    714   CAD   34904   1   ERROR with Trace_CAD :0E

    715   CAD   34948   1   USBPD_CAD_STATE_DETACHED

    716   CAD   34988   1   ERROR with Trace_CAD :0E

    717   CAD   35032   1   USBPD_CAD_STATE_DETACHED

    718   CAD   35072   1   ERROR with Trace_CAD :0E

    719   CAD   35116   1   USBPD_CAD_STATE_DETACHED

    720   CAD   35156   1   ERROR with Trace_CAD :0E

    721   CAD   35200   1   USBPD_CAD_STATE_DETACHED

    722   CAD   35240   1   ERROR with Trace_CAD :0E

    no matter connected something to usb-c or not.

    TYPEC_VSTATE_CC1 & TYPEC_VSTATE_CC2 become equal to 0x2.

    But nothing event happens.

    In function uint32_t CAD_StateMachine_SNK(uint8_t PortNum, USBPD_CAD_EVENT *pEvent, CCxPin_TypeDef *pCCXX)

    _handle->cstate always equal to USBPD_CAD_STATE_UNATTACHED_ACCESSORY.

    ST Employee
    February 23, 2021

    "ERROR with Trace_CAD :0E" means USBPD_CAD_STATE_UNATTACHED_ACCESSORY.

    Actually, to be able to detect an accessory, we should toggle our resistors on CC lines to Rp values (function USBPDM1_AssertRp called in ManageStateDetached_SNK). It is done every 40 ms.

    It is why you can see in your log a toggle from UNATTACHED_ACCESSORY to DETACHED states.

    Values 2 on CC lines means 'OPEN' in source mode (equivalent of Rp resistor). If you connect an accessory, these bits should change to 0 which means RA.

    Yohann

    ADoro.2Author
    Visitor II
    February 23, 2021

    I see with debugger enter in function USBPDM1_AssertRp

     /* A Sink with Accessory support shall transition to Unattached.Accessory within tDRPTransition
     after the state of both the CC1 and CC2 pins is SNK.Open for tDRP - dcSRC.DRP · tDRP, or if directed.*/
     if ( (HAL_GetTick() - _handle->CAD_tToggle_start) > CAD_ACCESSORY_TOGGLE)
     {
     _handle->cstate = USBPD_CAD_STATE_UNATTACHED_ACCESSORY;
     _handle->CAD_tToggle_start = HAL_GetTick();
     USBPDM1_AssertRp(PortNum);
     }

    But then in CAD_StateMachine_SNK I don`t see that TYPEC_VSTATE_CC1 & TYPEC_VSTATE_CC2 become equal to 0x0 on accessory attach

     case USBPD_CAD_STATE_UNATTACHED_ACCESSORY:
     {
     uint32_t cc;
     cc = Ports[PortNum].husbpd->SR & (UCPD_SR_TYPEC_VSTATE_CC1 | UCPD_SR_TYPEC_VSTATE_CC2);
     
     >>> here TYPEC_VSTATE_CC1 & TYPEC_VSTATE_CC2 stiil equal to 0x2 on accessory attach
     
     _handle->CAD_tDebounce_flag = USBPD_FALSE;
     if((USBPD_TRUE == _handle->CAD_Accessory_SNK) && (cc == (LL_UCPD_SRC_CC1_VRA | LL_UCPD_SRC_CC2_VRA)))
     {
     /* Get the time of this event */
     _handle->CAD_tDebounce_start = HAL_GetTick();
     _handle->cstate = USBPD_CAD_STATE_ATTACHED_ACCESSORY_WAIT;
     }

    ST Employee
    February 25, 2021

    Dear @ADoro.2​ 

    I tested again our FW in front of official tool (TC 4.4.6 SNKAS Connect Audio on Ellisys ) and I don't have issues to detect an audio accessory).

    Please refer to the attached log I generated in this configuration:

    4115	CAD	347188	1	USBPD_CAD_STATE_UNATTACHED_ACCESSORY
    4116	CAD	347232	1	USBPD_CAD_STATE_DETACHED
    4117	CAD	347272	1	USBPD_CAD_STATE_UNATTACHED_ACCESSORY
    4118	CAD	347316	1	USBPD_CAD_STATE_DETACHED
    4119	CAD	347356	1	USBPD_CAD_STATE_UNATTACHED_ACCESSORY
    4120	CAD	347385	1	USBPD_CAD_STATE_ATTACHED_ACCESSORY_WAIT
    4121	CAD	347507	1	USBPD_CAD_STATE_AUDIO_ACCESSORY
    4122	EVENT	347507	1	EVENT_ACCESSORY
    4123	CAD	348077	1	USBPD_CAD_STATE_DETACHED
    4124	EVENT	348077	1	EVENT_DETACHED
    4126	CAD	348117	1	USBPD_CAD_STATE_UNATTACHED_ACCESSORY

    If I connect also a Type-C charger to my sink device, I am able to establish a PD contract.

    Can you please attach your .cpd file you can retrieve in the CubeMonitor-UCPD folder ( cpd log )?

    Could you please confirm that your audio accessory is really an audio accessory from Type-C point of view? We know that few of them are not really audio accessory like described in the Type-C specification but those are legacy cables (based on the previous USB type).

    Did you connect a Type-C charger to your board? Did you try it without enabling the accessory support?

    Regards

    Yohann

    ADoro.2Author
    Visitor II
    March 1, 2021

    @Yohann M.​, thank you for your answers.

    It looks like my audio accessory from Xiaomi is not real Type-C. There is no any connection between CC and Gnd lines.

    I`ll try to make my own real accessory and then add some information here.

    All other board B-G474E-DPOW1 operation with charger is OK except for what I wrote about here.