View Single Post
  #2   Spotlight this post!  
Unread 04-01-2005, 16:00
Mark McLeod's Avatar
Mark McLeod Mark McLeod is online now
Just Itinerant
AKA: Hey dad...Father...MARK
FRC #0358 (Robotic Eagles)
Team Role: Engineer
 
Join Date: Mar 2003
Rookie Year: 2002
Location: Hauppauge, Long Island, NY
Posts: 8,820
Mark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond repute
Re: Rewriting main loop

Your code looks fine. There is no magic check to see if you've changed anything in main.c. Lots of teams have rewritten main.c without issues. All the teams I mentor modify main.c for this and a variety of other reasons as well.
I'll see if I can find some past threads on this topic. [edit]http://www.chiefdelphi.com/forums/sh...ad.php?t=24590

Since the call to User_Initialization comes before the loop you posted I suspect other problems.

Here's one stripped down version. For clarity I removed some lines that delayed all action until the sensors stabilize after power-up, resets autonomous upon disable, and a couple of other specialized routine calls like conversion from 0->254 to -127->127. The Put/Getdata calls are also brought into main.c instead of being repeated elsewhere, so User_Autonomous() is a normal routine.
Code:
void main (void)
{
#ifdef UNCHANGEABLE_DEFINITION_AREA
IFI_Initialization ();		/* DO NOT CHANGE! */
#endif
 
User_Initialization();		/* You edit this in user_routines.c */
 
statusflag.NEW_SPI_DATA = 0; /* DO NOT CHANGE! */ 
 
while (1) /* This loop will repeat indefinitely. */
{
#ifdef _SIMULATOR
	statusflag.NEW_SPI_DATA = 1;
#endif
 
	if (statusflag.NEW_SPI_DATA)	 /* 26.2ms loop area */
	{
	 Getdata(&rxdata); /* Get fresh data from the master microprocessor. */
 
	 Process_Data_From_Master_uP(); // Modified to only handle slow loop sensor stuff
 
	 if (competition_mode) // Robot is disabled
	 {
		 Gyro(); // Initialize gyro assumes FRC is powered up only when robot is in position
	 }
	 else if (autonomous_mode) // Robot is in autonomous
	 {
		 User_Autonomous_Code();
	 }
	 else // Robot is in normal human driver mode
	 {
		User_Driver(); // Joystick driving
	 }
 
	 Putdata(&txdata);			 /* DO NOT CHANGE! */
	 }
 
 
	 Process_Data_From_Local_IO();
 
} /* while (1) */
} /* END of Main */
__________________
"Rationality is our distinguishing characteristic - it's what sets us apart from the beasts." - Aristotle

Last edited by Mark McLeod : 05-01-2005 at 08:23.