Thread: loop problems
View Single Post
  #2   Spotlight this post!  
Unread 09-02-2006, 13:46
Alan Anderson's Avatar
Alan Anderson Alan Anderson is offline
Software Architect
FRC #0045 (TechnoKats)
Team Role: Mentor
 
Join Date: Feb 2004
Rookie Year: 2004
Location: Kokomo, Indiana
Posts: 9,112
Alan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond repute
Re: loop problems

Four problems jump out at me immediately.

1) This code will execute in a fraction of an eyeblink. It won't even come close to a half second.

2) 255 is not a proper value to send to a pwm. The highest number you should use is 254.

3) You aren't calling Putdata(&txdata) inside the loop. That means the value being stored in pwm06 will not be sent to the hardware until some time after the whole thing is done, so it'll never be set to the high value.

4) Finally, you didn't tell us what the syntax error is, so we can't easily tell you how to fix it.

It's almost never a good idea to put a timing loop like this inside your code, even if you get the loop time set to what you want. If you don't like interrupt-based timers, you can use the fact that Process_Data_From_Master_uP() is called about 39 times per second and maintain a counter to do things after a certain number of calls.