Sign in to follow this  
CProgrammer

timing functions

Recommended Posts

CProgrammer    303
Im working on a servo control programm in c for an avr microcontroller. Now my problem is the timing(I need 0.5-1.5ms of the bit set). Here are my 'wait' functions. I use twait to wait 0.5ms for example. Whats wrong with them? I want to be sure these work before I look everywhere why the servo isnt running.
#define CLOCK_KHZ 8000 //8 MHz chip

void cwait(unsigned int cycles)
{        
	int i;
	for(i = 0; i < cycles; ++i)
	{
		;
	}
}

void twait(float milliseconds)
{
	cwait(CLOCK_KHZ*milliseconds);
}

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this