AnsweredAssumed Answered

stm32 stop2 mode cannot work when indpendent watchdog enable

Question asked by jiang.peng on Nov 11, 2016
I have an application which enables the watchdog and deepsleep(stop2). The deep sleep mode wakes up by RTC, and then wathcdog is refreshed. However, the MCU still resets by watchdog. I attached code below and I am not sure anything missing by using deepsleep and watchdog.
----------------------------------------------------------------   

HAL_Init();
    
    HAL_PWR_EnableBkUpAccess();
 
  /* RTC Clock selection can be changed only if the Backup Domain is reset */
  __HAL_RCC_BACKUPRESET_FORCE();
  __HAL_RCC_BACKUPRESET_RELEASE();
    
    LSIClock_Config();
    
     __HAL_RCC_PWR_CLK_ENABLE();
 
  /* Ensure that MSI is wake-up system clock */
  __HAL_RCC_WAKEUPSTOP_CLK_CONFIG(RCC_STOP_WAKEUPCLOCK_MSI);
    while(1)
    {
        
        
    
        refreshDOG(); //this will refresh watchdog, but
        
     __HAL_RCC_GPIOA_CLK_ENABLE();
    __HAL_RCC_GPIOB_CLK_ENABLE();
    __HAL_RCC_GPIOC_CLK_ENABLE();  
    __HAL_RCC_GPIOD_CLK_ENABLE();
    __HAL_RCC_GPIOE_CLK_ENABLE();
    __HAL_RCC_GPIOF_CLK_ENABLE();
    __HAL_RCC_GPIOG_CLK_ENABLE();
    __HAL_RCC_GPIOH_CLK_ENABLE();    

    GPIO_InitStruct.Mode = GPIO_MODE_ANALOG;
    GPIO_InitStruct.Speed = GPIO_SPEED_HIGH;
    GPIO_InitStruct.Pull = GPIO_NOPULL;
    GPIO_InitStruct.Pin = GPIO_PIN_All;

    HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
    HAL_GPIO_Init(GPIOB, &GPIO_InitStruct);
    HAL_GPIO_Init(GPIOC, &GPIO_InitStruct);  
    HAL_GPIO_Init(GPIOD, &GPIO_InitStruct);
    HAL_GPIO_Init(GPIOE, &GPIO_InitStruct);
    HAL_GPIO_Init(GPIOF, &GPIO_InitStruct);
    HAL_GPIO_Init(GPIOG, &GPIO_InitStruct);
    HAL_GPIO_Init(GPIOH, &GPIO_InitStruct);  

    __HAL_RCC_GPIOA_CLK_DISABLE();
    __HAL_RCC_GPIOB_CLK_DISABLE();
    __HAL_RCC_GPIOC_CLK_DISABLE();
    __HAL_RCC_GPIOD_CLK_DISABLE();
    __HAL_RCC_GPIOE_CLK_DISABLE();
    __HAL_RCC_GPIOF_CLK_DISABLE();
    __HAL_RCC_GPIOG_CLK_DISABLE();
    __HAL_RCC_GPIOH_CLK_DISABLE();
 
    /* Disable all used wakeup source */
    HAL_RTCEx_DeactivateWakeUpTimer(&RTCHandle);
        
        HAL_RTCEx_SetWakeUpTimer_IT(&RTCHandle, 0x03FFF, RTC_WAKEUPCLOCK_RTCCLK_DIV16);
 
    /* Enter STOP 2 mode */
    HAL_PWREx_EnterSTOP2Mode(PWR_STOPENTRY_WFI);

    /* Re-configure the system clock to 80 MHz based on MSI, enable and
       select PLL as system clock source (PLL is disabled in STOP mode) */
    SYSCLKConfig_STOP();

    }

Outcomes