cancel
Showing results for 
Search instead for 
Did you mean: 

Read RTC wakeup timer register on STM32L151

gcristian
Associate II
Posted on January 08, 2014 at 14:30

Hi Everybody,

I am using the RTC WakeUp Timer while in Stop mode. 

The MCU can either leave the Stop mode at the end of the timer, or on an external IRQ. At this level, everything is working perfectly.

However, when the MCU is awaken from the external IRQ, I want to read the value of the RTC WakeUp Timer register (RTC_WUTR) and this is not working.

The register RTC_WUTR always return the value it is set to, but not its current value.

I know the RTC WakeUp Timer is running but the register does not seems to update itself.

Is there anything specific that needs to be done to read this register? Is it possible it is somehow read protected?

Thanks in advance for your help!

#stop-mode #poor-quality-of-documentation #stm32l151 #rtc
6 REPLIES 6
Posted on January 08, 2014 at 16:30

I'm not using the L1, but the obvious starting point would be

/* Enable the PWR clock */
RCC_APB1PeriphClockCmd(RCC_APB1Periph_PWR, ENABLE);
/* Allow access to RTC */
PWR_RTCAccessCmd(ENABLE);

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
gcristian
Associate II
Posted on January 08, 2014 at 18:59

Hi Clive,

Thanks for the feedback. I tried that already but it didn't work.

There is actually a function to read the RTC WakeUp timer in the API (in stm32l1xx_rtc.c), the function is: RTC_GetWakeUpCounter()

However, even this function always return the value I have setup in the register.

Do you know if it is actually possible to read the current value of the WakeUp counter? 

I have been through every single document existing and I am now wondering if the value is not copied into another internal register which is handling the WakeUp event.

Can you enlighten me on how the WakeUp counter work on other STM devices?

Do you have example code on this? (sadly I found none in the example provided by ST)

Posted on January 09, 2014 at 08:56

You probably misunderstood the purpose of the available hardware registers, namely RTC_WUTR. It simply holds the reload value. The (down)counter itself is not available. Read the fine manual.

[EDIT] Oh, I see what confused you - in RM0038 rev 8, 19.3.4 on page 468, the functional description (starting with ''When the initialization sequence [...]) of the wakeup timer is mistakenly and confusingly left with the description of WUCKSEL[2:1]=11 case, whereas it is supposed to form a separate paragraph. Yes, the quality of manuals IS poor.

JW

gcristian
Associate II
Posted on January 09, 2014 at 10:00

Thanks, I feared this was the case.

I agree with you, the documentation is really poor. It would be easy to indicate the reload value can be read back but not the actual counter value...

From: waclawek.jan

Posted: Thursday, January 09, 2014 9:03 AM

Subject: Read RTC wakeup timer register on STM32L151

You probably misunderstood the purpose of the available hardware registers, namely RTC_WUTR. It simply holds the reload value. The (down)counter itself is not available. Read the fine manual.

[EDIT] Oh, I see what confused you - in RM0038 rev 8, 19.3.4 on page 468, the functional description (starting with ''When the initialization sequence [...]) of the wakeup timer is mistakenly and confusingly left with the description of WUCKSEL[2:1]=11 case, whereas it is supposed to form a separate paragraph. Yes, the quality of manuals IS poor.

JW

itayk
Associate II
Posted on April 30, 2014 at 10:26

Hi Cris,

I am having the same problem as you.

I want my application to stay in stop-mode as much time as possible (28 sec max).

To wake up from stop-mode I use the WUT of the RTC or an external interrupt.

When external interrupt wake up the device, my RTOS needs to know how much time had pasted, so, I thought reading the RTC WUT register is the perfect solution, but to my disappointment I did not succeed reading the timer itself, but only the reload value.

Is there any news with this post? Did you find some solution to this problem?

Thank you very much,

Itay

robertwood9170
Associate II
Posted on April 07, 2016 at 22:41

I have searched for any documentation that states that RTC->WUTR can not be read, despite having a function to read. This register is documented on page 531 of the Reference Manual (RM0038), but there is nothing there indicated reading it only returns the value programmed into it. Could you please direct me to documentation explaining this register can not be read? Reading it would be useful in a number of applications such as debugging (determining if it is running), and assuming it is not stopped at Wakeup, determining how much time is spent in Wakeup before going back to Stop. It is also possible that the documentation regarding waking from standby may need some clarification as this appears to be quite different from waking from Stop and I can't see this explained. One other undocumented item seems to be that RTC->ISR bits can be reset even when the RTC registers are protected.