cancel
Showing results for 
Search instead for 
Did you mean: 

how to configure HSI in STM32L5...

DYann.1
Senior II

Hello,

I would like to know if it's possible to configure my evaluation board HSI, I have this code and I would like to adapt it on my evaluation card and see if it is compatible with the rest :

 

 

// HSI
//
void SystemClock_Config(void)
    {

    RCC_OscInitTypeDef RCC_OscInitStruct =
	{ 
	0
	};
    RCC_ClkInitTypeDef RCC_ClkInitStruct =
	{
	0
	};

    /** Configure the main internal regulator output voltage
     */
    if (HAL_PWREx_ControlVoltageScaling(PWR_REGULATOR_VOLTAGE_SCALE0) != HAL_OK)
	{
	Error_Handler();
	}

    /** Initializes the RCC Oscillators according to the specified parameters
     * in the RCC_OscInitTypeDef structure.
     */
    RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSI
	    | RCC_OSCILLATORTYPE_HSI48 | RCC_OSCILLATORTYPE_LSE
	    | RCC_OSCILLATORTYPE_LSI | RCC_OSCILLATORTYPE_MSI;
    RCC_OscInitStruct.LSEState =  RCC_LSE_BYPASS;
    RCC_OscInitStruct.HSIState = RCC_HSI_ON;
    RCC_OscInitStruct.HSI48State = RCC_HSI48_ON;
    RCC_OscInitStruct.LSIDiv = RCC_LSI_DIV1;
    RCC_OscInitStruct.LSIState = RCC_LSI_ON;
    RCC_OscInitStruct.HSICalibrationValue = RCC_HSICALIBRATION_DEFAULT;
    RCC_OscInitStruct.MSIState = RCC_MSI_ON;
    RCC_OscInitStruct.MSICalibrationValue = RCC_MSICALIBRATION_DEFAULT;
    RCC_OscInitStruct.MSIClockRange = RCC_MSIRANGE_6;
    RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON;
    RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_HSI;
    RCC_OscInitStruct.PLL.PLLM = 2;
    RCC_OscInitStruct.PLL.PLLN = 23;
    RCC_OscInitStruct.PLL.PLLR = RCC_PLLR_DIV8;
    RCC_OscInitStruct.PLL.PLLQ = RCC_PLLQ_DIV2;
    RCC_OscInitStruct.PLL.PLLP = RCC_PLLP_DIV7;
    if (HAL_RCC_OscConfig(&RCC_OscInitStruct) != HAL_OK)
	{
	Error_Handler();
	}

    /** Initializes the CPU, AHB and APB buses clocks
     */
    RCC_ClkInitStruct.ClockType = RCC_CLOCKTYPE_HCLK | RCC_CLOCKTYPE_SYSCLK
	    | RCC_CLOCKTYPE_PCLK1 | RCC_CLOCKTYPE_PCLK2;
    RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_PLLCLK;
    RCC_ClkInitStruct.AHBCLKDivider = RCC_SYSCLK_DIV1;
    RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV1;
    RCC_ClkInitStruct.APB2CLKDivider = RCC_HCLK_DIV1;

    if (HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_5) != HAL_OK)
	{
	Error_Handler();
	}

    /** Enable MSI Auto calibration
     */
    HAL_RCCEx_EnableMSIPLLMode();

    /** MCO configuration
     */
    HAL_RCC_MCOConfig(RCC_MCO1, RCC_MCO1SOURCE_SYSCLK, RCC_MCODIV_1);

    //__HAL_RCC_PWR_CLK_ENABLE();
    }

 

 

With the .ioc file, it's better for understanding.

Thank you for your helps.

2 REPLIES 2

@DYann.1 wrote:

my evaluation board .


What evaluation board is it?

And what STM32L5 chip, exactly?

See: https://community.st.com/t5/community-guidelines/how-to-write-your-question-to-maximize-your-chances-to-find-a/ta-p/575228

 

But HSI = the High-Speed Internal oscillator of the STM32L5 chip itself.

Because it's internal to the chip, configuring it is entirely independent of what board it's mounted on.

 

You can use CubeMX (either standalone, or within CubeIDE) to configure the clock system - including the internal oscillators.

TDK
Guru

Look at the values set by the code and duplicate those settings within the Clock Configuration tab in CubeMX.

TDK_0-1734545335826.png

If you're stuck, explain what you're stuck on along with a screenshot of your clock configuration screen.

 

HSI is configured on by default, but it seems like you want to configure the PLL as well based on your post.

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