cancel
Showing results for 
Search instead for 
Did you mean: 

Sleep/Stop mode while using the USBPD lib

RomThi
Associate III

Hi,

I have an issue with low power operation when using the USBPD library. We have successfully implemented a low power feature for our new product. After that we have started the development of a USBPD feature. The problem is, that after the function "USBPD_PreInitOs()" is called in main.c the power is much higher as it was before. As this function calls a static linked library, I have no idea what has been turned on and how to disable it again. Therefore I need your help as only you have the source code.

Here my simple steps to reproduce the problem:
Hardware (Nucleo144 STM32H563, STLINK-V3PWR):

PXL_20240930_115929316.jpg

1) In CubeMX I select the example USBPD_SNK, then I generate the code.

2) In main I add this two lines after USBPD_PreInitOs():

USBPD_PreInitOs(); /* USER CODE BEGIN 2 */ HAL_SuspendTick(); HAL_PWR_EnterSTOPMode(PWR_LOWPOWERREGULATOR_ON, PWR_STOPENTRY_WFE);

The current is 3600µA (3,6mA).

When commented out USBPD_PreInitOs() like here:

//USBPD_PreInitOs(); /* USER CODE BEGIN 2 */ HAL_SuspendTick(); HAL_PWR_EnterSTOPMode(PWR_LOWPOWERREGULATOR_ON, PWR_STOPENTRY_WFE);

The current is <700µA (0,7mA).

I have tried a lot, e.g. reseting the PD but without full success. Like here:

//USBPD_PreInitOs(); /* USER CODE BEGIN 2 */ __HAL_RCC_UCPD1_FORCE_RESET(); __HAL_RCC_APB1_RELEASE_RESET(); HAL_SuspendTick(); HAL_PWR_EnterSTOPMode(PWR_LOWPOWERREGULATOR_ON, PWR_STOPENTRY_WFE);

With the reset of the PD the current is <1350µA (1,35mA), but still higher then the 700µA without calling USBPD_PreInitOs().

 

Do anyone has a idea what can I turn off to reverse the USBPD_PreInitOs()?

 

Regards,

Roman

1 ACCEPTED SOLUTION

Accepted Solutions

Hi,

using reverse engineering I found the solution. I simply found out what function call is the problem, it was "USBPD_CAD_Init(..)". Then I scanned all HW registers that are changed.

So I found this:

2024_10_01_09_23_53_USBPD_SNK_Debugging_Microsoft_Visual_Studio.png

It seems that a port pin changes its function. After turned the pin back to input mode, the current is as before.

Here my test code:

/* Call PreOsInit function */ USBPD_PreInitOs(); /* USER CODE BEGIN 2 */ //------------------------------------------------------------------------------------ __HAL_RCC_UCPD1_FORCE_RESET(); __HAL_RCC_APB1_RELEASE_RESET(); LL_GPIO_InitTypeDef GPIO_InitStruct = { 0 }; GPIO_InitStruct.Pin = LL_GPIO_PIN_9; GPIO_InitStruct.Mode = LL_GPIO_MODE_INPUT; GPIO_InitStruct.Speed = LL_GPIO_SPEED_FREQ_LOW; GPIO_InitStruct.Pull = LL_GPIO_PULL_NO; LL_GPIO_Init(GPIOA, &GPIO_InitStruct); //------------------------------------------------------------------------------------ HAL_SuspendTick(); HAL_PWR_EnterSTOPMode(PWR_LOWPOWERREGULATOR_ON, PWR_STOPENTRY_WFE);

 

Regards,

Roman

 

View solution in original post

3 REPLIES 3
LLECH.1
ST Employee

Hello RomThi,

You can find an example of a sink low power at this link X-CUBE-TCPP - USB Type-C software expansion for STM32Cube - STMicroelectronics.

the application SNK1M1_Sink_LPM inside that expansion illustrates a sink consuming less than 700µA.

Hopefully it may help you.

 

Best Regards,

 

Hi, 

thank you for your quick replay. I try my luck in the example you mentioned, sounds like the right code.

 

Regards,

Roman

 

Hi,

using reverse engineering I found the solution. I simply found out what function call is the problem, it was "USBPD_CAD_Init(..)". Then I scanned all HW registers that are changed.

So I found this:

2024_10_01_09_23_53_USBPD_SNK_Debugging_Microsoft_Visual_Studio.png

It seems that a port pin changes its function. After turned the pin back to input mode, the current is as before.

Here my test code:

/* Call PreOsInit function */ USBPD_PreInitOs(); /* USER CODE BEGIN 2 */ //------------------------------------------------------------------------------------ __HAL_RCC_UCPD1_FORCE_RESET(); __HAL_RCC_APB1_RELEASE_RESET(); LL_GPIO_InitTypeDef GPIO_InitStruct = { 0 }; GPIO_InitStruct.Pin = LL_GPIO_PIN_9; GPIO_InitStruct.Mode = LL_GPIO_MODE_INPUT; GPIO_InitStruct.Speed = LL_GPIO_SPEED_FREQ_LOW; GPIO_InitStruct.Pull = LL_GPIO_PULL_NO; LL_GPIO_Init(GPIOA, &GPIO_InitStruct); //------------------------------------------------------------------------------------ HAL_SuspendTick(); HAL_PWR_EnterSTOPMode(PWR_LOWPOWERREGULATOR_ON, PWR_STOPENTRY_WFE);

 

Regards,

Roman