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-18 08:00 AM - edited 2024-12-18 08:06 AM
@DYann.1 wrote:my evaluation board .
What evaluation board is it?
And what STM32L5 chip, exactly?
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.
2024-12-18 10:09 AM - edited 2024-12-18 10:10 AM
Look at the values set by the code and duplicate those settings within the Clock Configuration tab in CubeMX.
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.
2024-12-19 02:32 PM - edited 2024-12-19 02:44 PM
@Andrew Neil wrote:
@DYann.1 wrote:my evaluation board .
What evaluation board is it?
And what STM32L5 chip, exactly?
Hi,
My board is STM32L552E-EV with STM32L552ZE MCU, yes in the example is the same microprocessor. I have this tab so how can I generate identical code in the example ?
How to select the HSI and configure the clock system to have the same code ?
2024-12-19 04:05 PM
@TDK wrote:Look at the values set by the code and duplicate those settings within the Clock Configuration tab in CubeMX.
If you're stuck, explain what you're stuck on along with a screenshot of your clock configuration screen.
first, I would like to have these 5 lines,
And after trying several options it seems to me that it's impossible to have LSI and LSE at the same time
Did I miss something ? Here is my configuration in this attached, can you tell me where the errors are ? Thank you
PJ : _HSI_conf.zip
2024-12-19 06:47 PM
What you have circled in the RTC clock selection. You can't have the RTC run from LSE and LSI at the same time.
If you use LSI somewhere in the system it will be automatically enabled in CubeMX.
2024-12-20 02:16 AM - edited 2024-12-20 02:16 AM
2024-12-20 03:14 AM
After making the changes
I have this code :
RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSI48|RCC_OSCILLATORTYPE_HSI
|RCC_OSCILLATORTYPE_LSE|RCC_OSCILLATORTYPE_MSI;
It's not really the same like this one :
RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSI
| RCC_OSCILLATORTYPE_HSI48 | RCC_OSCILLATORTYPE_LSE
| RCC_OSCILLATORTYPE_LSI | RCC_OSCILLATORTYPE_MSI;
RCC_OSCILLATORTYPE_LSI is missing. How to do that ? Is it really important ? After my understanding
you can have one or the other but not both at the same time, Right ? :
2024-12-20 03:18 AM
@TDK wrote:What you have circled in the RTC clock selection. You can't have the RTC run from LSE and LSI at the same time.
If you use LSI somewhere in the system it will be automatically enabled in CubeMX.
Thank you but your answer is not very precis, did you see my projet.zip ?
2024-12-20 03:50 AM - edited 2024-12-20 03:52 AM
Were you sure to save those settings, and to re-generate the code?
Please post the .ioc file.
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.