Contiki help: Cannot understand the variable behavior
<p>I have the following Contiki code where I am just trying to toggle the LEDs based on a variable 'i' being odd or even:</p>

<pre><code>while (1) {
    etimer_set(&amp;et, CLOCK_SECOND * 2);
    PROCESS_WAIT_EVENT_UNTIL(etimer_expired(&amp;et));
    i++;
    printf("i is %2d\n",i);
    if ((i % 2) == 0) {
        printf("Now go green.......\n");
        leds_on(LEDS_GREEN);
        leds_off(LEDS_RED);
    } else {
        printf("Reds again.......\n");
        leds_on(LEDS_RED);
        leds_off(LEDS_GREEN);
    }
}
</code></pre>

<p>The behavior when I run it on the CC2650 is quite strange. It always print i is 1. i has been declared above this code.</p>

<p>If I place the timer set code of two lines at the beginning of the loop however, i counts all the way and has no problem. But in that case, the LED toggles cannot be seen. </p>

<p>What am I missing here?</p>

<p>Please help</p>