Skip to main content
Visitor II
August 7, 2024
Question

STM32L4 in Stop2 mode (Debug vs Release)

  • August 7, 2024
  • 1 reply
  • 1772 views

Good morning,

I have an application based on the STM32L475 device that is running in many devices since many years ago. We have observed that, sometimes, some of the devices are resetted --> Here you have the main specs of my device:

- Device is working in Stop2 mode

- It's is waking up every 31.25ms because of RTC interrupt, in order to do all the tasks. And then it goes back to stop2 mode

- Device has a watchdog implemented (1.5")

We have observed that some devices are automatically reseted sometimes: some devices are reseted many times par day, some devices are reseted a few times par day, or some devices are never reseted.

In order to allow us look for this reset reason, we have set device in debug mode, but surprisingly, in debug mode device is never stopped or reseted. So, we can not find the reset reason.

The main differences between debug and release mode are:

- Debug mode:

                   - Watchdog is obviously not working

                   - HAL_DBGMCU_EnableDBGStopMode function is called once before entering into main loop

All the other code is the same. And in the main loop we have this:

int main(void)
{
/* Clear reset flags in any cases */
 __HAL_RCC_CLEAR_RESET_FLAGS();

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

//Variables initialization
Var_Par_Init();


__HAL_RCC_WAKEUPSTOP_CLK_CONFIG(RCC_STOP_WAKEUPCLOCK_MSI);	

//Only in debug mode
#ifdef EN_DEBUG 
HAL_DBGMCU_EnableDBGStopMode();
#endif 

 while (1)
 { 
	
	Tasks();	

	if(Equip_STOP_Mode()==SI) //No task is running so we can go to stop2 mode
	{							
				
		//Enter into Stop2 mode
		HAL_PWREx_EnterSTOP2Mode(PWR_STOPENTRY_WFI);						
		//When exiting Stop2 mode, clock is re-setup
		SYSCLKConfig_STOP();				
							
	}
					
		
}
}

So, which is the difference between Debug and Release mode in this case? Any idea how to find the reason of these resets?

    This topic has been closed for replies.

    1 reply

    Super User
    August 7, 2024

    If the watchdog is resetting the chip, it's probably not being reloaded in time. Check that assumption.

    Toggle a pin every time you pet the watchdog, Verify that pin and the NRST line to verify if you're doing this in time. Probably you will find a delay of 1.5s before NRST drops low due to the watchdog.

    Are there other reasons to suspect your 31.25ms wakeup isn't occurring? Perhaps you have a race condition occurring here, or some other code error in the setup. Consider disabling the watchdog during debugging and implementing diagnostics to verify the 31.25ms wakeup always occurs.

    dtarragoAuthor
    Visitor II
    August 7, 2024

    31.25ms is always ocurring as this base time is used to manage all the functionality in what regards synchronization, and synchronization is always perfect.

    Furthermore, the whatdog is always refreshed using HAL_IWDG_Refresh, and this is done in the 'Tasks' function, that is contantly called once the device has woke up (every 31.25ms).

    In order to have more information: besides the differences in code I have detailed, which are other differences between Release and Debug mode?

    Super User
    August 7, 2024

    Release has higher optimization settings. It results in faster code which sometimes exposes bugs that are masked during Debug mode.