cancel
Showing results for 
Search instead for 
Did you mean: 

Setting RTC wake up timer for perioic wake up

jrichards
Associate
Posted on July 17, 2011 at 21:55

I've pored over the user guide and various app notes but cannot seem to get the RTC wakeup timer to start running, so no WU interrupt and I get stuck in halt mode.

Can someone give me a difinitive checklist of what register bits need to be set/reset to get the timer started. I need to check that what I think I should be doing from reading the user manual is right.

Many thanks

Jeremy

3 REPLIES 3
Stm32User
Associate II
Posted on July 29, 2011 at 12:49

I am using STM8L151 with external 32khz crystal ( LSE)

Here is the setup code, in my application used as a 50ms systick interrupt

 CLK_PeripheralClockConfig(CLK_Peripheral_RTC, ENABLE);

 CLK_RTCClockConfig(CLK_RTCCLKSource_LSE, CLK_RTCCLKDiv_1);

 RTC_WakeUpClockConfig(RTC_WakeUpClock_RTCCLK_Div16);

 RTC_ITConfig(RTC_IT_WUT, ENABLE);

 

RTC_SetWakeUpCounter(_50ms_TIMER_VAL);

 RTC_WakeUpCmd(ENABLE);

then enable interrupts 

RTC_ITConfig(RTC_IT_WUT, ENABLE);

In interrupt handler clear the interrupt source 

if( RTC_GetFlagStatus(RTC_FLAG_WUTF) == SET )

{

   RTC_ClearITPendingBit(RTC_IT_WUT);

}

hakan23
Associate II
Posted on January 15, 2013 at 14:57

Hello Patrick

Are you still working with this processor ??

Can you please send the smallest possible complete example for this ??

best regards

  Hakan

Stm32User
Associate II
Posted on January 24, 2013 at 20:03

I would use the firmware library as its already written,tested and documented. You can then spend time on your application instead of wasting time re-writing something which already works. 

You can download the firmware library here:-

http://www.st.com/internet/com/SOFTWARE_RESOURCES/SW_COMPONENT/FIRMWARE/stm8l15x_stdperiph_lib.zip

If you really want to minimise the code size then for each of the function calls in the code strip out the lines of code you need.

For example 

 CLK_PeripheralClockConfig(CLK_Peripheral_RTC, ENABLE);

Find this function, look at the code and strip out the lines of code which actually enable the peripheral.