cancel
Showing results for 
Search instead for 
Did you mean: 

RTC fails synchronisation and initialisation

kdevine9
Associate II
Posted on November 14, 2013 at 05:19

Hello Forum

I have some code to initialise my RTC, compiled with Keil. This code works on the MCBSTM32F400 Keil eval board, but is not working on my target hardware. The program fails on ''RTC_WaitForSynchro'' and also on ''RTC_EnterInitMode''. I have disabled optimisation incase it is a hardware read issue.

The obvious conclusion would be that the crystal is not correct, however I am successfully clocking out a 32kHz signal from the LSE using the MCO1 output, which leads me to believe that the LSE clock must be working?

As a test, if I change the RTC clock source to use the LSI it also works.

The 32kHz crystal I am using is 12.5pF ''Abracon ABS07-32.768kHz-T''. I can't find anything in the datasheet or reference manual of the STM32F407 to suggest why this crystal wouldn't work, added to the fact that I am getting the 32kHz signal clocked out.

Here is a snippet of the code I am using:

/* Enable the PWR clock */

RCC_APB1PeriphClockCmd(RCC_APB1Periph_PWR, ENABLE);

/* Allow access to RTC */

PWR_BackupAccessCmd(ENABLE);

/* Reset BKP Domain */

RCC_BackupResetCmd(ENABLE);

RCC_BackupResetCmd(DISABLE);

/* Enable the LSE OSC */

RCC_LSEConfig(RCC_LSE_ON);

/* Wait till LSE is ready */  

while(RCC_GetFlagStatus(RCC_FLAG_LSERDY) == RESET)

{

}

/* Clock out the external oscillator */

RCC_MCO1Config(RCC_MCO1Source_LSE, RCC_MCO1Div_1);

/* Select the RTC Clock Source */

RCC_RTCCLKConfig(RCC_RTCCLKSource_LSE);

/* Enable the RTC Clock */

RCC_RTCCLKCmd(ENABLE);

/* Wait for RTC APB registers synchronisation */

RTC_WaitForSynchro();

/* Check on RTC init */

if (RTC_Init(&RTC_InitStructure) == ERROR)

{

    printf(''\n\r        /!\\***** RTC Prescaler Config failed ********/!\\ \n\r'');

}

I'd really appreciate it, if any one could help me and shed some light on this issue.

Cheers,

Kieran

#rtc #stm32 #rtc_waitforsynchro
2 REPLIES 2
garethdculver
Associate
Posted on November 18, 2013 at 04:27

Did you manage to resolve this issue? 

I am not using the exact same crystal, however I am getting a near identical problem.

Posted on November 18, 2013 at 09:09

What is your setup, what are the symptoms, and how do they fail short of your expectation?

JW