cancel
Showing results for 
Search instead for 
Did you mean: 

HAL_TIMEOUT problem in HAL_RCC_OscConfig() function (NUCLEO-F303K8)

DBlac.1
Associate II

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.

0693W00000StnXBQAZ.png

1 ACCEPTED SOLUTION

Accepted Solutions
Aime
ST Employee

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 ?

  • Can you confirm that there is an external clock HSE connected on your board? And what is the frequency ?

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.

0693W00000StzL2QAJ.png 

Best regards,

A.MVE

View solution in original post

6 REPLIES 6
Aime
ST Employee

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 ?

  • Can you confirm that there is an external clock HSE connected on your board? And what is the frequency ?

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.

0693W00000StzL2QAJ.png 

Best regards,

A.MVE

> 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

DBlac.1
Associate II

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.

I really appreciate your reply.

I really appreciate your reply.

SNish
Associate II

Hello Aime
Thanks for commenting about OSC-IN setting for external OSC. (PF0)
I have similar question about this issue.

I am trying to use Nucleo-F303K8 with external clock from PF0(D7).
According to UM1956 Page33 Figure10.
Connection OSC-IN to PF0(D7) should be soldered SB6 ON and desoldered SB4.
It is mismatched on Table 6.

Actually shipped board setting SB6 is soldered as MCO from ST-LINK.

And it works correctly by ST-LINK clock.
I believe SB4 and SB6 in silk and circuits are opposite.

regards
Shigemal

 

 

SNish_1-1734008306511.png

 

SNish_0-1734006976284.png