AnsweredAssumed Answered

how can i earn Real 1 second delay?!!

Question asked by hossein hosseini on Oct 20, 2017
Latest reply on Oct 20, 2017 by Clive One

hi,

i wrote Led blink with stm32f103re , and i did write this code :

 

 

#include "stm32f10x.h"
#include "delay.h"

int main()
{   
 
   RCC_DeInit  ( )  ;
   RCC_HSEConfig  ( RCC_HSE_ON) ;
   RCC_WaitForHSEStartUp  ( );  
   RCC_PLLConfig  ( RCC_PLLSource_HSE_Div1, 9) ;
   RCC_PLLCmd  ( ENABLE );  
   delay_ms(1);
   RCC_SYSCLKConfig  ( RCC_SYSCLKSource_PLLCLK );  
   RCC_HCLKConfig  ( RCC_SYSCLK_Div1 );
   RCC_PCLK2Config  ( RCC_HCLK_Div1 ); 
  RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA , ENABLE);  

 
  GPIO_InitTypeDef gpio;
  gpio.GPIO_Pin = GPIO_Pin_0;
  gpio.GPIO_Speed = GPIO_Speed_50MHz;
  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);
  }
}

But when cpu do delay _ms(300) , the delay is not real , it wait for 3 seconds,

and i modify RCC_ ... register to earn 1 second  , but i cant earn that !!
what shall i do to earn real 1 second?

I test some ways , but i cant do that yet.

I know that i have problem in RCC setting , but i dont know where!!!


so thanks.

Outcomes