2011-11-29 08:56 AM
We have an external 32.768 kHz oscillator (LSE).
Using the ST library, the initialization of the RTC goes out with ERROR on test of ISR.RSF bit and ISR.INITF bit in
RTC_WaitForSynchro() and RTC_Init(&RTC_InitStructure) functions.
We checked the signal 32 KHz on the MC01 (PA8) pin and it is OK.If we try with LSI clock source, it is OK : no ERROR.
What happens ? Do you have an idea ?
This is our source code (with RTX kernel) :
int main (void)
{
SystemInit();
RCC_APB2PeriphClockCmd(RCC_APB2Periph_SYSCFG,ENABLE);
RCC_APB1PeriphClockCmd(RCC_APB1Periph_PWR, ENABLE);
PWR_BackupAccessCmd(ENABLE);
RCC_LSEConfig(RCC_LSE_ON);
…
}
__task void _HORLOGE_Initialiser (void)
{
while (1)
{
while(RCC_GetFlagStatus(RCC_FLAG_LSERDY) == RESET);
RCC_RTCCLKConfig(RCC_RTCCLKSource_LSE);
RCC_RTCCLKCmd(ENABLE);
RTC_WaitForSynchro();
// Calendar ConfigurationRTC_InitStructure.RTC_AsynchPrediv = 0x7F;
RTC_InitStructure.RTC_SynchPrediv = 0xFF;
RTC_InitStructure.RTC_HourFormat = RTC_HourFormat_24;
RTC_Init(&RTC_InitStructure);
os_tsk_delete_self ();
} ;
}
2012-01-06 05:13 AM
Could you solve your problem? I also have a STM32F207 and initialize the RTC like you (LSE), but I have no problem with the initialization itself. My problem is that when I run power cycles (I have a battery) the RTC looses seconds!
2012-01-10 03:13 AM
Use code like this:
int main (void)
{SystemInit();
/* Enable the PWR clock */ RCC_APB1PeriphClockCmd(RCC_APB1Periph_PWR, ENABLE);/* Allow access to RTC */
PWR_BackupAccessCmd(ENABLE);/***Configures the External Low Speed oscillator (LSE)****/
RCC_LSEConfig(RCC_LSE_ON);/* Wait till LSE is ready */
while(RCC_GetFlagStatus(RCC_FLAG_LSERDY) == RESET) { }/* 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();/* Calendar Configuration with LSI supposed at 32KHz */
RTC_InitStructure.RTC_AsynchPrediv = 0x7F; RTC_InitStructure.RTC_SynchPrediv = 0xFF; RTC_InitStructure.RTC_HourFormat = RTC_HourFormat_24; RTC_Init(&RTC_InitStructure); .......while(1)
{ ..... //Read RTC Time Register ...... }…
}__task void _HORLOGE_Initialiser (void)
{while (1)
{os_tsk_delete_self ();
} ; }2012-08-21 05:37 AM
I have the same problem. I'm working on STM32F217VGT6 and when I want to configure LSE as the source clock of RTC it returns ERROR on synchonization and prescalers initialization. Did You found solution for this problem? Would be grateful for any help.
2012-08-21 06:01 AM
PWR/BKP domain needs to be clocked, and unlocked.
32KHz crystal needs to be 6pF or less. Verify clock is running. Show code.2012-08-21 07:03 AM
I'm using a 6pF cristal with 12pF external capacitors.
LSE clock is running, I've checked it on MCO1 output and it's stable.Here is code:(I'm using stm32f2xx_stdperiph_lib)int main(void){ SystemInit(); rcc_init(); RTC_init(); IO_init(); while(1){ }}static void rcc_init(void){ RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOA | RCC_AHB1Periph_GPIOB | RCC_AHB1Periph_GPIOC | RCC_AHB1Periph_GPIOD | RCC_AHB1Periph_GPIOE | RCC_AHB1Periph_DMA1 | RCC_AHB1Periph_DMA2 | RCC_AHB1Periph_BKPSRAM,ENABLE); RCC_APB2PeriphClockCmd(RCC_APB2Periph_USART1 | RCC_APB2Periph_SPI1 | RCC_APB2Periph_TIM1 | RCC_APB2Periph_SYSCFG,ENABLE); RCC_APB1PeriphClockCmd(RCC_APB1Periph_USART2 | RCC_APB1Periph_USART3 | RCC_APB1Periph_TIM2 | RCC_APB1Periph_TIM3 | RCC_APB1Periph_TIM4 | RCC_APB1Periph_TIM5 | RCC_APB1Periph_SPI3 | RCC_APB1Periph_PWR , ENABLE);}void RTC_init(void){ # Reset power domain PWR_DeInit(); # Allow access to RTC PWR_BackupAccessCmd(ENABLE); # Write protection DISABLE RTC_WriteProtectionCmd(DISABLE); # Enable LSE clock RCC_LSEConfig(RCC_LSE_ON); # Wait till LSE is ready while (RCC_GetFlagStatus(RCC_FLAG_LSERDY) == RESET); # COnfig MCO1 output RCC_MCO1Config(RCC_MCO1Source_LSE,RCC_MCO1Div_1); # Select LSE as RTC Clock Source RCC_RTCCLKConfig(RCC_RTCCLKSource_LSE); # Enable RTC Clock RCC_RTCCLKCmd(ENABLE); # Wait for RTC registers synchronization uint8_t odp = RTC_WaitForSynchro(); if(odp != 0){ #synchro OK LED1_ON();LED2_OFF(); }else{ #synchro ERROR LED2_ON();LED1_OFF(); }}Maybe i'm missing some thing obvious.2014-09-16 03:10 AM
We had this problem with our system too.
If we couldn't get synchronization (INITF set true), then we issuedRCC_BackupResetCmd(
ENABLE
); followed byRCC_BackupResetCmd(DIS
ABLE
); which made it work next time we tried. We think it was caused by our battery backup voltage dropping too low.2014-10-14 06:35 AM
I had a similar problem.
I found that I had to increase the timeout (SYNCHRO_TIMEOUT) for the RTC_WaitForSynchro() function from 0x008000 to 0x0F0000. I tried 0x010000 & 0x040000, but they did not consistently solve the problem, though 0x040000 was better. Vance2014-11-27 03:02 AM
I has the same problem with RTC_ISR_INITF flag.
I found error in usb_bsp.c file. /* enable the PWR clock */ RCC_APB1PeriphResetCmd(RCC_APB1Periph_PWR, ENABLE); ----->>> RCC_APB1PeriphClockCmd(RCC_APB1Periph_PWR, ENABLE);