AnsweredAssumed Answered

STM32F0 deep sleep with TIM1 as time-base source

Question asked by Ariel G on Apr 9, 2018

Hi,

I having a problem to get in sleep mode when using TIM1 as time-base source instead sysTick.

When using sysTick I'm able to enter sleep mode with no problem.

I wish to use TIM1 as time-base source to be able to use freeRTOS in the future.

 

What is wrong with this simple example?

 

while (1)
{
    blinkLED();
    if(btnPressed)
    {
      HAL_SuspendTick();
      HAL_PWR_EnterSLEEPMode(PWR_MAINREGULATOR_ON, PWR_SLEEPENTRY_WFI);
      HAL_ResumeTick();
    }
  }

 

void blinkLED()
{
  HAL_GPIO_WritePin(LED3_GPIO_Port, LED3_Pin, 0);
  HAL_Delay(100);
  HAL_GPIO_WritePin(LED3_GPIO_Port, LED3_Pin, 1);
  HAL_Delay(100);
}

void HAL_GPIO_EXTI_Callback(uint16_t GPIO_Pin)
{
  if (GPIO_Pin == BTN_Pin)
  {
    if(btnPressed)
      btnPressed = 0;
    else
      btnPressed = 1;
  }
}

Outcomes