AnsweredAssumed Answered

why does Led blink modify in this code?

Question asked by hossein hosseini on Jan 6, 2018
Latest reply on Jan 8, 2018 by Bogdan Golab

hi.

i wrote a code in IAR for stm32f103ret, the code is for blink led and  problem is the time is different when the led is on and the led is off .

But the wait is same both of set led and reset led.

19 seconds led is on but 22 seconds led is off. and it repeat again and again.
who know why?what do we do?

so thanks.

#include "stm32f10x.h"
#include "stm32f10x_gpio.h"  // for Enable LCD
#include "stm32f10x_rcc.h"   //for Enable LCD
#include "LCDLib.h"
#include "delay.h"

void GPIOC_init(void);

int main()
{
  int32_t dly=0;
  GPIOC_init();
 
  while(1)
  {
    GPIO_WriteBit(GPIOB,GPIO_Pin_0, Bit_SET);
    while(dly<100000000)dly+=1;
    dly=0;
    GPIO_WriteBit(GPIOB,GPIO_Pin_0, Bit_RESET);
    while(dly<100000000)dly+=1;
    dly=0;
  }
 
}


void GPIOC_init(void)
{
    RCC_APB2PeriphClockCmd  ( RCC_APB2Periph_GPIOB, ENABLE );
    
    GPIO_InitTypeDef gpioC;
    gpioC.GPIO_Mode = GPIO_Mode_Out_PP ;
    gpioC.GPIO_Pin = GPIO_Pin_All;
    gpioC.GPIO_Speed = GPIO_Speed_10MHz;  
    GPIO_Init  (  GPIOB,  &gpioC );
 
}

Outcomes