Skip to main content
oversc0re
Associate II
May 16, 2014
Question

RTC Flags problem when alarm is set

  • May 16, 2014
  • 0 replies
  • 520 views
Posted on May 16, 2014 at 13:37

Hi,

My RTC (F103) is currently running from LSI. The counter is counting properly, and the SEC flag in CRL is set every second as expected. When the Alarm is set, the SEC flag is asserted and cannot be cleared anymore. Also the alarm flag never gets set regardless of the value written to the ALRL and H registers. Here's an example: with

RTC_SetAlarm line commented, the led changes it's state once every second.

RTC_ClearFlag(RTC_FLAG_SEC);
while(RTC_GetFlagStatus(RTC_FLAG_SEC)==RESET);
//RTC_SetAlarm(RTC_GetCounter()+10);
RTC->CRL = 0;
while (1)
{
x = RTC_GetFlagStatus(RTC_FLAG_SEC);
if (x)
{
BRD_LedToggle(LD2);
RTC_ClearFlag(RTC_FLAG_SEC);
RTC->CRL = 0;
}
}

Uncommenting the

RTC_SetAlarm(RTC_GetCounter()+10) results in always true if condition that blinks the led on every iteration of the while loop. Clear flag does nothing and the flag is constantly asserted.

Can anyone replicate this problem? What would be the source of it?
    This topic has been closed for replies.