• Welcome to Andy's Workshop Forums. Please login or sign up.
 
May 04, 2024, 09:24:46 pm

News:

SMF - Just Installed!


stm32f4disco External RTC

Started by mhel, November 05, 2015, 04:33:38 pm

Previous topic - Next topic

mhel

Hello newbie here,
First off, thanks to Andy for sharing this very good library.

I'd like to use the LSE for the RTC, I've already installed
the crystal and other necessary hardware modification
that should make it work.
If anyone has a spare time, could you please modify the RTC
example for stm32f4 to use the external clock.
I want to display the time in my hd44780 LCD, I already got
the LCD sorted out. I just need a little nudge with RTC initialization thing.

TIA

Andy Brown

Hi,

Using the LSE on the F4 RTC should be as simple as changing this...


      Rtc<
        RtcLsiClockFeature<RtcMeasuredLsiFrequencyProvider>,  // we'll clock it from the LSI clock and calibrate the LSI using a timer
        RtcSecondInterruptFeature,                            // we want per-second interrupts
        RtcAlarmAInterruptFeature                             // we also want the alarm A interrupt
      > rtc;


to this...


      Rtc<
        RtcLseClockFeature,             // we'll clock it from the LSE clock
        RtcSecondInterruptFeature,      // we want per-second interrupts
        RtcAlarmAInterruptFeature       // we also want the alarm A interrupt
      > rtc;


Please try it and let me know how you get on.

- Andy
It's worse than that, it's physics Jim!

mhel

It works! I tried the rtc example with the suggested changes.
The orange LED PD13 is now blinking.
I just found out that the Rtc<> is defined in Rtc.h.
I was looking for it for more understanding.

Thanks so much.
--mhel

mhel

November 12, 2015, 04:50:03 pm #3 Last Edit: November 25, 2015, 04:48:07 pm by mhel
Hi,

I didn't want to open a new thread so I'll post my new query here.

I can't figure out how to keep the time when power is off, even though I have the VBat powered
by coin battery.

I'm simply doing it like this:

    FlagStatus flag;
    flag = RTC_GetFlagStatus(RTC_FLAG_INITS);
    if(flag == RESET){
_rtc.setTime(15, 22, 0);
_rtc.setDate(15, 11, 12, 5);
    }


Is checking INITS bit enough before setting the RTC?

(Note: I'm pretty new to C++, so I'm using the RTC as my learning project)

Edit: It might be hardware problem, as I see VBat dips to 1.2v after I remove power to VDD.