2402 views|5 replies

1643

Posts

0

Resources
The OP
 

Please tell me the setting function of deep sleep [Copy link]

邀请:@chunyang   @damiaa   @freebsder   @dcexpert   参与回复

This post was last edited by Shenzhen Xiaohua on 2021-6-26 06:05

Please see if the following function can achieve its: When the parameter is FALSE: it will not automatically enter sleep mode after waking up, assuming that the first bit of SCR is 1 before entering the function

/**
******************************************************************************
** \brief Enter deep sleep mode
**
** \input bOnExit - TRUE: After exiting exception handling, it will automatically enter sleep again;
** FALSE: It will not automatically enter sleep after waking up
**
** \retval NULL
*****************************************************************************/
void Lpm_GotoDeepSleep(boolean_t bOnExit) // ? Error FALSE: It will not automatically enter sleep after waking up It seems that it will not work when it is FALSE
{
SCB->SCR |= SCB_SCR_SLEEPDEEP_Msk;
SCB->SCR |= 1u<<bOnExit;

// When bOnExit = TRUE, 1 < 1 = 2, that is, set the first bit of SCR to 1 to realize the function that when exiting the exception handling and returning to the program thread, the processor automatically enters the sleep mode (WFI) // When bOnExit = false, 1 < 0 = 1, that is, set the 0th bit of SCR to 1, which has no effect on the 1st and 2nd bits of SCR

// i.e. SCB->SCR |= 1u<<0 --> SCB->SCR |= 1u Set bit 0 to 1 and have no effect on bit 1

That is, when the first bit is 1, you cannot change the first bit 1 to 0.

It also fails to achieve the expected function of [no longer automatically entering sleep after waking up]

It is still in the state of [Automatically enter sleep again after exiting exception handling]

}

Please check if my analysis in red font is correct. Thank you. Another question is what is the initial value of SCR after power-on reset of the microcontroller? Thank you.

This post is from MCU

Latest reply

I don't know if setting it to 1 will have any effect, but setting it to 0 will definitely have no effect, so in this case just follow the manual for safety. Maybe the manufacturer knows what function setting this bit to 1 will have, but doesn't intend to open this function to you, so they stipulate that this bit must be 0.   Details Published on 2021-7-17 11:58
 

242

Posts

0

Resources
2
 

You are so hardworking, don’t you sleep?

image.png (2.38 KB, downloads: 0)

image.png
This post is from MCU

Comments

Due to the pressure of life, no one wants to get up early.  Details Published on 2021-6-26 09:29
 
 

1643

Posts

0

Resources
3
 
Deeply confused published on 2021-6-26 09:05 You are so hardworking, don’t you sleep?

Due to the pressure of life, no one wants to get up early.

This post is from MCU
 
 
 

242

Posts

0

Resources
4
 

What is the initial value of SCR after power-on reset of the microcontroller? Reset value: 0x0000 0000

I don't know what's going on with your problem, but I found a problem in your program:

You said: "That is, SCB->SCR |= 1u<<0 --> SCB->SCR |= 1u sets bit 0 to 1, which has no effect on bit 1." This is true, but it does have an effect on bit 0. The manual says that bit 0 must remain 0.

This post is from MCU

Comments

Thank you very much. The program is not written by me, but a piece of code from a program downloaded from the Internet. Since it is reserved, why is it required to be 0?  Details Published on 2021-6-26 15:50
 
 
 

1643

Posts

0

Resources
5
 
Deep confusion published on 2021-6-26 10:00 What is the initial value of SCR after power-on reset of the microcontroller? Reset value: 0x0000 0000 Not for your question...

Thank you very much. The program is not written by me, but a piece of code from a program downloaded from the Internet.

Since it is reserved, why is it required to be 0?

image.png (12.75 KB, downloads: 0)

image.png
This post is from MCU

Comments

I don't know if setting it to 1 will have any effect, but setting it to 0 will definitely have no effect, so in this case just follow the manual for safety. Maybe the manufacturer knows what function setting this bit to 1 will have, but doesn't intend to open this function to you, so they stipulate that this bit must be 0.  Details Published on 2021-7-17 11:58
 
 
 

242

Posts

0

Resources
6
 
Shenzhen Xiaohua published on 2021-6-26 15:50 Thank you very much. The program was not written by me, but a piece of code from a program downloaded from the Internet. Since it is reserved, why is it required to be 0...

I don't know if setting it to 1 will have any effect, but setting it to 0 will definitely have no effect, so in this case just follow the manual for safety. Maybe the manufacturer knows what function setting this bit to 1 will have, but doesn't intend to open this function to you, so they stipulate that this bit must be 0.

This post is from MCU
 
 
 

Guess Your Favourite
Just looking around
Find a datasheet?

EEWorld Datasheet Technical Support

Related articles more>>

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

About Us Customer Service Contact Information Datasheet Sitemap LatestNews

Room 1530, Zhongguancun MOOC Times Building, Block B, 18 Zhongguancun Street, Haidian District, Beijing 100190, China Tel:(010)82350740 Postcode:100190

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京B2-20211791 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号
快速回复 返回顶部 Return list