10 years, 2 months ago.

RTC - External Crystal - Nucleo

I soldered on a 32 Khz to use as the LSE for the RTC, will the mbed time library take that into consideration? If not, how can I enable it to use the onboard rtc ?

T

3 Answers

10 years, 2 months ago.

It should automatically detect it and use it, but I have seen issues where it didn't really work, so if you got a scope check out if it oscillates, if yes, then iti s used.

10 years, 1 month ago.

You need a 32Khz crystal with 6 pF ! Most 32Khz crystals have 12 pF. The oscillator will not start with a 12pF crystal. You have to desolder SB49 and SB48 on the backside and place them to R34 and R36. Also C32 and C32 have to be fitted with 4.7pF or 6.8pF. The startup of the oscillator is critical !

If you attach the crystal with a scope probe it will not start !

You can check if the oscillator is running with this code :

#include "mbed.h"
#include "rtc_api.h"

DigitalOut myled(LED1);

int main() {
    
    rtc_init();
    //set_time(1387188323); // Set RTC time to 16 December 2013 10:05:23 UTC
                          // this will start the external osc  
    
    if(RCC_GetFlagStatus(RCC_FLAG_LSERDY)) {  // 32khz osc is running
        while(1) {
            myled = !myled;
            wait(1.0);
            }
    }
    else myled = 1;   // error - external osc is not running    
}

If the led is blinking the oscillator run.

Erick and Peter,
thanks your hints.
I summarize the problem in my notebook below.
http://developer.mbed.org/users/kenjiArai/notebook/nucleo-series-clock-structure-and-xtal-oscillation/
Route case is (a)load capacitors (Peter pointed out) and (b) time-out setting in "HAL_RCC_OscConfig" function.

posted by Kenji Arai 25 Oct 2014
10 years ago.

Hi Tom,
Please try following program.
http://developer.mbed.org/users/kenjiArai/code/Nucleo_RTC_Clock_setting/
You can use "CheckRTC" library(subroutine) for your own application.