Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PLL clock configuration

I'm using STM32L152RB board and I'm trying to configure system clock to use PLL clock but the RCC_FLAG_PLLRDY flag is getting set so the program is stuck in while loop. please let what I'm doing wrong

EnableHSI();
RCC_PLLConfig(RCC_PLLSource_HSI,RCC_PLLMul_3,RCC_PLLDiv_2);
RCC_PLLCmd(ENABLE);
while(RCC_GetFlagStatus(RCC_FLAG_PLLRDY) == RESET);
RCC_SYSCLKConfig( RCC_SYSCLKSource_PLLCLK);
t=GetSystemClockSource();
like image 669
Mustak U Avatar asked Mar 06 '26 17:03

Mustak U


1 Answers

Take a look in the reference manual for "Relation between CPU clock frequency and Flash memory read time". It says what for the CPU speed higher than 16MHz you should set flash latency for 1WS (wait state). Something like this before setting PLL as clock source:

FLASH->ACR  = FLASH_ACR_ACC64;   // 64-bit access
FLASH->ACR |= FLASH_ACR_LATENCY; // one wait state
FLASH->ACR |= FLASH_ACR_PRFTEN;  // prefetch enable
like image 98
LonelyWolf Avatar answered Mar 08 '26 20:03

LonelyWolf



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!