[Solved][Doubt] HAL Clock Config
Hi everyone. It's my first time posting here. I'm learning how to program STM32, especifically an STM32F303RE Nucleo Board using HAL libraries.
These are my resources to learn:
- Mastering STM32 from Carmine Noviello
- STM32F303RE User Manual and Datasheet
- UM1786 Description of STM32F3 HAL and low-layer drivers.
I'm trying to configure HSI oscilator using HAL drivers this is a part of my code (still incomplete):
void SystemClock_Config(){
RCC_OscInitTypeDef RCC_OscInitStruct = {0};
RCC_ClkInitTypeDef RCC_ClkInitStruct = {0};
RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSI;
RCC_OscInitStruct.HSEState = RCC_HSE_OFF;
RCC_OscInitStruct.HSEPrediValue = RCC_HSE_PREDIV_DIV1;
RCC_OscInitStruct.LSEState = RCC_LSE_OFF;
RCC_OscInitStruct.LSIState = RCC_HSI_OFF;
RCC_OscInitStruct.HSICalibrationValue = RCC_HSICALIBRATION_DEFAULT;
RCC_OscInitStruct.LSIStae = RCC_LSI_OFF;
RCC_PLLInitTypeDef.RCC_OscInitTypeDef = ???
}As you can see, I pretend use HSI (its on), so, HSEState are OFF also LSE = OFF and so one. I compared my code with the generated with CubeMX:
void SystemClock_Config(void)
{
RCC_OscInitTypeDef RCC_OscInitStruct = {0};
RCC_ClkInitTypeDef RCC_ClkInitStruct = {0};
RCC_PeriphCLKInitTypeDef PeriphClkInit = {0};
/** Initializes the RCC Oscillators according to the specified parameters
* in the RCC_OscInitTypeDef structure.
*/
RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSI;
RCC_OscInitStruct.HSIState = RCC_HSI_ON;
RCC_OscInitStruct.HSICalibrationValue = RCC_HSICALIBRATION_DEFAULT;
RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON;
RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_HSI;
RCC_OscInitStruct.PLL.PLLMUL = RCC_PLL_MUL9;
RCC_OscInitStruct.PLL.PREDIV = RCC_PREDIV_DIV1;As you can see, in this code CubeMX doesn't specify that HSE, LSI, are off. Only apears HSI = ON.
So my doubt is:
Can I skip to initialize these structure members for configure the osc?
Do they have a predefined value?
I hope you can help me. Ty
