title: How to setup the stm32f4 real time clock(RTC) to get valid values in the sub second register?
body: <p>I like to use my stm32f412 RTC at high resolution. For testing I use CubeMX code generator.
  For reading the rtc timestamp I am using:</p>
  <pre><code>// get sub second
  ss = (u16_t) LL_RTC_TS_GetSubSecond(RTC);
  // 0x00HHMMSS in bcd format
  t = LL_RTC_TIME_Get(RTC);
  // 0xWWDDMMYY
  d = LL_RTC_DATE_Get(RTC);
  </code></pre>
  <p>The rtc is using a 32.768kHz osc at PC14 &amp; PC15(LSE input). The setup code looks like:</p>
  <pre><code>static LL_RTC_InitTypeDef const initData = {
      .HourFormat = LL_RTC_HOURFORMAT_24HOUR,
      /* prescaler values for LSE @ 32768 Hz */
      .AsynchPrescaler = 0x7F,
      .SynchPrescaler = 0x00FF
  };
  
  LL_PWR_EnableBkUpAccess();
  LL_RCC_ForceBackupDomainReset();
  LL_RCC_ReleaseBackupDomainReset();
  
  LL_RCC_LSE_Enable();
  
  /* Wait untill LSE is ready */
  while (LL_RCC_LSE_IsReady() != 1) {};
  
  LL_RCC_SetRTCClockSource(LL_RCC_RTC_CLKSOURCE_LSE);
  
  LL_RCC_EnableRTC();
  
  if (LL_RTC_DeInit(RTC) != SUCCESS) {
      return -EIO;
  }
  
  if (LL_RTC_Init(RTC, (LL_RTC_InitTypeDef *)&amp;initData) != SUCCESS) {
      return -EIO;
  }
  
  LL_RTC_EnableShadowRegBypass(RTC);
  </code></pre>
  <p>Guess I am missing some steps in the setup.
  Any ideas?</p>