title: MSP430 Function Call Being Skipped
body: <p>I am programming an MSP430 microcontroller with the MSP430 LaunchPad Dev Kit and I am running into some problems on this simple code. </p>
  
  <pre><code>#include &lt;msp430.h&gt;
  
  void Delay(void);
  
  #define LED1 BIT0                   //define LED1 as bit 0 (0x00)
  #define LED2 BIT6                   //define LED2 as bit 6 (0x40)
  #define delayTime 20000             //define iTime as 20000
  
  int main(void)
  {
      WDTCTL = WDTPW | WDTHOLD;       //stop watchdog timer
      P1DIR |= (LED1|LED2);           //set P1.0 and P1.6 to output direction (P1.3 is naturally an input)
      P1OUT |= LED1;                  //set P1.0 high so the LEDs will blink alternatively
  
      while(1)
      {
          Delay();
          P1OUT ^= (LED1|LED2);       //toggle P1.0 using exclusive-OR
      }
  }
  
  void Delay(void)
  {
      int i = 0;
      while(delayTime &gt; i)
      {
          i++;
      }
  }
  </code></pre>
  
  <p>This code compiles fine, but when debugging the code, the function call 'Delay()' is skipped entirely and the function is never entered. However, when I give the function a return type of 'unsigned int' like this:</p>
  
  <pre><code>unsigned int Delay(void)
  {
      int i = 0;
      while(delayTime &gt; i)
      {
          i++;
      }
      return 1;
  }
  </code></pre>
  
  <p>I can call the Delay function in an if statement like the one below and the debugger will enter the function.</p>
  
  <pre><code>if(Delay() == 1)
  {
      P1OUT ^= (LED1|LED2);       //toggle P1.0 using exclusive-OR
  }
  </code></pre>
  
  <p>I'm sure there is some simple oversight that I'm making. I can't for the life of me figure out why the debugger is skipping my first void function call. Any wisdom?</p>