2022-08-25 05:00 PM
Dear, All.
I am trying to use HSE, but I ask for your help by continuously returning HAL_TIMEOUT from the HAL_RCC_OscConfig() function.
The test environment is as follows.
BOARD: NUCLEO-F303K8T6
IDE: STM32CubeIDE (latest version)
FIRMWARE: STM32Cube FW_F3 V1.11.3
The code generated by CubeIDE is as follows, and it is automatically generated, and the code has not been modified at all. RCC Mode is set to BYPASS Clock Source and Master Clock Output is disabled.
RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSE;
RCC_OscInitStruct.HSEState = RCC_HSE_BYPASS;
RCC_OscInitStruct.HSIState = RCC_HSI_ON;
RCC_OscInitStruct.PLL.PLLState = RCC_PLL_NONE;
if (HAL_RCC_OscConfig(&RCC_OscInitStruct) != HAL_OK)
{
Error_Handler();
}
If HSI is used, it works fine even if it is set to 64 MHz.
With HSE, several other NUCLEO-F303K8 HAL_TIMEOUT returned from the same location. And I don't remember exactly when I tested it, but when I tested it with CubeIDE a few years ago, everything worked fine.
The code that causes the timeout is the 265th line in the stm32f3xx_hal_rcc.c file.
while(__HAL_RCC_GET_FLAG(RCC_FLAG_HSERDY) == RESET)
I wll listen to any help. Thank you.
Solved! Go to Solution.
2022-08-29 07:24 AM
Hi @DBlac.1 ,
Thank you for sharing your questions, I will try to help you on your issue :) .
First can we try to find out where the issue come from ?
I'm seeing that your are using the RCC_HSE_BYPASS instead of the RCC_HSE_ON, if it's what's you want to do, make sure that the pins PF0 (OSC_IN) and PF1 (OSC_OUT) are connected to a waveform generator. Otherwise change it to RCC_HSE_ON ;) .
RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSE;
RCC_OscInitStruct.HSEState = RCC_HSE_BYPASS;
RCC_OscInitStruct.HSIState = RCC_HSI_ON;
RCC_OscInitStruct.PLL.PLLState = RCC_PLL_NONE;
if (HAL_RCC_OscConfig(&RCC_OscInitStruct) != HAL_OK)
{
Error_Handler();
}
Check also the hardware connection, by default your board using the HSI configuration : Refer to the section 6.8 "OSC clock" on the attached file.
Best regards,
A.MVE
2022-08-29 07:24 AM
Hi @DBlac.1 ,
Thank you for sharing your questions, I will try to help you on your issue :) .
First can we try to find out where the issue come from ?
I'm seeing that your are using the RCC_HSE_BYPASS instead of the RCC_HSE_ON, if it's what's you want to do, make sure that the pins PF0 (OSC_IN) and PF1 (OSC_OUT) are connected to a waveform generator. Otherwise change it to RCC_HSE_ON ;) .
RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSE;
RCC_OscInitStruct.HSEState = RCC_HSE_BYPASS;
RCC_OscInitStruct.HSIState = RCC_HSI_ON;
RCC_OscInitStruct.PLL.PLLState = RCC_PLL_NONE;
if (HAL_RCC_OscConfig(&RCC_OscInitStruct) != HAL_OK)
{
Error_Handler();
}
Check also the hardware connection, by default your board using the HSI configuration : Refer to the section 6.8 "OSC clock" on the attached file.
Best regards,
A.MVE
2022-08-29 08:55 AM
> make sure that the pins PF0 (OSC_IN) and PF1 (OSC_OUT) are connected to a waveform generator.
Or just make sure the solder bridges are set so that MCO from ST-LINK is connected to OSCIN (PF0).
Even if you'd want to connect external generator, you wouldn't connect it to PF1 (OSC_OUT)..
JW
2022-08-29 09:37 PM
Dear, A.MVE
Dear, waclawek.jan
I would like to express my best gratitude to both of you.
Fortunately, I found out what I misunderstood, and it was normalized after correcting that part.
The old version of Error_Handler() generated by Stm32CubeIDE had no code inside.
Therefore, when using the Optimize For Size (-Os) option, the compiler made the following code run for optimization regardless of the failure of HAL_RCC_OscConfig().
I misunderstood this as not returning a failure in HAL_RCC_OscConfig().
If the clock of the CPU is Bypassed, it would be better to return HAL_OK rather than HAL_TIMEOUT in the automatically generated code, but now I know what makes this result, and I am satisfied that the HAL of the old version and the latest version behave the same.
Thank you all, and I hope everything goes well all the time.
2022-08-29 09:44 PM
I really appreciate your reply.
2022-08-29 09:44 PM
I really appreciate your reply.