we working on stm32f103ret ic and using CMSIS library for setting GPIO Ports, so i have debuged program in keil v5.14 so in debugign mode it's stuck in line 1043 of systme_stm32f10x.c file which is this code :

/* Wait till PLL2 is ready */
while((RCC->CR & RCC_CR_PLL2RDY) == 1)//0

as you see in this picture:

 /* Wait till PLL2 is ready */

and it's clock setting here:

the clock

So all of main.c code is here:

#include "stm32f10x.h"

void delay(void);

int main(){
    GPIO_InitTypeDef GPIO_Struct;
    uint16_t N;
    int i;


    GPIO_Struct.GPIO_Pin=0xFFFF; // Selects All Pins



void delay(void){
    int i,j;

and the whole project is here:

keil files

thanks a lot.


closed as unclear what you're asking by Chris Stratton, Elliot Alderson, Edgar Brown, smashtastic, Finbarr Feb 4 at 10:23

Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.

  • \$\begingroup\$ Did you configure appropriately for an internal clock or an external crystal actually present and verified oscillating ? Questions here are required to include the critical information in the body of the question posting itself, and your question excludes the very line you claim is hanging! \$\endgroup\$ – Chris Stratton Jan 29 at 6:41
  • \$\begingroup\$ this is not so big project, as you can see I paste the main.c file I the question and my board have had one external 8 M.Hz oscillators but in main.c file it is not setting the clock for MCU but in options file I have added 8 M.Hz for the clock of the project, and I added a photo of clock setting in the question, so i think there is no need anything for setting the clock. \$\endgroup\$ – ss3 Jan 29 at 7:24
  • \$\begingroup\$ It's not the main that should be in your question, it is all the code that accomplishes clock setup. And if you are trying to use the HSE, the details of the crystal and what you found when you looked at it with a 10x probe. \$\endgroup\$ – Chris Stratton Jan 29 at 15:02

The reference manual for that part from here says

For the register RCC->CR

Bit 25 PLLRDY: PLL clock ready flag

Set by hardware to indicate that the PLL is locked.

0: PLL unlocked

1: PLL locked

If you're waiting for the PLL to lock your loop condition should be while((RCC->CR & RCC_CR_PLL2RDY) == 0) Check the definition of RCC_CR_PLL2RDY, it should be 1 << 25, but the reference manual for the part you mention doesn't mention a PLL2, so it could just be a naming issue.

At the moment I suspect your PLL is managing to lock before you enter your loop, and then you never leave it.


I found the reason, it was because of changing MCU series in Keil target option (Default MCU was STM32F107VC AND MCU was STM32F103RE ), so I must remove "startup_stm32f10x_lc.s" which belong to default MCU from project and inserted "startup_stm32f10x_hd.s" belong to New MCU.

as you can see in below pic it's built without any Error:



Not the answer you're looking for? Browse other questions tagged or ask your own question.