cancel
Showing results for 
Search instead for 
Did you mean: 

STM32F401RE external crystal HSE issue

AkshaySindal
Visitor

Hello,

I am using Nucleo-F401RE MB1136, want to run the board using the HSE, installed 8Mhz crystal on X3 with 22pf capacitors on C33 & C34 and 0 Ohm resistors on R35 & R37.

Using the CubeMx, configured the HSE pin as Crystal/Ceramic Resonator, set the clock in the Crystal Configuration for HSE as 8Mhz, tried both the ways, directly using HSE as System Clock and with using the PLL block.

Still not able to run the code as the code gets stuck in SystemClock_Config(void), no pulse is generated on the crystal.

Is there any step that i missed or some configuration, please guide me if possible. I am new into the Stm world. Provided the snippet of the CubeMx generated code.

Thank You

 

__weak HAL_StatusTypeDef HAL_RCC_OscConfig(RCC_OscInitTypeDef  *RCC_OscInitStruct)
{
  uint32_t tickstart;
  uint32_t pll_config;
  /* Check Null pointer */
  if (RCC_OscInitStruct == NULL)
  {
    return HAL_ERROR;
  }

  /* Check the parameters */
  assert_param(IS_RCC_OSCILLATORTYPE(RCC_OscInitStruct->OscillatorType));
  /*------------------------------- HSE Configuration ------------------------*/
  if (((RCC_OscInitStruct->OscillatorType) & RCC_OSCILLATORTYPE_HSE) == RCC_OSCILLATORTYPE_HSE)
  {
    /* Check the parameters */
    assert_param(IS_RCC_HSE(RCC_OscInitStruct->HSEState));
    /* When the HSE is used as system clock or clock source for PLL in these cases HSE will not disabled */
    if ((__HAL_RCC_GET_SYSCLK_SOURCE() == RCC_CFGR_SWS_HSE) || \
        ((__HAL_RCC_GET_SYSCLK_SOURCE() == RCC_CFGR_SWS_PLL) && ((RCC->PLLCFGR & RCC_PLLCFGR_PLLSRC) == RCC_PLLCFGR_PLLSRC_HSE)))
    {
      if ((__HAL_RCC_GET_FLAG(RCC_FLAG_HSERDY) != RESET) && (RCC_OscInitStruct->HSEState == RCC_HSE_OFF))
      {
        return HAL_ERROR;
      }
    }
    else
    {
      /* Set the new HSE configuration ---------------------------------------*/
      __HAL_RCC_HSE_CONFIG(RCC_OscInitStruct->HSEState);

      /* Check the HSE State */
      if ((RCC_OscInitStruct->HSEState) != RCC_HSE_OFF)
      {
        /* Get Start Tick */
        tickstart = HAL_GetTick();

        /* Wait till HSE is ready */
        while (__HAL_RCC_GET_FLAG(RCC_FLAG_HSERDY) == RESET)
        {
          if ((HAL_GetTick() - tickstart) > HSE_TIMEOUT_VALUE)
          {
            return HAL_TIMEOUT;
          }
        }
      }

  

8 REPLIES 8
SofLit
ST Employee

Hello @AkshaySindal and welcome to the community,

Could you please share your ioc file? 

Are you sure the crystal you mounted is OK?

To give better visibility on the answered topics, please click on "Accept as Solution" on the reply which solved your issue or answered your question.
SofLit
ST Employee

Meanwhile, you can use STLINK-MCO as clock source  for the MCU instead of installing an external crystal.

The source of STLINK-MCO is generated from a 8MHz Crystal.

SofLit_0-1729166212368.png

So, you need just to check that SB16 and SB50 are soldered. You need also to remove the crystal and the capacitors you've already soldered and configure HSE in Bypass mode.

To give better visibility on the answered topics, please click on "Accept as Solution" on the reply which solved your issue or answered your question.
Peter BENSCH
ST Employee

Incidentally, this could also be a source of error: if you have not removed SB16 or SB50 while trying to use your own crystal at X3, the crystal will be disturbed by the MCO of the ST-LINK/V2-1.

In order to give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.
SofLit
ST Employee

@AkshaySindal did you mistakenly mark the solution?

To give better visibility on the answered topics, please click on "Accept as Solution" on the reply which solved your issue or answered your question.

yes i did it by mistake!

Yes i checked the continuity, looks OK, installed capactior and resistors too. I have attached the IOC file below.

The board works completely fine on HSI but i need to use the HSE.

I don't see an issue in the ioc file.

But did you check the recommendations shared by @Peter BENSCH , you need to disconnect STLINK-MCO from OSC_IN OSC_OUT pins of the MCU or just use STLINK-MCO as it is as I described in a previous comment.

To give better visibility on the answered topics, please click on "Accept as Solution" on the reply which solved your issue or answered your question.

I am trying his recommendation, can you please guide me on how to disconnect the STLINK-MCO from the MCU.