Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ULP wakeup (IDFGH-3261) #5254

Closed
fpgamaster opened this issue May 8, 2020 · 4 comments
Closed

ULP wakeup (IDFGH-3261) #5254

fpgamaster opened this issue May 8, 2020 · 4 comments
Labels
Resolution: Done Issue is done internally Status: Done Issue is done internally Type: Doc issue pertains to documentation of IDF Type: Feature Request Feature request for IDF

Comments

@fpgamaster
Copy link

I have an ULP code which runs from normal mode and from deep sleep.

To generate an interrupt (wake up) the following code is used:
.global wake_up
wake_up:
/* Check if the system can be woken up */
READ_RTC_FIELD(RTC_CNTL_LOW_POWER_ST_REG, RTC_CNTL_RDY_FOR_WAKEUP)
and r0, r0, 1
jump wake_up, eq

    /* Wake up the SoC, end program */
    wake
    /* Stop ULP timer */
    WRITE_RTC_FIELD(RTC_CNTL_STATE0_REG, RTC_CNTL_ULP_CP_SLP_TIMER_EN, 0)
    halt

BUT if the ULP code is started from normal mode the following code runs forever:
wake_up:
/* Check if the system can be woken up */
READ_RTC_FIELD(RTC_CNTL_LOW_POWER_ST_REG, RTC_CNTL_RDY_FOR_WAKEUP)
and r0, r0, 1
jump wake_up, eq

So, is there a way to detect whether the ULP code is running from a deep sleep or normal mode and to wake up properly?

@fpgamaster fpgamaster added the Type: Feature Request Feature request for IDF label May 8, 2020
@github-actions github-actions bot changed the title ULP wakeup ULP wakeup (IDFGH-3261) May 8, 2020
@Alvin1Zhang
Copy link
Collaborator

@fpgamaster Thanks for reporting this feature request, we will evaluate.

@igrr
Copy link
Member

igrr commented May 12, 2020

Hi @fpgamaster, It seems that there is a (yet undocumented) bit in the same RTC_CNTL_LOW_POWER_ST_REG register, RTC_CNTL_MAIN_STATE_IDLE (bit 27). If this bit is set, the system is not in the sleep mode (i.e. running normally).
Note that when this bit is not 1, it might also mean that the system is transitioning to or from the sleep mode. If the system is entering the sleep mode, you may wait until RTC_CNTL_RDY_FOR_WAKEUP bit is set — eventually it will get set and you will be able to wake up the system. On the other hand, if the system is exiting the sleep mode, RTC_CNTL_RDY_FOR_WAKEUP will not get set, but RTC_CNTL_MAIN_STATE_IDLE will eventually become set. You might need to take this into account when implementing your wake-up logic.

@fpgamaster
Copy link
Author

Hi @igrr , Thanks! This is exactly I was looking for. It looks like this is the same bit as in s2 RTC_CNTL_MAIN_STATE_IS_IDLE found in header files.

@AxelLin
Copy link
Contributor

AxelLin commented Feb 22, 2022

Hi @fpgamaster, It seems that there is a (yet undocumented) bit in the same RTC_CNTL_LOW_POWER_ST_REG register, RTC_CNTL_MAIN_STATE_IDLE (bit 27).

@igrr
This is asked again recently: #8341
Any chance to update the document?

@espressif-bot espressif-bot added the Status: In Progress Work is in progress label Sep 2, 2022
@espressif-bot espressif-bot added Resolution: NA Issue resolution is unavailable Status: Done Issue is done internally Resolution: Done Issue is done internally and removed Status: In Progress Work is in progress Resolution: NA Issue resolution is unavailable labels Sep 12, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Resolution: Done Issue is done internally Status: Done Issue is done internally Type: Doc issue pertains to documentation of IDF Type: Feature Request Feature request for IDF
Projects
None yet
Development

No branches or pull requests

6 participants