In stop mode, if set pwm timer(TIM2&TIM15) init in main(), the power consumption is more than no setting pwm timer.
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);
