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 05:29 AM
> Thank you but your answer is not very precis, did you see my projet.zip ?
I saw your zip file. Did you see my answer?
As I said, you will have to use LSI as a clock source to something if you want CubeMX to enable it. Otherwise it is not needed and will not be enabled.
2024-12-20 05:33 AM - edited 2024-12-20 05:49 AM
@Andrew Neil wrote:You said you'd made changes since the zip file you posted.
Yes it's the case with my _HSI_conf project (in projet I have the .ioc file) but I don't have the same code. What I would like to obtain
RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSI
| RCC_OSCILLATORTYPE_HSI48 | RCC_OSCILLATORTYPE_LSE
| RCC_OSCILLATORTYPE_LSI | RCC_OSCILLATORTYPE_MSI;
And with _HSI_conf project I have this code :
RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSI48|RCC_OSCILLATORTYPE_HSI
|RCC_OSCILLATORTYPE_LSE|RCC_OSCILLATORTYPE_MSI;
I'm missing the RCC OSCILLATOR TYPE LSI line
2024-12-20 05:48 AM
@TDK wrote:As I said, you will have to use LSI as a clock source to something if you want CubeMX to enable it. Otherwise it is not needed and will not be enabled.
Always very vague and evasive, nothing concrete. Can you modify my .ioc file in my _HSI_conf projet and show me the generated code ?
And I have this code
RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSI48|RCC_OSCILLATORTYPE_HSI
|RCC_OSCILLATORTYPE_LSI|RCC_OSCILLATORTYPE_MSI;
And this is the code I am waiting for :
/** 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;
I'm missing the RCC_OSCILLATORTYPE_LSE line