Main loop wierd problem

We hooked up our sensors, and use Kevin’s ADC code to pull them.
Then we check for new adc data in the Process_Data_From_Local_IO() function in user rutines fast.
That is all fine and well (as in, it works exacly like it should).
We recently started to mess around with the autonomus mode, and our debug messages show us that sensor data isn’t being updated while we set the autonomus button. when we unset it, the sensor data does gets updated.
We checked and Process_Data_From_Local_IO() isn’t even called.

while (1)   /* This loop will repeat indefinitely. */
    statusflag.NEW_SPI_DATA = 1;

    if (statusflag.NEW_SPI_DATA)      /* 26.2ms loop area */
    {                                 /* I'm slow!  I only execute every 26.2ms because */
                                      /* that's how fast the Master uP gives me data. */
      Process_Data_From_Master_uP();  /* You edit this in user_routines.c */

      if (autonomous_mode)            /* DO NOT CHANGE! */
        User_Autonomous_Code();        /* You edit this in user_routines_fast.c */
    Process_Data_From_Local_IO();     /* You edit this in user_routines_fast.c */
                                      /* I'm fast!  I execute during every loop.*/
  } /* while (1) */

There is no aperent reason for the autonomus code and mode to affect the runing of the main loop, but for some reason it does.


Are you using Kevin’s new code that uses the 3.0 C compiler? The ADC functions included in that build work well.


No, we are still using 2.6.

Try this code. at
from you can get the C compiler update and MPLab update (8.0) from

the problem dosen’t appear to be in kevin’s code. it’s the first thing we checked. the “cpu” dosn’t seem to get to our sensor data pooling function for no aperent reason.

Just add a call to Process_Data_From_Local_IO() in User_Autonomous_Code()
between the while and the if NEW_SPI_DATA check.