AnsweredAssumed Answered

STM32L152 Exit from Stop Mode

Question asked by JoeEmerson on Jul 1, 2016
Latest reply on Jul 5, 2016 by JoeEmerson
Hello,

I'm having issues getting my device to wake from stop mode using the RTC wake interrupt. I'm using the tickless idle function of FreeRTOS v9.0.0 to place the MCU into low power mode and I'm using the RTC wake interrupt to generate a periodic interrupt to wake from low power mode.

  /***** My function to enter low power mode, called from FreeRTOS *****/

  void BSP_Power_EnterLowPowerMode( void )
  {
    /* Switch on file-scope variable to choose sleep mode */
    switch(BSP_LowPowerMode)
    {
    case LOW_POWER_SLEEP:
      PWR_EnterSleepMode( PWR_Regulator_LowPower, PWR_SLEEPEntry_WFI );
      break;
    
    case STOP_MODE:
      PWR_EnterSTOPMode( PWR_Regulator_LowPower, PWR_STOPEntry_WFI ) ;
    
    default:
      BSP_ASSERT(false);
      break;
    }
  }

  /**********/


Inside the RTC wake ISR, I wake a suspended FreeRTOS task. This task resets the internal watchdog timer and then places itself in suspended state. This allows my application to periodically wake and reload the internal watchdog to avoid a watchdog timeout and device reset.


  /***** My ISR *****/

  void RTC_WKUP_IRQHandler(void)
  {
    if(RTC_GetITStatus(RTC_IT_WUT) != RESET)
    {
      /* Clear RTC and EXTI interrupt flags */
      RTC_ClearITPendingBit(RTC_IT_WUT);
      EXTI_ClearITPendingBit(EXTI_Line20);
      
      /* Code to wake suspended task goes here*/
    } 
  }
  
  /**********/


  /***** My Task *****/
  
  void SLP_Task( void *pvParameters )
  {
    while(1)
    {
      /* Reload the IWDG timeout */
      BSP_WDG_Checkin();

      /* Do Stuff */

      /* Send this task to suspended state */
      vTaskSuspend(TaskHandle);
    }
  }


If I use Low Power Sleep mode everything works fine, my interrupt occurs periodically and the MCU exits sleep mode and resets the IWDG.

If, however, I use Stop Mode my interrupt either doesn't occur or doesn't successfully bring the MCU out of stop mode. My device sits idle until the internal watchdog eventually times out causing a reset.

Can anyone give any advice as to what might be going wrong? Do I need to perform additional configuration of the interrupt, or on exit from stop mode, to get the device to wake which doesn't need to be performed for low power sleep?

Thanks

Outcomes