title: STM32F4-Disc1: user defined software delay in keil MDK version 5 not working
body: <p>I am getting into learning embedded systems and I tried to implement blinky but the software delay gets skipped for some reason. I was expecting it to blink when I am pushing the button but instead the LEDs kept on.</p>
  <p>Code I have used is shown below,</p>
  <pre><code>#include Board_LED.h
  #include Board_Buttons.h
  #include &lt;stdint.h&gt;
  
  void delay(void);
  
  void delay(void) {
    int i;
    for (i = 0; i &lt; 5000000; i++)
      ;
  }
  
  int main(void) {
    LED_Initialize();
    Buttons_Initialize();
  
    while (1) {
      if (Buttons_GetState() == 1) {
        LED_On(0);
        LED_On(1);
        LED_On(2);
        LED_On(3);
        delay();
        LED_Off(0);
        LED_Off(1);
        LED_Off(2);
        LED_Off(3);
        delay();
      }
    }
    return 0;
  }
  </code></pre>
  <p>I'm using board support LED and button APIs.</p>
  <p>How do I fix this?</p>
  <p>My debugger starts as follows:</p>
  <p><img src="https://i.stack.imgur.com/CaPsq.png" alt="Debugger view" /></p>