Hola,
Estoy intentando configurar el reloj de un STM32F100RB y no consigo hacerlo. El programa funciona bien si no configuro el PLL, pero cuando intento configurarlo no hay manera.
El trozo de código que configura el reloj es el siguiente:
void SetupClock()
{
RCC_DeInit (); /* RCC system reset(for debug purpose)*/
RCC_HSEConfig (RCC_HSE_ON); /* Enable HSE */
/* Wait till HSE is ready */
while (RCC_GetFlagStatus(RCC_FLAG_HSERDY) == RESET);
RCC_HCLKConfig (RCC_SYSCLK_Div1); /* HCLK = SYSCLK */
RCC_PCLK2Config (RCC_HCLK_Div1); /* PCLK2 = HCLK */
RCC_PCLK1Config (RCC_HCLK_Div2); /* PCLK1 = HCLK/2 */
RCC_ADCCLKConfig (RCC_PCLK2_Div4); /* ADCCLK = PCLK2/4 */
/* PLLCLK = 8MHz * 9 = 72 MHz */
RCC_PLLConfig (0x00010000, RCC_PLLMul_9);
RCC_PLLCmd (ENABLE); /* Enable PLL */
/* 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 */
while (RCC_GetSYSCLKSource() != 0x08);
}
Si deshabilito las lineas:
RCC_SYSCLKConfig (RCC_SYSCLKSource_PLLCLK);
while (RCC_GetSYSCLKSource() != 0x08);
vuelve a funcionar pero a una frecuencia más baja, supongo que es normal porque estas lineas son las que configuran el reloj del sistema con el PLL.
¿Alguien me puede ayudar a saber que es lo que configuro mal?
Estoy usando Coocox por si sirve de ayuda.