Skip to main content
Omar Suárez
Senior
March 21, 2017
Question

STM32F7 - HSI configuration

  • March 21, 2017
  • 2 replies
  • 2675 views
Posted on March 21, 2017 at 13:12

Hi,

I am trying to configure a project in a STM32F769I-DISC1 board using TIM6, DAC1, the FMC connected to the external SDRAM and the DMA (to pass data between SDRAM and DAC).

I have generated the configuration using STM32CubeMX, everything compiles OK but when running the code the firmware is throwing me an error from the HSI configuration function.

The error comes from this line:

/* Check if HSI is used as system clock or as PLL source when PLL is selected as system clock */

    if((__HAL_RCC_GET_SYSCLK_SOURCE() == RCC_SYSCLKSOURCE_STATUS_HSI)

       || ((__HAL_RCC_GET_SYSCLK_SOURCE() == RCC_SYSCLKSOURCE_STATUS_PLLCLK) && ((RCC->PLLCFGR & RCC_PLLCFGR_PLLSRC) == RCC_PLLCFGR_PLLSRC_HSI)))

    {

      /* When HSI is used as system clock it will not disabled */

      if((__HAL_RCC_GET_FLAG(RCC_FLAG_HSIRDY) != RESET) && (RCC_OscInitStruct->HSIState != RCC_HSI_ON))

      {

        return HAL_ERROR;

      }

      /* Otherwise, just the calibration is allowed */

      else

      {

        /* Adjusts the Internal High Speed oscillator (HSI) calibration value.*/

        __HAL_RCC_HSI_CALIBRATIONVALUE_ADJUST(RCC_OscInitStruct->HSICalibrationValue);

      }

    }

It returns the HAL_ERROR here.

In STM32CubeMX I configured the RCC to work with the HSE from the board (25 MHz) so I don't understand why is the firmware having an issue with the HSI.

I  have attached also the RCC configuration in STM32CubeMX.

Any clue to fix this?

Thanks in advanced,

Omar

#stm32f7 #stm32cubemx
This topic has been closed for replies.

2 replies

Tesla DeLorean
Guru
March 21, 2017
Posted on March 21, 2017 at 13:47

I'd have to assume it relates to code earlier, and it making a determination that HSE didn't start. Start doing your debugging before this stepping through to be sure of the path to this point.

The 25 MHz clock source is from an oscillator, not a crystal, you'd probably need to make sure that the HSE is in BYPASS mode.

Tips, Buy me a coffee, or three.. PayPal VenmoUp vote any posts that you find helpful, it shows what's working..
Omar Suárez
Senior
March 21, 2017
Posted on March 21, 2017 at 15:18

I have changed the HSE mode from Crystal/Ceramic resonator to BYPASS mode but now the error seems to come from the HSI function:

if(((RCC_OscInitStruct->OscillatorType) & RCC_OSCILLATORTYPE_HSI) == RCC_OSCILLATORTYPE_HSI)

  {

    /* Check the parameters */

    assert_param(IS_RCC_HSI(RCC_OscInitStruct->HSIState));

    assert_param(IS_RCC_CALIBRATION_VALUE(RCC_OscInitStruct->HSICalibrationValue));

    

    /* Check if HSI is used as system clock or as PLL source when PLL is selected as system clock */

    if((__HAL_RCC_GET_SYSCLK_SOURCE() == RCC_SYSCLKSOURCE_STATUS_HSI)

       || ((__HAL_RCC_GET_SYSCLK_SOURCE() == RCC_SYSCLKSOURCE_STATUS_PLLCLK) && ((RCC->PLLCFGR & RCC_PLLCFGR_PLLSRC) == RCC_PLLCFGR_PLLSRC_HSI)))

    {

      /* When HSI is used as system clock it will not disabled */

      if((__HAL_RCC_GET_FLAG(RCC_FLAG_HSIRDY) != RESET) && (RCC_OscInitStruct->HSIState != RCC_HSI_ON))

      {

        return HAL_ERROR;

      }

      /* Otherwise, just the calibration is allowed */

      else

      {

        /* Adjusts the Internal High Speed oscillator (HSI) calibration value.*/

        __HAL_RCC_HSI_CALIBRATIONVALUE_ADJUST(RCC_OscInitStruct->HSICalibrationValue);

      }

[.......]

Seems to come from the 'if' statement where HSI si checked as not disable.

I was executing the code step by step three or four times, but everything works until this line now.

Does it make sense to you?

Thanks,

Omar

Tesla DeLorean
Guru
March 21, 2017
Posted on March 21, 2017 at 15:26

Not really. You'd want to inspect the RCC registers in the debugger, and perhaps scope the HSE clock source.

The part should start running from the 16 MHz HSI, if you don't reconfigure the clocks it will continue to do so. If the HSI was non-functional the part would not start and you would not be able to debug.

Tips, Buy me a coffee, or three.. PayPal VenmoUp vote any posts that you find helpful, it shows what's working..
Jeanne Joly
Associate
April 28, 2017
Posted on April 28, 2017 at 09:28

Hello

Su_rez.Omar

and

Turvey.Clive.002

,

I would inform you that anew patch

http://www.st.com/content/st_com/en/products/development-tools/software-development-tools/stm32-software-development-tools/stm32-configurators-and-code-generators/stm32cubemx.html

V 4.1is available to fix this issue.

Sorry for any inconvenience this may cause you.

BR. Eric