Solved
LED Blink - STM32F429I-DISCOVERY TIM1
could somebody please help me with this: i am a beginner ,i have done the clock configuration and Timer configuration for delay and also the GPIO configuration: the LED does blink but instead of 1s it takes like 4s , i have done a lot of research to find out where the problem might be, but found nothing i use STM32F429i discovery by the way . thank you and here is my code :
void Clock_Config(void)
{
RCC->CR |=(RCC_CR_HSEON);
while(!((RCC->CR) & (RCC_CR_HSERDY)));
RCC->APB1ENR |= (1<<28);
PWR->CR |= 1<<14;
FLASH->ACR |= (1<<8)|(1<<9)|(1<<10)|(2<<0);
RCC->CFGR|=RCC_CFGR_HPRE_DIV1;
RCC->CFGR |= RCC_CFGR_PPRE1_DIV4;
RCC->CFGR |= RCC_CFGR_PPRE2_DIV2;
RCC->PLLCFGR |= (0<<16)|(4<<0)|(180<<6)|(RCC_PLLCFGR_PLLSRC_HSE);
RCC->CR |=(RCC_CR_PLLON);
while(!((RCC->CR) & (RCC_CR_PLLRDY)));
RCC->CFGR |=(RCC_CFGR_SW_PLL);
while ((RCC->CFGR & RCC_CFGR_SWS) != RCC_CFGR_SWS_PLL);
}
void Timer_Config(void)
{
RCC->APB2ENR|=(1<<0);
TIM1->PSC=180-1;
TIM1->ARR=0xffff;
TIM1->CR1|=1<<0;
while (!((TIM1->SR)& (1<<0)));
}
void Delay_µs(int µs)
{
TIM1->CNT=0;
while (TIM1->CNT<µs);
}
void Delay_ms (int ms)
{
for (uint16_t counter=0;counter<ms;counter++)
{
Delay_µs(1000);
}
}
void GPIOxConfig(void)
{
RCC->AHB1ENR |=(1<<6);
GPIOG->MODER|=(1<<26)|(1<<28);
GPIOG->OTYPER&=~(0<<13)|~(1<<14);
GPIOG->OSPEEDR |=(2<<26) | (2<<28) ;
GPIOG->PUPDR&=~((1<<26) | (1<<28));
}
