cancel
Showing results for 
Search instead for 
Did you mean: 

using stm32f401rct6, two question, (1) system clock configured with a external 16Mhz crystal can work if it is set to 42Mhz but not at 84Mhz and (2) even if working will stuck at HAL_GetTick

JTse.1
Associate II

(1) cannot run at 84Mhz, it will stuck at Error Handler

 RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSE;

 RCC_OscInitStruct.HSEState = RCC_HSE_ON;

 RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON;

 RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_HSE;

 RCC_OscInitStruct.PLL.PLLM = 16;

 RCC_OscInitStruct.PLL.PLLN = 336;

 RCC_OscInitStruct.PLL.PLLP = RCC_PLLP_DIV8;

 RCC_OscInitStruct.PLL.PLLQ = 4;

 if (HAL_RCC_OscConfig(&RCC_OscInitStruct) != HAL_OK)

 {

  Error_Handler();

 }

(2) can run at 42Mhz but will keep looping inside the loop forever and cannot timeout

    /* Wait till HSE is ready */

    while(__HAL_RCC_GET_FLAG(RCC_FLAG_HSERDY) == RESET)

    {

     if((HAL_GetTick() - tickstart ) > HSE_TIMEOUT_VALUE)

     {

      return HAL_TIMEOUT;

     }

    }

   }

   else

10 REPLIES 10

What is your hardware? Is there a crystal connected to HSE pins?

JW

Javier1
Principal

@JTse.1​ 

  1. show us your pcb(detail on the XTAL)
  2. are you using cubeMX? , attach your cubeMX ".ioc" file
we dont need to firmware by ourselves, lets talk
Dear JW

Yes, I have a 16Mhz crystal connected

Part number: CRYSTAL, SMD, 16MHz, 2.5X2.0 CX2520SB27120D0FLJZZ

See attached

Noticed that in the circuits is a 1M resistor in series
This resistor was indicated in the generic design document , but it was not
Indicated in the reference manual. Could it be the problem?

The crystal used has been proven working in several board but using NXP ARM
The circuit there has the resistor in parallel with values from 33R to 10M
And some boards do not even have it installed

I am in the process of converting all my NXP boards to using ST CPU

I have another ST board with the same resistor but using only 33R and it worked

I suspect this 1M resistor value is too high, I am going to change to 33R since my other ST board is working.

I was mistaken, with HSE on, the code got stuck because the HSE rdy never got set

With only the internal 16Mhz, I can run the code

Still, I have some strange problems

But no matter what setting I did in stmcudeidse, I can turn on the PLL but the PLL rdy bit do not lock

The good news is that I can run the board using the default low speed setting but will need to get the HSE working in order to do
Mass production soon

john
Dear Javier

I am using stmcubeide

I have a 16Mhz crystal connected

Part number: CRYSTAL, SMD, 16MHz, 2.5X2.0 CX2520SB27120D0FLJZZ

See attached

Noticed that in the circuits is a 1M resistor in series
This resistor was indicated in the generic design document , but it was not
Indicated in the reference manual. Could it be the problem?

The crystal used has been proven working in several board but using NXP ARM
The circuit there has the resistor in parallel with values from 33R to 10M
And some boards do not even have it installed

I am in the process of converting all my NXP boards to using ST CPU

I have another ST board with the same resistor but using only 33R and it worked

I suspect this 1M resistor value is too high, I am going to change to 33R since my other ST board is working.

I was mistaken, with HSE on, the code got stuck because the HSE rdy never got set

With only the internal 16Mhz, I can run the code

Still, I have some strange problems

But no matter what setting I did in stmcudeidse, I can turn on the PLL but the PLL rdy bit do not lock

The good news is that I can run the board using the default low speed setting but will need to get the HSE working in order to do
Mass production soon

john
AScha.3
Chief II

your osc circuit should look like this:

0693W00000SuTY6QAN.png 

show your circuit, if you expect any useful help.

If you feel a post has answered your question, please click "Accept as Solution".
Dear AsCha

I am using stmcubeide

I have a 16Mhz crystal connected

Part number: CRYSTAL, SMD, 16MHz, 2.5X2.0 CX2520SB27120D0FLJZZ

See attached

Noticed that in the circuits is a 1M resistor in series
This resistor was indicated in the generic design document , but it was not
Indicated in the reference manual. Could it be the problem?

The crystal used has been proven working in several board but using NXP ARM
The circuit there has the resistor in parallel with values from 33R to 10M
And some boards do not even have it installed

I am in the process of converting all my NXP boards to using ST CPU

I have another ST board with the same resistor but using only 33R and it worked

I suspect this 1M resistor value is too high, I am going to change to 33R since my other ST board is working.

I was mistaken, with HSE on, the code got stuck because the HSE rdy never got set

With only the internal 16Mhz, I can run the code

Still, I have some strange problems

But no matter what setting I did in stmcudeidse, I can turn on the PLL but the PLL rdy bit do not lock

The good news is that I can run the board using the default low speed setting but will need to get the HSE working in order to do
Mass production soon
Piranha
Chief II

You posted the same post 3 times, each sentence is on a separate line and the space between lines consists of 3 empty lines. It's worse than spam! Edit those posts so that the topic is readable.

Please don't repetitively post the same material, post it once, everyone can see it.

Here's the App Note https://www.st.com/resource/en/application_note/cd00221665-oscillator-design-guide-for-stm8afals-stm32-mcus-and-mpus-stmicroelectronics.pdf

Show your circuit as constructed.

The HAL Tick requires SysTick to be up and running.

The crystal has to start. The output can be probed if you enable it's output on PA8/MCO pin.

The MCU can crash if the PLL and FLASH wait states are wrong.

Make sure HSE_VALUE define in stm32f4xx_hal_conf.h reflects the speed of your external crystal.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
Dear PiranhA
I do not understand where I posted 3 times?
I was just answering different people
I remember posting it once initially
And as for space and lines, it looks normal on my side
Even your reply shows my post looks normal
Pls help me to understand where did I go wrong?
john