AnsweredAssumed Answered

Using LSI oscillator as clock source for RTC STM32F205

Question asked by A2 on Sep 5, 2013
Latest reply on Sep 5, 2013 by John F.
From example code given in STM32F2 , I used RTC example & use it with LSI.
I have 3V on Vbat pin. I found that when VDD gets removed LSI oscillator gets off also, even if Vbat is present. Is it property of LSI or I am making some mistake in correct operation of RTC. However once RTC_BKP_DR0   is written on initialization , it maintains its value.

void rtc(void)
{
    RTC_InitTypeDef RTC_InitStructure;
    RTC_TimeTypeDef RTC_TimeStructure;
    RTC_DateTypeDef RTC_DateStructure;   
    
    if(RTC_ReadBackupRegister(RTC_BKP_DR0) != 0x32F2)
    { 
    /* RTC configuration  */
        RTC_Config();
        
    /* Configure the RTC data register and RTC prescaler */
        RTC_InitStructure.RTC_AsynchPrediv = AsynchPrediv;
        RTC_InitStructure.RTC_SynchPrediv = SynchPrediv;
        RTC_InitStructure.RTC_HourFormat = RTC_HourFormat_12;


    /* Check on RTC init */
        if (RTC_Init(&RTC_InitStructure) == ERROR)
        {
            while(1);
        }  


        RTC_TimeRegulate();        
    }    


    else
    { 
    /* Check if the Power On Reset flag is set */
        if(RCC_GetFlagStatus(RCC_FLAG_PORRST) != RESET)
        {
    //        printf("\r\n Power On Reset occurred....\n\r");
        }
    /* Check if the Pin Reset flag is set */
        else if (RCC_GetFlagStatus(RCC_FLAG_PINRST) != RESET)
        {
            //printf("\r\n External Reset occurred....\n\r");
        }
        

/* check if LSI is on */      
      AsynchPrediv = RCC->CSR;  /*  return zero in LSB indicating LSI is off */

  
        
    /* Enable the PWR clock */
        RCC_APB1PeriphClockCmd(RCC_APB1Periph_PWR, ENABLE);


    /* Allow access to RTC */
        PWR_BackupAccessCmd(ENABLE);


    /* Wait for RTC APB registers synchronisation */
        RTC_WaitForSynchro();
    }    
  
    while(1)
    {
        configure_tim3_wait( 100000 );
        RTC_GetTime(RTC_Format_BIN, &RTC_TimeStructure);
        RTC_GetDate(RTC_Format_BIN, &RTC_DateStructure);        
    }    
  
    
}

Outcomes