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

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

RCC_PLLCmd(ENABLE);

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

RCC_HSI14Cmd(ENABLE);

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

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

RCC_ADCCLKConfig(RCC_ADCCLK_PCLK_Div2);

RCC_USARTCLKConfig(RCC_USART1CLK_SYSCLK);

RCC_APB2PeriphClockCmd(RCC_APB2Periph_USART1, ENABLE);

RCC_LSICmd(ENABLE);

 

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

Outcomes