cancel
Showing results for 
Search instead for 
Did you mean: 

why led blink when any clock source not selected?

hossein hosseini
Associate II
Posted on October 19, 2017 at 10:42

hi,

on this code:

&sharpinclude 'stm32f10x.h'

&sharpinclude 'delay.h'

int main()

{   

 

  SystemInit ();

  RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA , ENABLE);  

    

  GPIO_InitTypeDef gpio;

  gpio.GPIO_Pin = GPIO_Pin_0;

  gpio.GPIO_Speed = GPIO_Speed_2MHz;

  gpio.GPIO_Mode = GPIO_Mode_Out_PP;

  GPIO_Init(GPIOA , &gpio);  

 

  while(1)

    

  {

    GPIOA->BSRR = GPIO_Pin_0;

    delay_ms(300);

    

    GPIOA->BSRR = (GPIO_Pin_0<<16);

    delay_ms(300);

  }

}

when there is SystemInit ();   , it work corrctly. 

and when  i delete the SystemInit ();  when the system clock not set , but the led blink and time is more then 300 ms , i dont know why the clock isnt set , but the led blink ??

i write RCC_LSICmd  ( DISABLE) ; to disable internal clock , but this CMD doesnt work , and the led still blink.

NOTE:

i want to understand how does the clock or RCC work in stm32 , for this , i try to test these ways.And i want to set the RCC myself.

so thanks.

#blink #clock
1 REPLY 1
bbee
Associate III
Posted on October 19, 2017 at 12:20

I assume that when you don't initialize the clocks it will run using the internal high speed clock (HSI) with 8MHz by default as system clock (SYSCLK). (Have a look on the figure 'Clock tree' in the reference manual)

LSI is the low speed internal clock which can only be used to trigger the real time clock (RTC) or the internal watchdog (IWDG). Disabling LSI will have no effect on the execution speed of your programme.