cancel
Showing results for 
Search instead for 
Did you mean: 

system clock configuration issue - STM32L0538 – Discovery board

kobi nis
Associate
Posted on August 13, 2017 at 13:49

Hi,

I have the following issue on STM32L0538 – Discovery board:

I'm trying to configure the system clock to 65 KHz by MSI oscillator but it's failed.

It's crash inside the function 'HAL_RCC_OscConfig'.

For all the other frequency of MSI it doesn’t crash and work ok.

I also tried to run it without debug, doesn't work.

my code: (crash in the red line)

void SystemClock_Config(void)

{

   RCC_ClkInitTypeDef RCC_ClkInitStruct;

  RCC_OscInitTypeDef RCC_OscInitStruct;

  /* Enable Power Control clock */

  __HAL_RCC_PWR_CLK_ENABLE();

  /* The voltage scaling allows optimizing the power consumption when the device is

     clocked below the maximum system frequency, to update the voltage scaling value

     regarding system frequency refer to product datasheet.  */

  __HAL_PWR_VOLTAGESCALING_CONFIG(PWR_REGULATOR_VOLTAGE_SCALE3);

  /* Enable MSI Oscillator */

  RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_MSI;

  RCC_OscInitStruct.MSIState = RCC_MSI_ON;

  RCC_OscInitStruct.MSIClockRange = RCC_MSIRANGE_0;

  RCC_OscInitStruct.MSICalibrationValue = 0;

  RCC_OscInitStruct.PLL.PLLState = RCC_PLL_NONE;

 

if (HAL_RCC_OscConfig(&RCC_OscInitStruct)!= HAL_OK)

  {

    Error_Handler();

  }

}

Inside HAL_RCC_OscConfig (it's crash at the green line):

        {

          /* Else, keep current flash latency while decreasing applies */

          /* Selects the Multiple Speed oscillator (MSI) clock range .*/

         

__HAL_RCC_MSI_RANGE_CONFIG(RCC_OscInitStruct->MSIClockRange);

          /* Adjusts the Multiple Speed oscillator (MSI) calibration value.*/

          __HAL_RCC_MSI_CALIBRATIONVALUE_ADJUST(RCC_OscInitStruct->MSICalibrationValue);

          /* Decrease number of wait states update if necessary */

          if(RCC_SetFlashLatencyFromMSIRange(RCC_OscInitStruct->MSIClockRange) != HAL_OK)

          {

            return HAL_ERROR;

          }         

        }

Do you have any idea why it's crash?

thanks...

2 REPLIES 2
john doe
Lead
Posted on August 13, 2017 at 15:45

so what is HAL_RCC_OscConfig() returning?

Posted on August 13, 2017 at 17:15

I didnt get there, because its crash on the green line.