Skip to content

changed the stm32f1xx_hal_rcc.c to handle the HSE init properly #4777

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions targets/TARGET_STM/TARGET_STM32F1/device/stm32f1xx_hal_rcc.c
Original file line number Diff line number Diff line change
Expand Up @@ -285,6 +285,23 @@ HAL_StatusTypeDef HAL_RCC_OscConfig(RCC_OscInitTypeDef *RCC_OscInitStruct)
}
else
{
if((__HAL_RCC_GET_FLAG(RCC_CR_HSEBYP) != RESET) && (RCC_OscInitStruct->HSEState == RCC_HSE_ON))
{
/* if it's in bypass mode, and the new mode is HSE_ON, must disable the bypass first
which requires HSE off to be changed*/
CLEAR_BIT(RCC->CR, RCC_CR_HSEON); \
CLEAR_BIT(RCC->CR, RCC_CR_HSEBYP); \
tickstart = HAL_GetTick();

/* Wait till HSE is disabled */
while(__HAL_RCC_GET_FLAG(RCC_FLAG_HSERDY) != RESET)
{
if((HAL_GetTick() - tickstart ) > HSE_TIMEOUT_VALUE)
{
return HAL_TIMEOUT;
}
}
}
/* Set the new HSE configuration ---------------------------------------*/
__HAL_RCC_HSE_CONFIG(RCC_OscInitStruct->HSEState);

Expand Down