Log in

View Full Version : main.c


6600gt
28-08-2006, 17:11
in the main.c


while (1) /* This loop will repeat indefinitely. */
{
#ifdef _SIMULATOR
statusflag.NEW_SPI_DATA = 1;
#endif

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) */



shouldn't it be

if(autonomous_mode)
{
User_Autonomous_Code();
}
else
{
Process_Data_From_Master_uP();
}

otherwise it will be executing Process_Data_From_Master_uP() and then User_Autonomous_Code() in auton, every loop, thus eating up a lot of processor time.

Donut
28-08-2006, 17:24
If you take a look at User_Autonomous_Code() in user_routines_fast.c, you'll notice that there is a loop inside the funciton that the controller will not leave until autonomous is over. So no, it shouldn't be since the program can't return to execute Process_Data_From_Master_uP() until autonomous has ended.

Astronouth7303
28-08-2006, 21:29
It's also worth mentioning that getdata() isn't called (and the autonomous flag set) until Process_Data_From_Master_uP() is called. Personally, this is a bug to me. Of course, I've also changed that layout anyway, so it doesn't bug me.

6600gt
29-08-2006, 02:19
whoops...I missed the while loop in user_routines_fast.c...

Anyway, thanks for letting me know