cancel
Showing results for 
Search instead for 
Did you mean: 

RTC alarm is not accurate

jramirez
Associate II
Posted on April 30, 2009 at 16:45

RTC alarm is not accurate

1 REPLY 1
jramirez
Associate II
Posted on May 17, 2011 at 13:10

Hello all,

I am having some issues with my RTC alarm, Im using the stm32f103 dev kit from iar. I am trying to wake the MCU every second from stop mode with an rtc alarm i have succesfully set the interrupt and they unit is going to sleep then waking up but instead of every sencond it wakes up every 2 ! even tough im setting for that ie.

/* Wait till RTC Second event occurs */

RTC_ClearFlag(RTC_FLAG_SEC);

while(RTC_GetFlagStatus(RTC_FLAG_SEC) == RESET);

RTC_WaitForLastTask();

/* Alarm in 1 second */

RTC_SetAlarm(RTC_GetCounter()+1);

/* Wait until last write operation on RTC registers has finished */

RTC_WaitForLastTask();

PWR_EnterSTOPMode(PWR_Regulator_LowPower, PWR_STOPEntry_WFE);

Time_Show();

/* Configures system clock after wake-up from STOP: enable HSE, PLL and select

PLL as system clock source (HSE and PLL are disabled in STOP mode) */

SYSCLKConfig_STOP();

it funny because if i use the rtc sec interrupt instead of the alarm i get anice second interrupt but not from the alarm interrupt furthermore i have this debug string shooting to teraterm that tell me what the time is

************ Reset ************

Time Show

Time: 24:00:02

Time Show

Time: 24:00:04

Time Show

Time: 24:00:06

Time Show

Time: 24:00:08

Time Show

Time: 24:00:10

I am setting the time to be 24:00:00 but as you can see 2 seconds after is when the micro gets woken this tells me that the actual rtc is running fine but for some reason the alarm is screwed up somehow. I am running the micro at 8 mGz HSE and the rtc from the 32 khz LSE here is the RCC config for APB1 and APB2

/* HCLK = SYSCLK */

RCC_HCLKConfig(RCC_SYSCLK_Div1);

/* PCLK2 = HCLK */

RCC_PCLK2Config(RCC_HCLK_Div1);

/* PCLK1 = HCLK/2 */

RCC_PCLK1Config(RCC_HCLK_Div2);

any ideas guys ???

thank you