/** * @brief Wait 1 sec for LSE stabilization . * @param None. * @retval None. * Note : TIM4 is configured for a system clock = 2MHz */ void LSE_StabTime(void) { CLK_PeripheralClockConfig(CLK_Peripheral_TIM4, ENABLE); /* Configure TIM4 to generate an update event each 1 s */ TIM4_TimeBaseInit(TIM4_Prescaler_16384, 123); /* Clear update flag */ TIM4_ClearFlag(TIM4_FLAG_Update); /* Enable TIM4 */ TIM4_Cmd(ENABLE); /* Wait 1 sec */ while ( TIM4_GetFlagStatus(TIM4_FLAG_Update) == RESET ); TIM4_ClearFlag(TIM4_FLAG_Update); /* Disable TIM4 */ TIM4_Cmd(DISABLE); CLK_PeripheralClockConfig(CLK_Peripheral_TIM4, DISABLE); }