cancel
Showing results for 
Search instead for 
Did you mean: 

In stop mode, if set pwm timer(TIM2&TIM15) init in main(), the power consumption is more than no setting pwm timer.

林宗諭.1
Associate

I use STM32L431 with STM32CubeMX generating code.

If my main function execute like below, the power consumption is 0.35mA

int main(void)

{

 HAL_Init();

 SystemClock_Config();

 MX_GPIO_Init();

 MX_DMA_Init();

 MX_LPUART1_UART_Init();

 MX_USART1_UART_Init();

 MX_RNG_Init();

 MX_TIM2_Init();

 MX_USART3_UART_Init();

 MX_TIM15_Init();

 MX_RTC_Init();

  for(;;) {

    HAL_UART_DeInit(&hlpuart1);

    HAL_UART_DeInit(&huart1);

    HAL_UART_DeInit(&huart3);

    HAL_SuspendTick();

    HAL_PWREx_EnableLowPowerRunMode();

    HAL_PWREx_EnterSTOP2Mode(PWR_SLEEPENTRY_WFI);

    HAL_PWREx_DisableLowPowerRunMode();

    SystemClock_Config();

    HAL_ResumeTick();

    HAL_UART_Init(&hlpuart1);

    HAL_UART_Init(&huart1);

    HAL_UART_Init(&huart3);

  }

And I found out that, if I don't INIT TIM2 & TIM15, the power consumption can reach 0.04mA

int main(void)

{

 HAL_Init();

 SystemClock_Config();

 MX_GPIO_Init();

 MX_DMA_Init();

 MX_LPUART1_UART_Init();

 MX_USART1_UART_Init();

 MX_RNG_Init();

//MX_TIM2_Init();

 MX_USART3_UART_Init();

// MX_TIM15_Init();

 MX_RTC_Init();

  for(;;) {

    HAL_UART_DeInit(&hlpuart1);

    HAL_UART_DeInit(&huart1);

    HAL_UART_DeInit(&huart3);

    HAL_SuspendTick();

    HAL_PWREx_EnableLowPowerRunMode();

    HAL_PWREx_EnterSTOP2Mode(PWR_SLEEPENTRY_WFI);

    HAL_PWREx_DisableLowPowerRunMode();

    SystemClock_Config();

    HAL_ResumeTick();

    HAL_UART_Init(&hlpuart1);

    HAL_UART_Init(&huart1);

    HAL_UART_Init(&huart3);

  }

I want to use TIM2 & TIM15 as PWM timer, Can I do anything to stop the TIM2& TIM15 before HAL_SuspendTick() and let the power consumption reach 0.04mA?

I have tried all the deinit/disable below, but no one work.

HAL_TIM_PWM_Stop_IT(&htim15, TIM_CHANNEL_1);

HAL_TIM_PWM_Stop(&htim15, TIM_CHANNEL_1);

HAL_TIM_PWM_Stop_IT(&htim2, TIM_CHANNEL_2);

HAL_TIM_PWM_Stop(&htim2, TIM_CHANNEL_2);

HAL_TIM_PWM_Stop_IT(&htim2, TIM_CHANNEL_1);

HAL_TIM_PWM_Stop(&htim2, TIM_CHANNEL_1);

HAL_TIM_Base_Stop(&htim2);

HAL_TIM_Base_MspDeinit(&htim2);

HAL_TIM_Base_Deinit(&htim2);

HAL_TIM_PWM_DeInit(&htim2);

HAL_TIM_PWM_MspDeInit(&htim15);

HAL_TIM_PWM_DeInit(&htim15);

4 REPLIES 4
TDK
Guru

Look at the TIM2/TIM15 registers and compare between the two cases.

If you feel a post has answered your question, please click "Accept as Solution".
Roro1990
Associate II

I have exaclty the same issue.

Did you fix it?

I am working with STM32WL and TIM2 as PWM timer, but there is no way to stop it and avoid to consume more power in STOP  MODE.

with TIM2 as PWM 200uA

without TIM2 as PWM 4 uA

One way to disable a peripheral during SLEEP mode is to set properly the RCC_AHBxSMENR and RCC_APBxSMENR registers.

JW

Muy problems was the TIMER 2 pin was as NO_PULL, y set is as PULL_DOWN and it solved the issue. 

Best Regards