I use the STM32L152RE device and I found some problems when I execute the sleep mode in STM32CubeHALv1.7.0. In fact, when I use the __HAL_PWR_VOLTAGESCALING_CONFIG function with PWR_REGULATOR_VOLTAGE_SCALE3 for a low frequency (lower than 4MHz), this instruction stops the execution, while this function is executed for the two other ranges (PWR_REGULATOR_VOLTAGE_SCALE1 and PWR_REGULATOR_VOLTAGE_SCALE2). I tried to change the value of this variable (PWR_REGULATOR_VOLTAGE_SCALE3) from PWR_CR_VOS (0x00001800) to 0x0000C000. With this setting, the function runs. Please, is it possible to check if there is an error in the definition of this value?
In the other hand, the HAL_RCC_DeInit function does not execute. Indeed, the execution is stopped in the function of switching the SYSCLK to MSI (CLEAR_BIT(RCC->CFGR, RCC_CFGR_SW);). When, I change this function CLEAR_BIT by SET_BIT function and change the order of the 4th instruction (Reset CFGR register) before the instruction switch SYSCLK to MSI, the code is executed and the sleep mode outperforms the normal mode in terms of energy consumption. Please, can you verify if there are some problems in the function HAL_RCC_DeInit?
Thank you in advance.
Wassim Ben Chikha