lse.c 666 B

1234567891011121314151617181920212223242526272829
  1. /**
  2. * @brief Wait 1 sec for LSE stabilization .
  3. * @param None.
  4. * @retval None.
  5. * Note : TIM4 is configured for a system clock = 2MHz
  6. */
  7. void LSE_StabTime(void)
  8. {
  9. CLK_PeripheralClockConfig(CLK_Peripheral_TIM4, ENABLE);
  10. /* Configure TIM4 to generate an update event each 1 s */
  11. TIM4_TimeBaseInit(TIM4_Prescaler_16384, 123);
  12. /* Clear update flag */
  13. TIM4_ClearFlag(TIM4_FLAG_Update);
  14. /* Enable TIM4 */
  15. TIM4_Cmd(ENABLE);
  16. /* Wait 1 sec */
  17. while ( TIM4_GetFlagStatus(TIM4_FLAG_Update) == RESET );
  18. TIM4_ClearFlag(TIM4_FLAG_Update);
  19. /* Disable TIM4 */
  20. TIM4_Cmd(DISABLE);
  21. CLK_PeripheralClockConfig(CLK_Peripheral_TIM4, DISABLE);
  22. }