2013-09-05 01:22 AM
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); } }
2013-09-05 03:17 AM
Backup domain description
To retain the content of the RTC backup registers, backup SRAM, and supply the RTC when VDD is turned off, VBAT pin can be connected to an optional standby voltage supplied by a battery or by another source. To allow the RTC to operate even when the main digital supply (VDD) is turned off, the VBAT pin powers the following blocks: �? The RTC �? The LSE oscillator �? The backup SRAM when the low power backup regulator is enabled �? PC13 to PC15 I/Os, plus PI8 I/O (when available) The switch to the VBAT supply is controlled by the power-down reset embedded in the Reset block. Use LSE if you want to run from battery.