cancel
Showing results for 
Search instead for 
Did you mean: 

Behavior with _LOW_POWER

CWern.1
Associate II

Hi everyone,

I am working on an USB-PD source that is battery powered.

To make use of the low power features, I defined _LOW_POWER.

When this is defined, I get a problem in connection with eletronically marked cables (EMC). Non-EMC cables work fine.

The system will get stuck in the state currentHWcondition "HW_PwrCable_NoSink_Attachment".

I investigated the issue and found that the system works perfectly once I commented the following lines in usbpd_cad_hw_if.c related to _LOW_POWER

uint32_t CAD_StateMachine(uint8_t PortNum, USBPD_CAD_EVENT *pEvent, CCxPin_TypeDef *pCCXX)
{
  CAD_HW_HandleTypeDef *_handle = &CAD_HW_Handles[PortNum];
  uint32_t _timing = CAD_DEFAULT_TIME;
 
  /* set by default event to none */
  *pEvent = USBPD_CAD_EVENT_NONE;
 
  if (USBPD_TRUE == Ports[PortNum].params->PE_SwapOngoing)
  {
    return _timing;
  }
 
  if (_handle->CAD_ErrorRecoveryflag == USBPD_TRUE)
  {
    /* Force the state error recovery */
    _handle->CAD_ErrorRecoveryflag = USBPD_FALSE;
    _handle->cstate = USBPD_CAD_STATE_ERRORRECOVERY;
#if defined(_TRACE)
    USBPD_TRACE_Add(USBPD_TRACE_CAD_LOW, PortNum, (uint8_t)_handle->cstate, NULL, 0);
#endif /* _TRACE */
  }
 
  switch(_handle->cstate)
  {
  case USBPD_CAD_STATE_RESET:
    {
//#if !defined(_LOW_POWER) && !defined(USBPDM1_VCC_FEATURE_ENABLED)
		//DBG
      LL_UCPD_EnableIT_TypeCEventCC2(Ports[PortNum].husbpd);
      LL_UCPD_EnableIT_TypeCEventCC1(Ports[PortNum].husbpd);
//#endif /* !_LOW_POWER */
      if( 0 == PortNum)
      {
        UCPD_INSTANCE0_ENABLEIRQ;
      }
#if USBPD_PORT_COUNT > 1
      else
      {
        UCPD_INSTANCE1_ENABLEIRQ;
      }
#endif /* USBPD_PORT_COUNT > 1 */
#if defined(_DRP) || defined(_ACCESSORY_SNK)
      _handle->CAD_tToggle_start = HAL_GetTick();
#endif /* _DRP || _ACCESSORY_SNK */
      _handle->cstate = USBPD_CAD_STATE_DETACHED;
      break;
    }
void CAD_Check_HW_SRC(uint8_t PortNum)
{
#if !defined(_RTOS)
  uint32_t CC1_value_temp, CC2_value_temp;
#endif /* !_RTOS */
  CAD_HW_HandleTypeDef *_handle = &CAD_HW_Handles[PortNum];
  /* done to prevent code optimization issue with GCC */
  uint32_t CC1_value, CC2_value;
 
  /*
  ----------------------------------------------------------------------------
  | ANAMODE   |  ANASUBMODE[1:0]  |  Notes      |  TYPEC_VSTATE_CCx[1:0]      |
  |           |                   |             |  00  |  01  |  10  |  11    |
  ----------------------------------------------------------------------------
  | 0: Source | 00: Disabled      |Disabled N/A |         NA                  |
  |           | 01: Default USB Rp|             |vRaDef|vRdDef|vOPENDef|      |
  |           | 10: 1.5A Rp       |             |vRa1.5|vRd1.5|vOPEN1.5| NA   |
  |           | 11: 3.0A Rp       |             |vRa3.0|vRd3.0|vOPEN3.0| NA   |
  -----------------------------------------------------------------------------
  | 1: Sink   |                   |             |xx vRa|vRdUSB| vRd1.5 |vRd3.0|
  -----------------------------------------------------------------------------
  */
//DBG
//#ifdef _LOW_POWER
//  /* Enable type C state machine */
//  CLEAR_BIT(Ports[PortNum].husbpd->CR, UCPD_CR_CC1TCDIS | UCPD_CR_CC2TCDIS);
 
//  for(int32_t index=0; index < 200/2; index++){ __DSB();};
//#endif /* _LOW_POWER */
 
  CC1_value = (Ports[PortNum].husbpd->SR & UCPD_SR_TYPEC_VSTATE_CC1) >> UCPD_SR_TYPEC_VSTATE_CC1_Pos;
  CC2_value = (Ports[PortNum].husbpd->SR & UCPD_SR_TYPEC_VSTATE_CC2) >> UCPD_SR_TYPEC_VSTATE_CC2_Pos;
//DBG
//#ifdef _LOW_POWER
//    /* Disable the C state machine */
//  SET_BIT(Ports[PortNum].husbpd->CR, UCPD_CR_CC1TCDIS | UCPD_CR_CC2TCDIS);
//#endif /* _LOW_POWER */
 

Is this a known issue or am I using the code wrong in some other place?

Thanks,

Christian

11 REPLIES 11
Yohann M.
ST Employee

Dear Christian

This issue is not a known issue. could you please provide further information? How do you start from? X-CUBE-TCPP with SINK LPM application? FW G0 Package?

Anyway, I will raise a ticket internally to track this issue and come back to you.

Regards,

Yohann

CWern.1
Associate II

Hi Yohann,

I am using a STM32G071GBN. I started from the CubeMX version 6.2 with the G0 package version 1.4. I created a Source application.

For the low power handling I looked up the example project for the STM32G081b-Eval "USB-PD_Provider_1Port". And I am using the non-Os implementation.

Thanks,

Christian

Thanks for your feedback!

In meanwhile, did you have a look at the application we delivered for Low Power in sink mode?

x-cube-tcpp/Projects/NUCLEO-G071RB/Applications/USB_PD/USBPDM1_Sink_LPM at main · STMicroelectronics/x-cube-tcpp · GitHub

Yohann

Yes I did have a look at your example. I don't see a difference in the middleware files, aside from it being a sink and I have a source application. So I don't know how comparable the two projects are.

Did you have any luck replicating this behavior?

Christian

Dear Christian

I confirm that we reproduced this issue with Provider setup. I raised a ticket internally to fix this issue.

Thanks your comprehension.

Yohann

Dear Yohann,

any news on this?

Christian

Dear @CWern.1​ 

Unfortunately no... I will update you as soon as we have a feedback

Regards,

Yohann

Dear @CWern.1​ 

This is patch done in the USB-PD device for G0 (to copy in Firmware\Middlewares\ST\STM32_USBPD_Library\Devices\STM32G0XX\src).

Ticket is still open on our side, need further investigations and validations but you could try it for tests.

Regards

Yohann

CWern.1
Associate II

Dear Yohann,

I tested the file you supplied with the old version 3.2 and the new 4.0.0 of the USB-PD library. Unfortunately no luck with both. Problem still persists.