cancel
Showing results for 
Search instead for 
Did you mean: 

RTC - STM32F407

juergen239955_stm1
Associate II
Posted on January 23, 2013 at 03:19

Dear colleagues,

      I'm planning on using the 32.768kHz LSE timer, and I would like to confirm that this timer is actually built into the STM32F407 I'm using (on Keil board, MCBSTM32F400). There's no clear documentation in any of the data sheets, whether LSE is actually a built-in timer, and what's the difference to LSI.

Thanks in advance,

JJ

8 REPLIES 8
Posted on January 23, 2013 at 09:16

Excuse me, but if THIS is not clear for you, how do you understand the more obscure features of the chip, e.g. the timers?

LSI is an internal RC oscillator, hence imprecise. LSE is intended to be controlled by a watch crystal (although it can be connected to an external oscillator). The existence of LSE is unambiguously given away by the existence of OSC32_IN and OSC32_OUT pins, multiplexed on PC14/PC15 and present on every package of the chip, see pinout tables in datasheet. There is ample reading in UM0090 (currently rev.3) - start perhaps at Fig13 (top portions), then chapter 6.2.4, 6.3.27, and don't miss also the related 5.1.2 (as LSE is in the battery backup supply domain - see among others Fig.8) and related registers.

JW

Posted on January 23, 2013 at 09:52

'I' is for ''

I

nternal'';

'E' is for ''

E

xternal''.

Posted on January 23, 2013 at 15:52

The critical thing to note, as Jan points out, is that only the LSE can run the RTC from battery when the primary supply is removed.

One might suppose that the LSI isn't used because it's more power hungry, and likely to be impacted by a falling input voltage. The F1's used to run at about 40 KHz and wandered all over the place.

As Andy illustrates the device can use internal and external sources, the internal ones are for cheap boards where a course clock is sufficient, and the external ones are for where you need accuracy and low power. If you want to use USB or CAN you will need an external crystal or oscillator.

I don't think the documentation is ambiguous, you just have multiple choices about where your clock sources come from, and you have to decide what's appropriate for your specific application. Being a synchronous device it's always going to need at least one.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
Posted on January 23, 2013 at 16:39

> The critical thing to note, as Jan points out, is that

> only the LSE can run the RTC from battery when the primary supply is removed.

This is misattribution - in fact, I did not even realize this before I read your note, Clive! :)

Also, it occured to me, that the expression ''external'', may be misleading - based solely on this word, Juergen might have thought that the *whole* oscillator is supposed to be external and that there is only an input for it; while this is one of the options, in fact the oscillator's amplifier is provided on-chip and in the majority of uses only the feedback element (usually the crystal) is supposed to be external...

JW

juergen239955_stm1
Associate II
Posted on January 23, 2013 at 20:36

OK, got it, just found that there's already a crystal on the eval board - I was confused by the fact that the LSE worked for me without adding a crystal. Thanks, guys!

JJ

Posted on January 23, 2013 at 21:02

This is misattribution - in fact, I did not even realize this before I read your note, Clive! :)

Well you stumbled into it by citing the fact that it's in the backup power domain. I'll rephrase it.

The point Jan made about the backup power domain is critical because the LSI is not in that domain, and the only way for the RTC run when the primary supply is removed is to us an LSE crystal. PC13,14,15 are also in this domain, and have lower speed and current specifications. The use of PC13 in low power designs should be critically reviewed.
Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
santoshpawar
Associate
Posted on March 10, 2015 at 10:21

Hi,

We are using stm32f407 internal rtc.

We are getting date time with time differance.

One second is added every eighth second .and GetLSIFrequency returns 37112.

Please Help us to solve this issue. 

Here Is RTC initialisation

void INIT_RtcConfiguration(void)

     {

          RTC_InitTypeDef RTC_InitStructure;

          //RTC_DateTypeDef RTC_DateStructure;

          //RTC_TimeTypeDef RTC_TimeStructure;

          short  RTCInitErrorStatus; 

          

          RCC_APB1PeriphClockCmd(RCC_APB1Periph_PWR , ENABLE);

          PWR_BackupAccessCmd(ENABLE);

          RCC_LSICmd(ENABLE);

          

                  

          /* Wait till LSI is ready */  

          while(RCC_GetFlagStatus(RCC_FLAG_LSIRDY) == RESET)

               {

               }

          

          /* Select the RTC Clock Source */

          RCC_RTCCLKConfig(RCC_RTCCLKSource_LSI);

          

          RCC_RTCCLKCmd(ENABLE);

          RTC_WaitForSynchro();

          /* Configure the RTC data register and RTC prescaler */

          RTC_InitStructure.RTC_AsynchPrediv = 0x7F;

          RTC_InitStructure.RTC_SynchPrediv  = 0xFF;//0xF9;//0xFF;

          RTC_InitStructure.RTC_HourFormat   = RTC_HourFormat_24;

          

          /* Check on RTC init */

          if (RTC_Init(&RTC_InitStructure) == ERROR)

               {

                    USART_SendBuffer(DEBUG_ON_PC_USART,''***** RTC Prescaler Config failed ********'',42);

               }

          //RTC_SmoothCalibConfig(RTC_SmoothCalibPeriod_8sec,RTC_SmoothCalibPlusPulses_Set,0x7F);

          RTC_SmoothCalibConfig(RTC_SmoothCalibPeriod_8sec,RTC_SmoothCalibPlusPulses_Set,0x01);          

          RTC_CalibOutputConfig(RTC_CalibOutput_1Hz);

          RTC_TimeStructure.RTC_H12     = RTC_H12_AM;

          

          //xprintf(''\r\nRTC Successfully Set'');

          //  RTC_TimeShow();

          

          RTC_GetDate(RTC_Format_BIN, &RTC_DateStructure);  

          //xprintf(''\n\rThe current Date is :  %0.2d:%0.2d:%0.2d'', RTC_DateStructure.RTC_Date, RTC_DateStructure.RTC_Month, RTC_DateStructure.RTC_Year-100);

          //xprintf(''The current Date is :  %d:%d:%d\n\r'', RTC_DateStructure.RTC_Date, RTC_DateStructure.RTC_Month, RTC_DateStructure.RTC_Year-100);

          

          RTC_GetTime(RTC_Format_BIN, &RTC_TimeStructure);

          //xprintf(''The current time is :  %d:%d:%d\n\r'', RTC_TimeStructure.RTC_Hours, RTC_TimeStructure.RTC_Minutes, RTC_TimeStructure.RTC_Seconds);

          /* Indicator for the RTC configuration */

          RTC_WriteBackupRegister(RTC_BKP_DR0, 0x32F2);

          

          

     }

system is Running at 72MHz.

Thanks and Regards,

Santosh pawar

Posted on March 10, 2015 at 12:46

If the clock is 37112 rather than 32768 then you're going to need to change the RTC prescaler to reflect the 12% difference.

The LSI clock is neither accurate or stable, Your should probably also verify it externally via a MCO pin and a meter, and review the computation in GetLSIFrequency, as it lacks precision.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..