2024-12-18 07:39 AM - last edited on 2024-12-18 08:05 AM by Andrew Neil
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.
2024-12-20 03:55 AM - edited 2024-12-20 04:06 AM
@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
I can see the .ioc file
When I open the projet I can see the Clock configuration under STM32CubeIDE
@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
2024-12-20 04:17 AM - edited 2024-12-20 04:19 AM
@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?
2024-12-20 04:38 AM
No,
RCC_OSCILLATORTYPE_LSI is missing.
The original code is
And I have this code with my .ioc file :
2024-12-20 04:46 AM - edited 2024-12-20 04:53 AM
(never mind)
2024-12-20 04:53 AM
I'm confused.
You attached your zip file to this post:
In your next post, you said:
@DYann.1 wrote:After making the changes ...
That's the post I was replying to when I asked for .ioc file & full code - ie, the stuff after you made those changes.
2024-12-20 04:54 AM
@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 ?
It's the same question but asked in reverse.
2024-12-20 05:08 AM
@Andrew Neil wrote:I'm confused.
You attached your zip file to this post:
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 ?
2024-12-20 05:14 AM - edited 2024-12-20 05:16 AM
@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.
2024-12-20 05:17 AM
@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 ?
2024-12-20 05:24 AM
You said you'd made changes since the zip file you posted.
Anyhow, I'm out.