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,

Is it possible to provide the project to this thread?

regards,

Yohann

CWern.1
Associate II

Dear Yohann,

yes I can share it with you. Is there any way I can get it to you?