cancel
Showing results for 
Search instead for 
Did you mean: 

I am using DWM1000 on a board with a microcontroller STM32L431CC. I am facing a strange issue when the battery becomes weak and can’t provide the power needed for DWM1000 initialization.

DamienAdveez
Associate II

Hello,

I am using DWM1000 on a board with a microcontroller STM32L431CC. I am facing a strange issue when the battery becomes weak and can’t provide the power needed for DWM1000 initialization.

When the battery is too weak, the board resets because of DWM1000 initialization. After a random number of attemps, the microcontroller does not start anymore. At this point, i am not able to do anything with my board, it is like the code have been erased or the microcontroller is locked in a strange state. Even after disconnecting the battery or connecting a new one, it doesn’t start again. The only way to make it work again is to reflash the board.

I can avoid this problem by putting a 500ms delay before DWM1000 initialization when my boards resets, but i would like to know if this is a known issue ? Is it possible that STM32L431CC locks or loses the code ?

Here you can see the power voltage applied with the weak battery. At the first three attempts of connecting the battery, the battery is too weak to initialize DWM1000. At the fourth attempt, the code has kind of disappeared…

6 REPLIES 6
Piranha
Chief II

Does your code use flash erase or write? EEPROM emulation or something similar? Using system bootloader or own made?

DamienAdveez
Associate II

My code uses flash write/read.

But it does not use any system bootloader or EEPROM emulation.

Additionally, I realized that the 500ms delay does not change the problem.

> My code uses flash write/read.

This usually involves an erase.

For technological reason, power consumption is inreased for Flash erase/program operations, aggravating to the problem.

Only ST would know what happens if the MCU browns out while erasing a Flash sector.

DamienAdveez
Associate II

Even when i comment out the code parts relatives to flash write or read, it has the same behaviour.

DamienAdveez
Associate II

It seems it comes from my configuration function of the IWDG :

bool bHILSTM_ConfigureWatchdog(void)

{

   bool   __b_Result = true;

   FLASH_OBProgramInitTypeDef __t_FlashUserConfig;

   if(   HAL_FLASH_Unlock() != HAL_OK )

   {

      __b_Result = false;

   }

   if(   HAL_FLASH_OB_Unlock() != HAL_OK)

   {

      __b_Result = false;

   }

   __t_FlashUserConfig.OptionType = OPTIONBYTE_USER;

   __t_FlashUserConfig.USERConfig = OB_BOOT0_FROM_OB;

   __t_FlashUserConfig.USERType = OB_USER_nSWBOOT0;

   if(   HAL_FLASHEx_OBProgram(&__t_FlashUserConfig) != HAL_OK)

   {

      __b_Result = false;

   }

   __t_FlashUserConfig.OptionType = OPTIONBYTE_USER;

   __t_FlashUserConfig.USERConfig = OB_BOOT0_SET;

   __t_FlashUserConfig.USERType = OB_USER_nBOOT0;

   if(   HAL_FLASHEx_OBProgram(&__t_FlashUserConfig) != HAL_OK)

   {

      __b_Result = false;

   }

   __t_FlashUserConfig.OptionType = OPTIONBYTE_USER;

   __t_FlashUserConfig.USERConfig = OB_IWDG_STDBY_FREEZE;

   __t_FlashUserConfig.USERType = OB_USER_IWDG_STDBY;

   if(   HAL_FLASHEx_OBProgram(&__t_FlashUserConfig) != HAL_OK)

   {

      __b_Result = false;

   }

   if(   HAL_FLASH_OB_Lock() != HAL_OK)

   {

      __b_Result = false;

   }

   if(   HAL_FLASH_Lock() != HAL_OK)

   {

      __b_Result = false;

   }

   if(   HAL_FLASH_OB_Launch() != HAL_OK)

   {

      __b_Result = false;

   }

   return __b_Result;

}

Then i just call the following function but if comment it out, i still have the problem, so it comes from the previous function : bHILSTM_ConfigureWatchdog()

bool bHILSTM_EnableWatchdog(void)

{

   bool   __b_Result = false;

   /* Watchdog set to 5s */

   _t_WatchdogHandle.Instance = IWDG;

   _t_WatchdogHandle.Init.Prescaler = IWDG_PRESCALER_128;

   _t_WatchdogHandle.Init.Reload = 1250U;

   _t_WatchdogHandle.Init.Window = IWDG_WINDOW_DISABLE;

   if(HAL_IWDG_Init(&_t_WatchdogHandle) == HAL_OK)

   {

      __b_Result = true;

   }

   return __b_Result;

}

DamienAdveez
Associate II

Adding a 1s delay before calling bHILSTM_ConfigureWatchdog(); solved my issue but could you help me to avoid this issue without it ?