Chief Delphi

Chief Delphi (http://www.chiefdelphi.com/forums/index.php)
-   Programming (http://www.chiefdelphi.com/forums/forumdisplay.php?f=51)
-   -   main.c (http://www.chiefdelphi.com/forums/showthread.php?t=48771)

6600gt 28-08-2006 17:11

main.c
 
in the main.c

Quote:

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

Re: main.c
 
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

Re: main.c
 
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

Re: main.c
 
whoops...I missed the while loop in user_routines_fast.c...

Anyway, thanks for letting me know


All times are GMT -5. The time now is 03:16.

Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi