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.

22 REPLIES 22

@Andrew Neil wrote:

Were you sure to save those settings, and to re-generate the code?

Please post the .ioc file.

Really ? You don't have the .ioc file in my _HSI_conf.zip ? When I unzip my file

DYann1_0-1734695945719.png

I can see the .ioc file

DYann1_2-1734695988859.png

When I open the projet I can see the Clock configuration under STM32CubeIDE

DYann1_3-1734696050511.png

 


@Andrew Neil wrote:

PS:

As @TDK noted earlier, are you sure the code that you showed relates to the System clock - not the RTC ?

Show the full code.


What the full code ? I have the code at the beginning of my message but no .ioc file and I would like to create an .ioc file with the same code, just for void SystemClock_Config(void) for this moment and nothing else 

 


@DYann.1 wrote:

You don't have the .ioc file in my _HSI_conf.zip ? 

That was attached several posts earlier - has it not changed?

No,

RCC_OSCILLATORTYPE_LSI is missing.

The original code is

DYann1_0-1734698222858.png

And I have this code with my .ioc file :

DYann1_1-1734698272486.png

(never mind)


I'm confused.

You attached your zip file to this post:

https://community.st.com/t5/stm32-mcus-products/how-to-configure-hsi-in-stm32l5/m-p/755458/highlight/true#M269041

 

In your next post, you said:


@DYann.1 wrote:

After making the changes ...


Here: https://community.st.com/t5/stm32-mcus-products/how-to-configure-hsi-in-stm32l5/m-p/755630/highlight/true#M269063

That's the post I was replying to when I asked for .ioc file & full code - ie, the stuff after you made those changes.


@Andrew Neil wrote:

The .ioc file just saves the CubeMX configuration - the C source code has to be generated from that configuration data.


So how to configure CubeMX to have this code ?

DYann1_0-1734699172043.png

It's the same question but asked in reverse.


@Andrew Neil wrote:

I'm confused.

You attached your zip file to this post:

https://community.st.com/t5/stm32-mcus-products/how-to-configure-hsi-in-stm32l5/m-p/755458/highlight/true#M269041

I have only this code without '.ioc' 

// 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();
    }

And I would like to have the .ioc file to look at the configuration and adapt to my code, thus I created a _HSI_conf project to have the .ioc file in order to generate the code that I found. Now do you understand what I'm looking for ?


@DYann.1 wrote:
 I created a _HSI_conf project to have the .ioc file in order to generate the code that I found. 

So post that .ioc file, and the code that was generated from it - the most recent version, after all the changes that have been discussed.


@Andrew Neil wrote:

@DYann.1 wrote:
 I created a _HSI_conf project to have the .ioc file in order to generate the code that I found. 

So post that .ioc file, and the code that was generated from it.


???? Is this a joke ?  With all these explanations and you going around in circles ?

You said you'd made changes since the zip file you posted.

Anyhow, I'm out.