Mustak U
Mustak U

Reputation: 113

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();

Upvotes: 3

Views: 7015

Answers (1)

LonelyWolf
LonelyWolf

Reputation: 61

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

Upvotes: 5

Related Questions