AnsweredAssumed Answered

STM32F051 - Flash not working with an external clock

Question asked by Abi Nair on Mar 26, 2018
Latest reply on Mar 28, 2018 by Clive One

I have been trying to erase and store data in the flash without any success. As long as I am using the HSI clock to drive the SYSCLK, the flash works just fine. However, if I start using the external oscillator to drive the SYSCLK, any flash operation would freeze the MCU.

I am using an 8 MHz external oscillator. Initialization code that I use is provided below:


RCC_PLLConfig(RCC_PLLSource_PREDIV1, RCC_PLLMul_6); // set the PLL Clock to 48 Mhz


RCC_SYSCLKConfig(RCC_SYSCLKSource_PLLCLK); // PLL selected as system clock source


RCC_HCLKConfig(RCC_SYSCLK_Div2); // HCLK selected as 24 MHz

RCC_PCLKConfig(RCC_HCLK_Div1); // PCLK selected as 24 MHz



RCC_APB2PeriphClockCmd(RCC_APB2Periph_USART1, ENABLE);



EDIT: Sorry. I am using an external 8 MHz oscillator (crystal), not an external clock.