AnsweredAssumed Answered

RTC fine until I write to the counter

Question asked by beals.william on Feb 1, 2016
Latest reply on Feb 13, 2016 by beals.william
I'm using an STM32F100RB.  I've started with the reference code RTC/Calendar/main.c and it all works fine until I try to use the RTC_SetCounter function.  All is OK when it gets called on startup with a value of 0. I get my regular interrupts every 1 second as expected.  However, as soon as I try to set a time later after the counter is running, I get stuck in an infinite RTC interrupt loop.

I'm still pretty new to this, but in doing some debugging, it looks like even though I call
RTC_ClearFlag(RTC_FLAG_SEC)
RTC_ClearITPendingBit(RTC_IT_SEC)

the RTC_CRL bit 0 for the seconds interrupt never gets cleared, so when I return from the interrupt, I just go back into it again.  I tried an infinite loop inside the ISR to keepon writing 0 to RTC_CRL until the bit gets cleared and it gets stuck there, I believe confirming this to be the issue. 

Weird part is that ISR works fine servicing 1-second interrupts until I do the write to the counter registers, so clearly gumming something up.  I'm using the reference code subroutines.  I figure there is something else ancillary I have messed up. 

Any suggestions appreciated.


Outcomes