cancel
Showing results for 
Search instead for 
Did you mean: 

How to use watchdog with standby mode ?

isikli
Associate III

I am devoloping a low-power motion detector device using the STM32L071 mcu.
The PIR sensor wakes up the system through wake-up pin, and after completing the RF packet transmission, the system goes back to sleep. In other words, I have a system that continuously switches between standby and run modes.

How should I implement the watchdog in such a system ?

I don't want the watchdog to keep counting while the MCU is in standby mode. I only it to run during run mode.


My code like this (bare metal):

int main(void)
{

  /* USER CODE BEGIN 1 */
  config_getresetflags();
  /* USER CODE END 1 */

  /* MCU Configuration--------------------------------------------------------*/

  /* Reset of all peripherals, Initializes the Flash interface and the Systick. */
  HAL_Init();

  /* USER CODE BEGIN Init */

  /* USER CODE END Init */

  /* Configure the system clock */
  SystemClock_Config();

  /* USER CODE BEGIN SysInit */
  ws_register_sensor_driver(&ws_door_driver);
  ws_init_mx();
  ws_wkp_src();
  ws_init_selection();
  ws_pvd();
#if WS_MX_INIT_FUSE //closed part
  /* USER CODE END SysInit */

  /* Initialize all configured peripherals */
  MX_GPIO_Init();
  MX_DMA_Init();
  MX_SPI2_Init();
  MX_USART1_UART_Init();
  MX_TIM7_Init();
  MX_TIM6_Init();
  MX_RTC_Init();
  MX_ADC_Init();
  /* USER CODE BEGIN 2 */
#endif
  control.tick = HAL_GetTick();
  /* USER CODE END 2 */

  /* Infinite loop */
  /* USER CODE BEGIN WHILE */
  while (1)
  {
	loop(); // my tasks
    /* USER CODE END WHILE */

    /* USER CODE BEGIN 3 */
  }
  /* USER CODE END 3 */
}
 



1 REPLY 1
Gyessine
ST Employee

Hello @isikli 
>How should I implement the watchdog in such a system?
That depends on how you want to implement it and what functionality you want to achieve using the IWDG. Can you elaborate more?
However, I don't think you can freeze the watchdog in Standby mode in hardware with STM32L071. Most MCUs have an IWDG_STDBY 
option byte which can freeze the IWDG, but STM32L071 doesn't have it.
BR
Gyessine

To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.