Thread: Delay Function
View Single Post
  #2   Spotlight this post!  
Unread 01-03-2007, 20:17
bear24rw's Avatar
bear24rw bear24rw is offline
Team 11 Programming Captain
AKA: Max T
FRC #0011 (MORT)
Team Role: Programmer
 
Join Date: Sep 2005
Rookie Year: 2005
Location: Flanders, NJ
Posts: 385
bear24rw is a splendid one to beholdbear24rw is a splendid one to beholdbear24rw is a splendid one to beholdbear24rw is a splendid one to beholdbear24rw is a splendid one to beholdbear24rw is a splendid one to beholdbear24rw is a splendid one to behold
Send a message via AIM to bear24rw
Re: Delay Function

Quote:
Originally Posted by Anime-niac_2.9 View Post
i've thought about it before, and it turns out something like bear24rw's idea.

Code:
int counter=0;

void User_Autonomous_Code(void)
{
  static unsigned int i;
  const float delay = 100;
  int counter, int limit=(delay*1000)*26.4;

  for(counter=0, counter<limit, counter++)
  {
  }
}
not necessarilly a function, but the interrupt code here (the for loop) should work. all you have to do if place the for loop whereever you want it
You need to be carefull with that loop, you need to call putdata and getdata every so often so the master processor doesnt shut down.. i forget what the actual timeout is but its not very long...