Topic : PLL clock twice what it should be!

Forum : ARM

Original Post
Post Information Post
July 13, 2009 - 4:40am
Guest

My STM32F103C8T6 board has a 4 MHz external oscillator. When I run the following RCC configuration code the second call to the RCC_GetClocksFreq() routine reports a SYSCLK, HCLK and PCLK2 clock speed of 112 MHz and a PCLK1 speed of 56 MHz. If I change the PLLSource to RCC_PLLSource_HSE_Div2, then the clock frequencies are halved, as you would expect. The device specifications say the maximum clock speed is 72 HMz, but I'm sure it could go a little further; whether it can go all the way to 112 MHz, I don't know. Is the clock actually being set to 112 MHz or is the reported value being multiplied by 2? Either way, something is wrong. Any suggestions? Could it be something in the compiler?

void RCC_Configuration(void)
{
RCC_ClocksTypeDef RCC_Clocks;
ErrorStatus HSEStartUpStatus;

/* Get the frequencies of different on-chip clocks */
/* At this point all clocks 8 MHz except ADC clock = 4 MHz *? */
RCC_GetClocksFreq(&RCC_Clocks);

/* RCC system reset(for debug purpose) -------------------------------------*/
RCC_DeInit();

/* Enable HSE --------------------------------------------------------------*/
RCC_HSEConfig(RCC_HSE_ON);

/* Wait till HSE is ready --------------------------------------------------*/
HSEStartUpStatus = RCC_WaitForHSEStartUp();

if(HSEStartUpStatus == SUCCESS)
{
/* Enable Prefetch Buffer */
FLASH_PrefetchBufferCmd(FLASH_PrefetchBuffer_Enable);

/* Flash 2 wait state */
FLASH_SetLatency(FLASH_Latency_2);

/* HCLK = SYSCLK */
RCC_HCLKConfig(RCC_SYSCLK_Div1);

/* PCLK2 = HCLK */
RCC_PCLK2Config(RCC_HCLK_Div1);

/* PCLK1 = HCLK/2 */
RCC_PCLK1Config(RCC_HCLK_Div2);

/* PLLCLK = 4MHz * 14 = 56 MHz */
RCC_PLLConfig(RCC_PLLSource_HSE_Div1, RCC_PLLMul_14);

/* Enable PLL */
RCC_PLLCmd(ENABLE);

/* Wait till PLL is ready */
while(RCC_GetFlagStatus(RCC_FLAG_PLLRDY) == RESET)
{
}

/* Select PLL as system clock source */
RCC_SYSCLKConfig(RCC_SYSCLKSource_PLLCLK);

/* Wait till PLL is used as system clock source, SWS_PLL = 0x80 */
while(RCC_GetSYSCLKSource() != SWS_PLL)
{
RCC_GetClocksFreq(&RCC_Clocks);
}
}
else
{
// Alternative source
}

/* Get the frequencies of different on-chip clocks */
RCC_GetClocksFreq(&RCC_Clocks);

}

Replies
Post Information Post
+1
0
-1
July 15, 2009 - 11:29am
Raisonance Support Team

Hi,

You have a complex issue here. Definitely trying to walk off-ways of the specifications to overclock your STM32 does not look like a good idea.

This issue does not look like it is related to the tools (the compiler should get it right), so you should contact the ST support people for help.

Regards,
Bruno

+1
0
-1
July 22, 2009 - 12:18am
Guest

Hello Bruno. Thank you for your reply. The code says it all. I am not trying to overclock the device, that's just what the debugger is reporting.
Since I can't get the 4 MHz external oscillator to oscillate at the frequency I want (56 MHz via the PLL), could you supply some code that would show me how to get the internal 8 Mhz oscillator to oscillate at 56 MHz (via the PLL of course).
Regards,
Harry.

+1
0
-1
July 23, 2009 - 12:19pm
Guest

Hi

We do not see a solution to te problems you have.
I think the best solution is to start from latest STmicroelectronics library files.
http://www.st.com/mcu/modules.php?name=mcu&file=devicedocs&DEV=STM32F103C8&FAM=110
If this does not work it wil be easier to get support from ST Microelectronics teams.

Regards,
Matloub

+1
0
-1
July 24, 2009 - 1:32pm
Guest

@Oudenhoven

Can you also check that you have changed the define of the frequency in the library.
In stm32f10x_conf.h file the frequency is by default defined at 800000 it has to be changed to 400000.
This might be the reason why.

Regards,
Matloub