AnsweredAssumed Answered

GPIO Toggling issue

Question asked by Carter Lee on Sep 8, 2017
Latest reply on Sep 8, 2017 by Clive One

Hi,

 

Now I'm currently working with GPIO control.

And I have an issue to control GPIO,

I came across there's not toggling when I use delay()

 

 

 

 

 

For example,

# GPIO toggling not working case


void delay(void)
{
volatile int i;
for(i=0; i<10000000; i++);
}


while (1)
{
GPIOG->BSRRL = GPIO_Pin_14;
delay();
GPIOG->BSRRH = GPIO_Pin_14;
delay();

 

GPIOG->BSRRL = GPIO_Pin_15;
GPIOG->BSRRH = GPIO_Pin_15;

 

GPIO_SetBits(GPIOG, GPIO_Pin_15);
GPIO_ResetBits(GPIOG, GPIO_Pin_15);

}

 

 

 

# GPIO  toggling working good case


void delay(void)
{
volatile int i;
for(i=0; i<10000000; i++);
}


while (1) 
{ 
GPIOG->BSRRL = GPIO_Pin_14; 
GPIOG->BSRRH = GPIO_Pin_14; 

 

 

GPIOG->BSRRL = GPIO_Pin_15; 
GPIOG->BSRRH = GPIO_Pin_15; 

 

GPIO_SetBits(GPIOG, GPIO_Pin_15);
GPIO_ResetBits(GPIOG, GPIO_Pin_15);

}

 

Could you please let me know what does difference between them?

Why doesn't it toggling whithin delay() ?

Outcomes