5 years, 10 months ago.

Accuracy of real-time clock?

I've noticed that over a period of about 3 or so hours my Nucleo board RTC is running about 3 minutes fast. I'm using the following code:

RTC Test

#include "mbed.h"

DigitalOut myled(LED1);

Serial pc(SERIAL_TX, SERIAL_RX);

int main() {
    
    pc.baud(115200);
    pc.printf("RTC example\r\n"); 
    set_time(1411381500); 
    pc.printf("Date and time are set.\r\n");

    while(1) {
        time_t seconds = time(NULL);
        pc.printf("Time as a basic string = %s\r", ctime(&seconds));
        myled = !myled;      
        wait(1);
    }
}

I'm assuming that this time drift is due to the RTC not using an external crystal? If this is the case, what is the modification needed to add an external crystal?

Thank you.

Question relating to:

Affordable and flexible platform to ease prototyping using a STM32F411RET6 microcontroller.

Hi Ceri,

Could you make a double check of the RTC P/N? I think the MAX3231 is a serial transceiver.

Regards,

Samuel

posted by Samuel Ramirez 23 Sep 2014

Hi, I've the same problem... have you find a solution? Let me know! thank you.

posted by Gigi Marz 11 Feb 2015

I think Samuel meant to put DS3231 is a precision RTC. Lots of boards around with the device and a battery made for the job.

Kind Regards

Duncan

posted by Duncan Wood 01 Sep 2017

1 Answer

5 years, 10 months ago.

Usually you just need a Crystal across the two pins, and 18pf to gnd on both pins.

but if you need accurate time, then consider MAX 3231 a real time clock with temperature stabilizer... 2 seconds a month!!!!!

Accepted Answer

Thank you Ceri.

posted by Jim Norton 23 Sep 2014

The 32KHz real time oscillator will not work with 18pf ! You need a 32.768KHz crystal with a load capacitance of 6pF. Most crystals used in PC boards or other chips have 12pF. With a 12pF crystal the oscillator won't start reliably. Use two 6.8 pF capacitor to ground. The LSE amp has a very low amp transconductance to reduce the power consumption.

See datasheet: " never use a resonator with a load capacitance of 12.5pF".

posted by Peter Drescher 23 Sep 2014

Hi Ceri,

Could you make a double check of the RTC P/N? I think the MAX3231 is a serial transceiver.

Regards,

Samuel

posted by Samuel Ramirez 23 Sep 2014