How to use watchdog with standby mode ?
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 */
}