Skip to main content
BBeck.1
Associate III
February 1, 2022
Solved

Is it possible to wake via RTC from shutdown?

  • February 1, 2022
  • 2 replies
  • 2425 views

I have tried the following on my DK2 dev board:

  1. Connect VBAT (verify that RTC is working as well)
  2. Set rtc alarm (30s into future or so)
  3. Power off via long press of "sleep" button
  4. Wait for alarm to wake RTC...

I have verified that the RTC is using the LSE clock, and that the RTC is working by powering system off for a bit and seeing that the RTC doesn't lose time.

Thanks,

Ben Beckwith

This topic has been closed for replies.
Best answer by PatrickF

Hi,

did you have setup the RTC TAMPALARM as push-pull output on PC13 (RTC_OUT1)?

Using such as following sequence (assuming other settings as default):

  • start LSE (if not already done)
  • unlock RTC access
  • start RTC as usual (if not already done)
  • RTC_CR.OSEL = 0b11 (enable WUT on TAMPALARM)
  • RTC_CR.WUTE = 0 (ensure wake up flag is first disabled)
  • RTC_SCR = 0x3F (clear WUTF)
  • RTC_CR.WUCKSEL = 0b100 (1Hz)
  • RTC_WUTR = 60 (e.g. for 60 seconds)
  • RTC_CR.WUTE = 1

Please refer to Reference Manual RTC section for details.

Regards.

2 replies

PatrickF
PatrickFBest answer
Technical Moderator
February 2, 2022

Hi,

did you have setup the RTC TAMPALARM as push-pull output on PC13 (RTC_OUT1)?

Using such as following sequence (assuming other settings as default):

  • start LSE (if not already done)
  • unlock RTC access
  • start RTC as usual (if not already done)
  • RTC_CR.OSEL = 0b11 (enable WUT on TAMPALARM)
  • RTC_CR.WUTE = 0 (ensure wake up flag is first disabled)
  • RTC_SCR = 0x3F (clear WUTF)
  • RTC_CR.WUCKSEL = 0b100 (1Hz)
  • RTC_WUTR = 60 (e.g. for 60 seconds)
  • RTC_CR.WUTE = 1

Please refer to Reference Manual RTC section for details.

Regards.

In order to give better visibility on the answered topics, please click on 'Best Answer' on the reply which solved your issue or answered your question.Tip of the day: Try Sidekick STM32 AI agent
BBeck.1
BBeck.1Author
Associate III
February 21, 2022

Partrick,

Thanks for your reply. Is there any linux utility to set RTC_CR.OSEL = 0b11?

Cheers,

Ben

PatrickF
Technical Moderator
February 22, 2022

Hi,

I'm not SW expert, but I think those specific settings belongs to TF-A (either during boot phase or during shutdown sequence). so TF-A need to be adapted.

On Linux, maybe possible to do some trials with devmem2 (apt-get install devmem2), if RTC access is not forbidden by security settings.

Note that with devmem2 you might need to play also with peripheral bus clock enable in RCC registers before accessing a peripheral.

Anyway, sound like on starter package on DK2 board that RTC is not secured and its bus clock is already enabled.

So, something like this might do the job for just a trial (Tested on a DK2 with a battery):

# unlock RTC access
devmem2 0x5C004024 w 0xCA
devmem2 0x5C004024 w 0x53
 
# OSEL=0b11, WUTE=0, WUCKSEL=0b11
devmem2 0x5C004018 w 0x00600004
# Clear WUTF
devmem2 0x5C00405C w 0x00000004
 
# WUTR=60
devmem2 0x5C004014 w 0x0000003C
 
# WUTE=1
devmem2 0x5C004018 w 0x00600404

after first wake, need to clear flag before next shutdown.

# unlock RTC access
devmem2 0x5C004024 w 0xCA
devmem2 0x5C004024 w 0x53
 
# Clear WUTF
devmem2 0x5C00405C w 0x00000004

But I remind this is only for trial as devmem2 is not a clean solution and might have side effects with other RTC usage by the system.

Regards

In order to give better visibility on the answered topics, please click on 'Best Answer' on the reply which solved your issue or answered your question.Tip of the day: Try Sidekick STM32 AI agent