Hi, I'm new to the Embedded Development and i'm using a STM32L4R5ZI NUCLEO144 board.
Want to know that how to configure the system clock for STM32L4R5ZI to 120mHz in mcuconf.h? Is there a visualization tool to generator the configure code like STM32cubeMX for chibios?
How to configure the system clock for STM32L4R5ZI to 120mHz Topic is solved
Moderators: RoccoMarco, barthess
-
- Posts: 24
- Joined: Sun Jan 12, 2020 2:11 pm
- Has thanked: 4 times
- Giovanni
- Site Admin
- Posts: 14444
- Joined: Wed May 27, 2009 8:48 am
- Location: Salerno, Italy
- Has thanked: 1074 times
- Been thanked: 921 times
- Contact:
Re: How to configure the system clock for STM32L4R5ZI to 120mHz Topic is solved
Hi,
There is no such tool in ChibiOS, you can use CubeMX to get your configuration then you can copy the parameters into the clock section of mcuconf.h. The meaning of all settings is exactly as explained the in STM32 RM and is what CubeMX generates.
In general ChibiOS demos are already configured with optimal settings, so no need to do that at all initially.
Giovanni
There is no such tool in ChibiOS, you can use CubeMX to get your configuration then you can copy the parameters into the clock section of mcuconf.h. The meaning of all settings is exactly as explained the in STM32 RM and is what CubeMX generates.
In general ChibiOS demos are already configured with optimal settings, so no need to do that at all initially.
Giovanni
-
- Posts: 24
- Joined: Sun Jan 12, 2020 2:11 pm
- Has thanked: 4 times
Re: How to configure the system clock for STM32L4R5ZI to 120mHz
Thanks for reply.
Here is the code cubeMx generated:
And this is code in mcuconf.h which is in the demo of ChibiStudio:
Want to double check is this configuration the fastest or not? If not how to modify it to fit the code which the CubeMX generated?
Here is the code cubeMx generated:
Code: Select all
/**
* @brief System Clock Configuration
* @retval None
*/
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_SCALE1_BOOST) != HAL_OK)
{
Error_Handler();
}
/** Initializes the CPU, AHB and APB busses clocks
*/
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.PLLM = 2;
RCC_OscInitStruct.PLL.PLLN = 30;
RCC_OscInitStruct.PLL.PLLP = RCC_PLLP_DIV2;
RCC_OscInitStruct.PLL.PLLQ = RCC_PLLQ_DIV2;
RCC_OscInitStruct.PLL.PLLR = RCC_PLLR_DIV2;
if (HAL_RCC_OscConfig(&RCC_OscInitStruct) != HAL_OK)
{
Error_Handler();
}
/** Initializes the CPU, AHB and APB busses 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();
}
}
And this is code in mcuconf.h which is in the demo of ChibiStudio:
Code: Select all
/*
* HAL driver system settings.
*/
#define STM32_NO_INIT FALSE
#define STM32_VOS STM32_VOS_RANGE1
#define STM32_PVD_ENABLE FALSE
#define STM32_PLS STM32_PLS_LEV0
#define STM32_HSI16_ENABLED FALSE
#define STM32_HSI48_ENABLED FALSE
#define STM32_LSI_ENABLED TRUE
#define STM32_HSE_ENABLED FALSE
#define STM32_LSE_ENABLED FALSE
#define STM32_MSIPLL_ENABLED FALSE
#define STM32_MSIRANGE STM32_MSIRANGE_4M
#define STM32_MSISRANGE STM32_MSISRANGE_4M
#define STM32_SW STM32_SW_PLL
#define STM32_PLLSRC STM32_PLLSRC_MSI
#define STM32_PLLM_VALUE 1
#define STM32_PLLN_VALUE 60
#define STM32_PLLPDIV_VALUE 0
#define STM32_PLLP_VALUE 7
#define STM32_PLLQ_VALUE 4
#define STM32_PLLR_VALUE 2
#define STM32_HPRE STM32_HPRE_DIV1
#define STM32_PPRE1 STM32_PPRE1_DIV1
#define STM32_PPRE2 STM32_PPRE2_DIV1
#define STM32_STOPWUCK STM32_STOPWUCK_MSI
#define STM32_MCOSEL STM32_MCOSEL_NOCLOCK
#define STM32_MCOPRE STM32_MCOPRE_DIV1
#define STM32_LSCOSEL STM32_LSCOSEL_NOCLOCK
#define STM32_PLLSAI1M_VALUE 1
#define STM32_PLLSAI1N_VALUE 72
#define STM32_PLLSAI1PDIV_VALUE 6
#define STM32_PLLSAI1P_VALUE 7
#define STM32_PLLSAI1Q_VALUE 6
#define STM32_PLLSAI1R_VALUE 6
#define STM32_PLLSAI2M_VALUE 1
#define STM32_PLLSAI2N_VALUE 72
#define STM32_PLLSAI2PDIV_VALUE 6
#define STM32_PLLSAI2P_VALUE 7
#define STM32_PLLSAI2Q_VALUE 6
#define STM32_PLLSAI2R_VALUE 6
Want to double check is this configuration the fastest or not? If not how to modify it to fit the code which the CubeMX generated?
-
- Posts: 24
- Joined: Sun Jan 12, 2020 2:11 pm
- Has thanked: 4 times
Re: How to configure the system clock for STM32L4R5ZI to 120mHz
After a few debuging I'm confirmed that the clock is 120mHz by default as well, thanks a lot.
Who is online
Users browsing this forum: No registered users and 11 guests