cancel
Showing results for 
Search instead for 
Did you mean: 

Problems in sleep mode using STM32CubeHALv1.7.0

Wassim Ben Chikha
Associate II
Posted on September 27, 2017 at 14:29

Hi,

I

use the

STM32L152RE

device

and

I

found some problems when I

execute

the sleep mode

in STM32CubeHALv1.7.0

.

In fact, w

hen I use the __HAL_PWR_VOLTAGESCALING_CONFIG function with PWR_REGULATOR_VOLTAGE_SCALE3 for

a

low frequenc

y (lower than 4MHz)

, this instruction

stops the

execut

ion

, 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.

P

lease, 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 execut

e

. 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 4

th

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

.

P

lease, can you verify if there

are

some problem

s

in the function

HAL_RCC_DeInit

?

T

hank you in advance.

Best regards,

Wassim Ben Chikha

Note: this post was migrated and contained many threaded conversations, some content may be missing.
18 REPLIES 18
Posted on October 04, 2017 at 09:28

Hello!

I tried to change the value of this variable

(PWR_REGULATOR_VOLTAGE_SCALE3)

from

PWR_CR_VOS (

0x00001800

)

to 0x0000C000. With this setting,

This setting leaves VOS unchanged , sets the reserved bit 15 and also sets LPRUN  bit14

0690X00000608PnQAI.png

For the second part of your question:

Please, can you verify if there are some problems in the function HAL_RCC_DeInit

It seems that HAL_RCC_DeInit function sets as systemclock the MSI , whithout check for MSIRDY flag in the RCC_CR register. Yes i thing this is a problem .

0690X00000608PsQAI.png

Regards

vf

Imen.D
ST Employee
Posted on October 04, 2017 at 11:56

Hello Wassim,

Your reported issue about

HAL_RCC_DeInit

function 

is raised internally for further review.

All your comments and suggestions are welcome to improve our solutions.

Best Regards

Imen

When your question is answered, please close this topic by clicking "Accept as Solution".
Thanks
Imen
Posted on October 04, 2017 at 12:00

Hello Imen,

Many thanks for your time and consideration.

Kind regards,

Wassim Ben Chikha

Posted on October 04, 2017 at 15:01

Hello Vangelis,

According to the RM0038 Reference manual, I agree with you that

changing the value of the variable

(PWR_REGULATOR_VOLTAGE_SCALE3)

from

PWR_CR_VOS (

0x00001800

)

to 0x0000C000, leaves VOS unchanged, sets the reserved bit 15 and also sets LPRUN  bit14. But, the __HAL_PWR_VOLTAGESCALING_CONFIG function using PWR_REGULATOR_VOLTAGE_SCALE3 (0x00001800) stops the execution. Thus, I think that there is an error in the definition of this value.

Posted on October 04, 2017 at 15:59

Hello again!

But, the __HAL_PWR_VOLTAGESCALING_CONFIG function using PWR_REGULATOR_VOLTAGE_SCALE3 (0x00001800) stops the execution.

I checked the

__HAL_PWR_VOLTAGESCALING_CONFIG and according to RM sets or clears the VOS bits.

I will try later to find why stops the execution .I have a board with L152.

It would help a lot if you post  some code here. Like an .IOC file and main func .

Regards

vf

Posted on October 04, 2017 at 16:21

Hello again,

In fact, when I use the function SystemClock_Config implemented in cube_hal_l1.c file (V1.0.0, date: 03-November 2014) with

a

low frequenc

y (lower than 4MHz: 1, 2 or 4MHz), I found that __HAL_PWR_VOLTAGESCALING_CONFIG function using PWR_REGULATOR_VOLTAGE_SCALE3 (0x00001800) stops the execution. Please can you verify if there is a possibility that VOS[1:0]= 00 for range 3 and VOS[1:0]=11: forbidden (bits are unchanged and keep the previous value, no voltage scaling range changed)? Indeed, _HAL_PWR_VOLTAGESCALING_CONFIG function using PWR_REGULATOR_VOLTAGE_SCALE3 (0x00000000) is executed without any problem.

Many thanks for your time and look forward for you response.

Best regards,

WBC

Posted on October 04, 2017 at 17:30

Hello again.

0690X00000608TjQAI.png

Does your code wait for VOSF flag?

If not , due to system clock stopping, your debugger will disonnect.

Take some care to follow theese note about change voltage scalling.

Regards

vf

Posted on October 04, 2017 at 17:39

Hi

wassimbenchikha

,

I have tested and checked this case with

STM32L152REdevice

, but I'm not able to reproduce this behavior.

Could you please share your code,so that it will be easier to understand the issue.

Kind Regards

Imen

When your question is answered, please close this topic by clicking "Accept as Solution".
Thanks
Imen
Posted on October 04, 2017 at 17:55

The original post was too long to process during our migration. Please click on the provided URL to read the original post. https://st--c.eu10.content.force.com/sfc/dist/version/download/?oid=00Db0000000YtG6&ids=0680X000006I6tR&d=%2Fa%2F0X0000000bxU%2F02L8trz3Y50eyBIS4_W29HgMiTmtyt8Frq6fimtjK_4&asPdf=false