Faiz-983654
Faiz-983654

Reputation: 1

stm32wb55 does not wake up from STOP2 mode

i'm using stm32wb55 microcontroller and i am trying to use the STOP2 mode to reduce power consumption. i can see the measured current consumption that the mcu does indeed enter the low power mode however it does not wakeup. i am using the LPTIM1 in enterrupt mode to wake it up. Here is my code and thank you for your help :

void stop2mode(){

    HAL_UART_DeInit(&huart1);
    HAL_UART_DeInit(&hlpuart1);
    HAL_ADC_DeInit(&hadc1);
//  HAL_I2C_DeInit(&hi2c1);

    GPIO_InitTypeDef GPIO_InitStructure;
    GPIO_InitStructure.Pin = GPIO_PIN_All;
    GPIO_InitStructure.Mode = GPIO_MODE_ANALOG;
    GPIO_InitStructure.Pull = GPIO_NOPULL;

    HAL_GPIO_Init(GPIOA, &GPIO_InitStructure);
    HAL_GPIO_Init(GPIOB, &GPIO_InitStructure);
    HAL_GPIO_Init(GPIOC, &GPIO_InitStructure);
    HAL_GPIO_Init(GPIOD, &GPIO_InitStructure);
    HAL_GPIO_Init(GPIOH, &GPIO_InitStructure);

    __HAL_RCC_GPIOA_CLK_DISABLE();
    __HAL_RCC_GPIOB_CLK_DISABLE();
    __HAL_RCC_GPIOC_CLK_DISABLE();
    __HAL_RCC_GPIOD_CLK_DISABLE();
    __HAL_RCC_GPIOH_CLK_DISABLE();



    /* Enter STOP 2 mode */
    HAL_LPTIM_TimeOut_Start_IT(&hlptim1, 0xFFFF, period);
    HAL_PWREx_EnterSTOP2Mode(PWR_STOPENTRY_WFI);
}

void SetLowPowerMode(void)
{
    LL_C2_PWR_SetPowerMode(LL_PWR_MODE_SHUTDOWN);
    HAL_GPIO_WritePin(LD1_GPIO_Port, LD1_Pin, GPIO_PIN_RESET);

    __HAL_RCC_LPTIM1_CLK_SLEEP_ENABLE() ;   /** On laisse la clock du TIM1 (alarme trame de vie) activée pendant le sleep mode  */

    LL_EXTI_DisableIT_32_63(LL_EXTI_LINE_48);
    LL_C2_EXTI_DisableIT_32_63(LL_EXTI_LINE_48);
    __HAL_PWR_CLEAR_FLAG(PWR_FLAG_WU);
    ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    stop2mode();
}

. I am sure that the interrupt from the LPTIM1 works because i tried the code in debug mode without the function HAL_PWREx_EnterSTOP2Mode(PWR_STOPENTRY_WFI; and i got the desired functionality.

Upvotes: 0

Views: 506

Answers (1)

Faiz-983654
Faiz-983654

Reputation: 1

I found the problem while reviewing a code on github. you have to use HAL_SuspendTick(); before entering stop2 mode and HAL_ResumeTick(); after you wakeup. However i still don't know why

Upvotes: 0

Related Questions