2014-09-12 04:12 PM
Hi,
I am trying to create a 64MHz system clock by using the 8MHz HSI clock and the PLL (PLLMUL = 16). But the firmware stops working after this line:RCC_SYSCLKConfig(RCC_SYSCLKSource_PLLCLK);
But it will work if I change the PLLMUL to 13 or less. The user manual says the STM32F103 system clock max frequency is 72MHz, so I don't know why the firmware fails.
Below is a simple example main.c file, the project was created by Keil uVision 5.1. Project file attached.
/* Includes ------------------------------------------------------------------*/
#include ''stm32f10x.h''
#include ''stm32f10x_gpio.h''
#include ''stm32f10x_rcc.h''
#include <
stdio.h
>
int main(void)
{
GPIO_InitTypeDef gpio_init_structure; //GPIO structure
RCC_HSICmd(ENABLE);
RCC_PLLConfig(RCC_PLLSource_HSI_Div2, RCC_PLLMul_16);
// Enable PLL
RCC_PLLCmd(ENABLE);
// Checks whether the specified RCC flag is set or not
// Wait till PLL is ready
while(RCC_GetFlagStatus(RCC_FLAG_PLLRDY) == RESET);
// Select PLL as system clock source
RCC_SYSCLKConfig(RCC_SYSCLKSource_PLLCLK);
RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA, ENABLE);
/* Output clock on MCO pin ---------------------------------------------*/
gpio_init_structure.GPIO_Pin = GPIO_Pin_8;
gpio_init_structure.GPIO_Mode = GPIO_Mode_AF_PP;
gpio_init_structure.GPIO_Speed = GPIO_Speed_50MHz;
GPIO_Init(GPIOA, &gpio_init_structure);
// RCC_MCOConfig(RCC_MCO_HSE); // Put on MCO pin the: freq. of external crystal
RCC_MCOConfig(RCC_MCO_SYSCLK); // Put on MCO pin the: System clock selected
while(1);
}
#ifdef USE_FULL_ASSERT
/**
* @brief Reports the name of the source file and the source line number
* where the assert_param error has occurred.
* @param file: pointer to the source file name
* @param line: assert_param error line source number
* @retval None
*/
void assert_failed(uint8_t* file, uint32_t line)
{
/* User can add his own implementation to report the file name and line number,
ex: printf(''Wrong parameters value: file %s on line %d\r\n'', file, line) */
/* Infinite loop */
while (1)
{
}
}
#endif
/**
* @}
*/
/**
* @}
*/
/******************* (C) COPYRIGHT 2011 STMicroelectronics *****END OF FILE****/
2014-09-12 04:40 PM
Normally with the CMSIS model this is done in SystemInit()
Watch that you have sufficient Flash Wait States selected for the speed you plan on switching too. At 64 MHz you'll need at least 2.