2018-06-02 04:41 PM
Hello, I just want to make sure what I'm doing is right. I'm using MBED and stm32L4. I want to change clock speed to 26 Mhz, I plan to use MSI as input. In order to do so, I will change the parameter PLL_M and leave the rest of the parameters as they are in the method
uint8_t
SetSysClock_PLL_MSI
(
void
)
defined in []. To calculate PLL_m , I solve for it in the equation: SystemClock = ((MSI / PLL_M) * PLL_N) / PLL_R and set the SystemClock to 26 Mhz. Then I will call the method from my main program to change the clock speed. Can someone please correct me if I'm doing anything wrong?2018-06-02 05:11 PM
You can run the Cube and visualise the clock settings there.
it is very easy to do.
I checked it for you,
MSI input
PLLM /1
N = x12
R = /2
ABH prescaler /2
= 26MHz
Why so low ?
MSI input
PLLM /1
N = x40
R = /2
ABH prescaler /1
= 80MHz
2018-06-02 05:40 PM
((4 / 1) * 13) / 2 = 26
/* MSI is enabled after System reset, activate PLL with MSI as source */
RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_MSI; RCC_OscInitStruct.MSIState = RCC_MSI_ON; RCC_OscInitStruct.MSIClockRange = RCC_MSIRANGE_6; // 4 MHz RCC_OscInitStruct.MSICalibrationValue = RCC_MSICALIBRATION_DEFAULT; RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON; RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_MSI; RCC_OscInitStruct.PLL.PLLM = 1; RCC_OscInitStruct.PLL.PLLN = 13; RCC_OscInitStruct.PLL.PLLR = 2; RCC_OscInitStruct.PLL.PLLP = 7; RCC_OscInitStruct.PLL.PLLQ = 4; if(HAL_RCC_OscConfig(&RCC_OscInitStruct) != HAL_OK) { /* Initialization Error */ while(1); }2018-06-02 07:49 PM
((4 / 1) * 13) / 2 = 26
MSI Range 6 for 4 MHz
M=1, N=13, R=2
Posted code, but stuck in moderation
2018-06-02 09:15 PM
I use the Quotes now, no moderation delay
2018-06-04 06:21 PM
Thank you so much. Can I use this code on mbed?
2018-06-04 06:21 PM
Thank you so much. Can I use this code on mbed to change the clock?
2018-06-04 06:41 PM
I'm not using mbed, you would need to seek specific support in the mbed forums if the build you are making isn't using the code you cited earlier.
Or consider if you can export the project to Keil, and then build/modify that to suit your requirements.